{
  "openapi": "3.0.3",
  "info": {
    "title": "Wevion API",
    "description": "Public REST API catalog for generated clients and automation. Backoffice-only operations are intentionally excluded.",
    "version": "1.0.0",
    "contact": {
      "name": "Wevion Support",
      "email": "support@wevion.ai",
      "url": "https://wevion.ai"
    },
    "license": {
      "name": "Proprietary",
      "url": "https://wevion.ai/legal/terms"
    }
  },
  "components": {
    "schemas": {
      "ErrorResponse": {
        "type": "object",
        "required": [
          "statusCode",
          "error",
          "message"
        ],
        "properties": {
          "statusCode": {
            "type": "integer",
            "description": "HTTP status code (mirrors the response status)."
          },
          "error": {
            "type": "string",
            "description": "Short human-readable error class (e.g. \"Bad Request\")."
          },
          "message": {
            "type": "string",
            "description": "Human-readable description of what went wrong."
          },
          "code": {
            "type": "string",
            "description": "Optional stable machine-readable identifier (snake_case)."
          },
          "request_id": {
            "type": "string",
            "description": "Fastify request id, propagated for support correlation."
          },
          "details": {
            "type": "object",
            "additionalProperties": true,
            "description": "Optional structured payload (e.g. field-level validation errors)."
          }
        },
        "additionalProperties": false
      },
      "PaginationMeta": {
        "type": "object",
        "required": [
          "page",
          "pageSize",
          "total"
        ],
        "properties": {
          "page": {
            "type": "integer",
            "minimum": 1
          },
          "pageSize": {
            "type": "integer",
            "minimum": 1
          },
          "total": {
            "type": "integer",
            "minimum": 0
          },
          "hasMore": {
            "type": "boolean"
          }
        },
        "additionalProperties": true
      }
    },
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "JWT"
      },
      "apiKeyAuth": {
        "type": "apiKey",
        "in": "header",
        "name": "x-api-key",
        "description": "API key created via `/api/v1/api-keys`. Send as `x-api-key: <key>` header. Permissions are scoped per key at creation time."
      },
      "stripeSignature": {
        "type": "apiKey",
        "in": "header",
        "name": "stripe-signature",
        "description": "Stripe webhook signature. Verified server-side via Stripe SDK against STRIPE_WEBHOOK_SECRET. See https://stripe.com/docs/webhooks/signatures"
      },
      "hmacSha256": {
        "type": "apiKey",
        "in": "header",
        "name": "x-hub-signature-256",
        "description": "HMAC-SHA256 signature of the raw request body, formatted as `sha256=<hex>`. Verified server-side against the provider-specific webhook secret."
      },
      "featurebaseSignature": {
        "type": "apiKey",
        "in": "header",
        "name": "x-webhook-signature",
        "description": "Featurebase webhook signature. HMAC-SHA256 (hex) over `<x-webhook-timestamp>.<raw body>`, verified server-side against FEATUREBASE_WEBHOOK_SECRET with a 5-minute timestamp tolerance (anti-replay). REQUIRES the companion `x-webhook-timestamp` header (unix seconds) alongside this `x-webhook-signature` header."
      },
      "cioReportingSignature": {
        "type": "apiKey",
        "in": "header",
        "name": "x-cio-signature",
        "description": "Customer.io reporting webhook signature. HMAC-SHA256 (hex) over `v0:<x-cio-timestamp>:<raw body>`, verified server-side against CIO_REPORTING_WEBHOOK_SECRET. See https://docs.customer.io/integrations/data-out/connections/webhooks/"
      },
      "telegramSecretToken": {
        "type": "apiKey",
        "in": "header",
        "name": "x-telegram-bot-api-secret-token",
        "description": "Secret token configured via Telegram Bot API `setWebhook`. Compared in constant-time against TELEGRAM_WEBHOOK_SECRET / BETA_FEEDBACK_WEBHOOK_SECRET. See https://core.telegram.org/bots/api#setwebhook"
      }
    }
  },
  "paths": {
    "/ads-status/delete-campaigns": {
      "post": {
        "operationId": "postAdsStatusDeleteCampaigns",
        "summary": "Delete campaigns by account from ads_status sheet",
        "tags": [
          "ads"
        ],
        "description": "Receives a list of account rows and deletes all campaigns associated with each account in Meta.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "sheet_id",
                  "rows"
                ],
                "properties": {
                  "sheet_id": {
                    "description": "Session or batch identifier.",
                    "type": "string"
                  },
                  "rows": {
                    "description": "Array of account rows to process.",
                    "minItems": 1,
                    "type": "array",
                    "items": {
                      "additionalProperties": false,
                      "type": "object",
                      "required": [
                        "sheet_row_number",
                        "account_id",
                        "bm_id"
                      ],
                      "properties": {
                        "sheet_row_number": {
                          "description": "Row number for tracking purposes.",
                          "type": "number"
                        },
                        "account_id": {
                          "description": "Meta Ad Account ID (column identifier).",
                          "type": "string"
                        },
                        "bm_id": {
                          "description": "Business Manager ID (column identifier).",
                          "type": "string"
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "message",
                    "summary"
                  ],
                  "properties": {
                    "message": {
                      "type": "string"
                    },
                    "summary": {
                      "type": "object",
                      "required": [
                        "total_tasks",
                        "skipped_count",
                        "accounts_processed"
                      ],
                      "properties": {
                        "total_tasks": {
                          "type": "number"
                        },
                        "skipped_count": {
                          "type": "number"
                        },
                        "accounts_processed": {
                          "type": "number"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/ads-status": {
      "post": {
        "operationId": "postAdsStatus",
        "summary": "Execute ads checker",
        "tags": [
          "ads"
        ],
        "description": "Receives a sheet id, retrieve all associated accounts and then update ads status.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "sheet_id"
                ],
                "properties": {
                  "sheet_id": {
                    "description": "The ID of the sheet containing ad data.",
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "message"
                  ],
                  "properties": {
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/ads/actions": {
      "put": {
        "operationId": "putAdsActions",
        "summary": "Process ad toggle actions",
        "tags": [
          "ads"
        ],
        "description": "Receives a list of ad toggle actions and processes them asynchronously via SQS workers.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "sheet_id",
                  "rows"
                ],
                "properties": {
                  "sheet_id": {
                    "description": "Session or batch identifier.",
                    "type": "string"
                  },
                  "rows": {
                    "description": "Array of ad actions to process.",
                    "minItems": 1,
                    "type": "array",
                    "items": {
                      "additionalProperties": false,
                      "type": "object",
                      "required": [
                        "sheet_row_number",
                        "ad_id",
                        "account_id",
                        "bm_id"
                      ],
                      "properties": {
                        "sheet_row_number": {
                          "description": "Row number for tracking purposes.",
                          "type": "number"
                        },
                        "ad_id": {
                          "description": "Meta WevionAd ID to toggle.",
                          "type": "string"
                        },
                        "account_id": {
                          "description": "Meta WevionAd Account ID associated with the ad.",
                          "type": "string"
                        },
                        "bm_id": {
                          "description": "Business Manager ID.",
                          "type": "string"
                        },
                        "toggle_action": {
                          "description": "Whether to toggle the ad. Defaults to false if not provided.",
                          "anyOf": [
                            {
                              "type": "string",
                              "enum": [
                                "ACTIVE"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "PAUSED"
                              ]
                            }
                          ]
                        },
                        "delete_action": {
                          "description": "Delete (archive) the ad on Meta.",
                          "type": "boolean"
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "message"
                  ],
                  "properties": {
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "207": {
            "description": "Multi-status - partial success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message",
                    "errors"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "errors": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "ad_id",
                          "action",
                          "error"
                        ],
                        "properties": {
                          "ad_id": {
                            "type": "string"
                          },
                          "action": {
                            "type": "string"
                          },
                          "error": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "422": {
            "description": "Unprocessable entity - semantic validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/adsets/actions": {
      "put": {
        "operationId": "putAdsetsActions",
        "summary": "Process adset actions (edit bid and/or toggle",
        "tags": [
          "ads"
        ],
        "description": "Receives a batch of adset actions and processes them asynchronously via SQS.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "sheet_id",
                  "rows"
                ],
                "properties": {
                  "sheet_id": {
                    "description": "The ID of the Google Sheet.",
                    "type": "string"
                  },
                  "rows": {
                    "description": "Array of adset actions to process.",
                    "type": "array",
                    "items": {
                      "additionalProperties": false,
                      "type": "object",
                      "required": [
                        "adset_id",
                        "bm_id",
                        "account_id",
                        "sheet_row_number"
                      ],
                      "properties": {
                        "adset_id": {
                          "description": "The ID of the Meta Ad Set.",
                          "type": "string"
                        },
                        "bm_id": {
                          "description": "The business manager ID.",
                          "type": "string"
                        },
                        "account_id": {
                          "description": "The ad account ID.",
                          "type": "string"
                        },
                        "new_bid_amount": {
                          "description": "New bid amount in cents (minimum currency units). Passed directly to Meta API.",
                          "type": "number"
                        },
                        "new_daily_budget": {
                          "description": "New daily budget in cents (minimum currency units). Passed directly to Meta API.",
                          "type": "number"
                        },
                        "toggle_action": {
                          "description": "Whether to turn off the adset.",
                          "anyOf": [
                            {
                              "type": "string",
                              "enum": [
                                "ACTIVE"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "PAUSED"
                              ]
                            }
                          ]
                        },
                        "delete_action": {
                          "description": "Delete (archive) the adset on Meta.",
                          "type": "boolean"
                        },
                        "sheet_row_number": {
                          "description": "Real row number in Google Sheet (1-based).",
                          "type": "number"
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "message"
                  ],
                  "properties": {
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "207": {
            "description": "Multi-status - partial success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message",
                    "errors"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "errors": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "adset_id",
                          "action",
                          "error"
                        ],
                        "properties": {
                          "adset_id": {
                            "type": "string"
                          },
                          "action": {
                            "type": "string"
                          },
                          "error": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "422": {
            "description": "Unprocessable entity - semantic validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/account-health": {
      "get": {
        "operationId": "getApiV1AccountHealth",
        "summary": "List ad account health snapshots",
        "tags": [
          "account-health"
        ],
        "description": "Returns the latest health score snapshot for each accessible ad account.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "accounts",
                    "last_updated"
                  ],
                  "properties": {
                    "accounts": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "platform",
                          "ad_account_id",
                          "account_name",
                          "owner_email",
                          "score",
                          "level",
                          "breakdown",
                          "delta_1d",
                          "delta_7d",
                          "snapshot_date",
                          "details"
                        ],
                        "properties": {
                          "platform": {
                            "anyOf": [
                              {
                                "type": "string",
                                "enum": [
                                  "meta"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "google"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "tiktok"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "taboola"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "snapchat"
                                ]
                              }
                            ]
                          },
                          "ad_account_id": {
                            "type": "string"
                          },
                          "account_name": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "owner_email": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "score": {
                            "type": "integer"
                          },
                          "level": {
                            "anyOf": [
                              {
                                "type": "string",
                                "enum": [
                                  "healthy"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "warning"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "critical"
                                ]
                              }
                            ]
                          },
                          "breakdown": {
                            "type": "object",
                            "required": [
                              "spend_efficiency",
                              "performance_trend",
                              "operational_errors",
                              "creative_fatigue"
                            ],
                            "properties": {
                              "spend_efficiency": {
                                "type": "number"
                              },
                              "performance_trend": {
                                "type": "number"
                              },
                              "operational_errors": {
                                "type": "number"
                              },
                              "creative_fatigue": {
                                "type": "number"
                              }
                            }
                          },
                          "delta_1d": {
                            "anyOf": [
                              {
                                "type": "integer"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "delta_7d": {
                            "anyOf": [
                              {
                                "type": "integer"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "snapshot_date": {
                            "format": "date",
                            "type": "string"
                          },
                          "details": {
                            "additionalProperties": false,
                            "type": "object",
                            "properties": {
                              "account_active": {
                                "type": "boolean"
                              },
                              "account_status": {
                                "anyOf": [
                                  {
                                    "type": "number"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "conversions_delta": {
                                "anyOf": [
                                  {
                                    "type": "number"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "cpc_delta": {
                                "anyOf": [
                                  {
                                    "type": "number"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "ctr_decay": {
                                "anyOf": [
                                  {
                                    "type": "number"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "ctr_delta": {
                                "anyOf": [
                                  {
                                    "type": "number"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "frequency_avg": {
                                "anyOf": [
                                  {
                                    "type": "number"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "rejected_campaigns": {
                                "type": "number"
                              },
                              "roas": {
                                "anyOf": [
                                  {
                                    "type": "number"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "spend_total": {
                                "type": "number"
                              },
                              "target_roas": {
                                "anyOf": [
                                  {
                                    "type": "number"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              }
                            }
                          }
                        }
                      }
                    },
                    "last_updated": {
                      "anyOf": [
                        {
                          "format": "date-time",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "error_code": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/account-health/{platform}/{account_id}": {
      "get": {
        "operationId": "getApiV1AccountHealthByPlatformByAccountId",
        "summary": "Get ad account health snapshot",
        "tags": [
          "account-health"
        ],
        "description": "Returns the latest health score snapshot for one platform account.",
        "parameters": [
          {
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "enum": [
                    "meta"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "google"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "tiktok"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "taboola"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "snapchat"
                  ]
                }
              ]
            },
            "in": "path",
            "name": "platform",
            "required": true
          },
          {
            "schema": {
              "minLength": 1,
              "maxLength": 50,
              "type": "string"
            },
            "in": "path",
            "name": "account_id",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "platform",
                    "ad_account_id",
                    "account_name",
                    "owner_email",
                    "score",
                    "level",
                    "breakdown",
                    "delta_1d",
                    "delta_7d",
                    "snapshot_date",
                    "details"
                  ],
                  "properties": {
                    "platform": {
                      "anyOf": [
                        {
                          "type": "string",
                          "enum": [
                            "meta"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "google"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "tiktok"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "taboola"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "snapchat"
                          ]
                        }
                      ]
                    },
                    "ad_account_id": {
                      "type": "string"
                    },
                    "account_name": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "owner_email": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "score": {
                      "type": "integer"
                    },
                    "level": {
                      "anyOf": [
                        {
                          "type": "string",
                          "enum": [
                            "healthy"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "warning"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "critical"
                          ]
                        }
                      ]
                    },
                    "breakdown": {
                      "type": "object",
                      "required": [
                        "spend_efficiency",
                        "performance_trend",
                        "operational_errors",
                        "creative_fatigue"
                      ],
                      "properties": {
                        "spend_efficiency": {
                          "type": "number"
                        },
                        "performance_trend": {
                          "type": "number"
                        },
                        "operational_errors": {
                          "type": "number"
                        },
                        "creative_fatigue": {
                          "type": "number"
                        }
                      }
                    },
                    "delta_1d": {
                      "anyOf": [
                        {
                          "type": "integer"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "delta_7d": {
                      "anyOf": [
                        {
                          "type": "integer"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "snapshot_date": {
                      "format": "date",
                      "type": "string"
                    },
                    "details": {
                      "additionalProperties": false,
                      "type": "object",
                      "properties": {
                        "account_active": {
                          "type": "boolean"
                        },
                        "account_status": {
                          "anyOf": [
                            {
                              "type": "number"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "conversions_delta": {
                          "anyOf": [
                            {
                              "type": "number"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "cpc_delta": {
                          "anyOf": [
                            {
                              "type": "number"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "ctr_decay": {
                          "anyOf": [
                            {
                              "type": "number"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "ctr_delta": {
                          "anyOf": [
                            {
                              "type": "number"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "frequency_avg": {
                          "anyOf": [
                            {
                              "type": "number"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "rejected_campaigns": {
                          "type": "number"
                        },
                        "roas": {
                          "anyOf": [
                            {
                              "type": "number"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "spend_total": {
                          "type": "number"
                        },
                        "target_roas": {
                          "anyOf": [
                            {
                              "type": "number"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "error_code": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "error_code": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/account-health/{platform}/{account_id}/history": {
      "get": {
        "operationId": "getApiV1AccountHealthByPlatformByAccountIdHistory",
        "summary": "Get ad account health history",
        "tags": [
          "account-health"
        ],
        "description": "Returns historical component scores for one platform account.",
        "parameters": [
          {
            "schema": {
              "minimum": 1,
              "maximum": 365,
              "type": "integer"
            },
            "in": "query",
            "name": "days",
            "required": false
          },
          {
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "enum": [
                    "meta"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "google"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "tiktok"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "taboola"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "snapchat"
                  ]
                }
              ]
            },
            "in": "path",
            "name": "platform",
            "required": true
          },
          {
            "schema": {
              "minLength": 1,
              "maxLength": 50,
              "type": "string"
            },
            "in": "path",
            "name": "account_id",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "platform",
                    "ad_account_id",
                    "items"
                  ],
                  "properties": {
                    "platform": {
                      "anyOf": [
                        {
                          "type": "string",
                          "enum": [
                            "meta"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "google"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "tiktok"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "taboola"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "snapchat"
                          ]
                        }
                      ]
                    },
                    "ad_account_id": {
                      "type": "string"
                    },
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "snapshot_date",
                          "total_score",
                          "spend_efficiency",
                          "performance_trend",
                          "operational_errors",
                          "creative_fatigue"
                        ],
                        "properties": {
                          "snapshot_date": {
                            "format": "date",
                            "type": "string"
                          },
                          "total_score": {
                            "type": "integer"
                          },
                          "spend_efficiency": {
                            "type": "integer"
                          },
                          "performance_trend": {
                            "type": "integer"
                          },
                          "operational_errors": {
                            "type": "integer"
                          },
                          "creative_fatigue": {
                            "type": "integer"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "error_code": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/account-health/config": {
      "get": {
        "operationId": "getApiV1AccountHealthConfig",
        "summary": "Get account health configuration",
        "tags": [
          "account-health"
        ],
        "description": "Returns the authenticated user account health scoring and alert configuration.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "alert_threshold_drop",
                    "alert_threshold_min",
                    "target_roas",
                    "alert_cooldown_hours"
                  ],
                  "properties": {
                    "alert_threshold_drop": {
                      "minimum": 1,
                      "maximum": 100,
                      "type": "integer"
                    },
                    "alert_threshold_min": {
                      "minimum": 0,
                      "maximum": 100,
                      "type": "integer"
                    },
                    "target_roas": {
                      "anyOf": [
                        {
                          "minimum": 0,
                          "type": "number"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "alert_cooldown_hours": {
                      "minimum": 1,
                      "maximum": 168,
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "error_code": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      },
      "put": {
        "operationId": "putApiV1AccountHealthConfig",
        "summary": "Update account health configuration",
        "tags": [
          "account-health"
        ],
        "description": "Updates account health scoring and alert thresholds for the authenticated user.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "alert_threshold_drop": {
                    "minimum": 1,
                    "maximum": 100,
                    "type": "integer"
                  },
                  "alert_threshold_min": {
                    "minimum": 0,
                    "maximum": 100,
                    "type": "integer"
                  },
                  "target_roas": {
                    "anyOf": [
                      {
                        "minimum": 0,
                        "type": "number"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "alert_cooldown_hours": {
                    "minimum": 1,
                    "maximum": 168,
                    "type": "integer"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "alert_threshold_drop",
                    "alert_threshold_min",
                    "target_roas",
                    "alert_cooldown_hours"
                  ],
                  "properties": {
                    "alert_threshold_drop": {
                      "minimum": 1,
                      "maximum": 100,
                      "type": "integer"
                    },
                    "alert_threshold_min": {
                      "minimum": 0,
                      "maximum": 100,
                      "type": "integer"
                    },
                    "target_roas": {
                      "anyOf": [
                        {
                          "minimum": 0,
                          "type": "number"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "alert_cooldown_hours": {
                      "minimum": 1,
                      "maximum": 168,
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "error_code": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "error_code": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/ad-accounts/{accountId}/conversion-events": {
      "get": {
        "operationId": "getApiV1AdAccountsByAccountIdConversionEvents",
        "summary": "List available pixel conversion events for an ad account",
        "tags": [
          "ad-accounts"
        ],
        "description": "Discovers pixel conversion events from the last 30 days of ad insights data for the specified ad account.",
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "in": "path",
            "name": "accountId",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "items"
                  ],
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "action_type",
                          "count"
                        ],
                        "properties": {
                          "action_type": {
                            "type": "string"
                          },
                          "count": {
                            "type": "integer"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/ad-accounts/{accountId}/conversion-settings": {
      "get": {
        "operationId": "getApiV1AdAccountsByAccountIdConversionSettings",
        "summary": "Get current conversion settings for an ad account",
        "tags": [
          "ad-accounts"
        ],
        "description": "Returns the default optimization event and optional default pixel id stored for the requested Meta ad account, scoped to the caller team.",
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "in": "path",
            "name": "accountId",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "default_conversion_event",
                    "default_conversion_pixel_id"
                  ],
                  "properties": {
                    "default_conversion_event": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "default_conversion_pixel_id": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      },
      "put": {
        "operationId": "putApiV1AdAccountsByAccountIdConversionSettings",
        "summary": "Update conversion settings for an ad account",
        "tags": [
          "ad-accounts"
        ],
        "description": "Persists the default conversion event and optional default pixel id for the requested Meta ad account so campaign creation can preselect the team-approved conversion settings.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "default_conversion_event"
                ],
                "properties": {
                  "default_conversion_event": {
                    "anyOf": [
                      {
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "default_conversion_pixel_id": {
                    "anyOf": [
                      {
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "in": "path",
            "name": "accountId",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "default_conversion_event",
                    "default_conversion_pixel_id"
                  ],
                  "properties": {
                    "default_conversion_event": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "default_conversion_pixel_id": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/ad-accounts/extended": {
      "get": {
        "operationId": "getExtendedAdAccounts",
        "summary": "Get extended ad account info from Meta",
        "tags": [
          "ad-accounts"
        ],
        "description": "Fetches extended financial info (spend cap, amount spent, balance, payment method) from Meta Batch API for all ad accounts of the authenticated user. `accounts` is a map keyed by Meta account_id; when no tokens/eligible accounts are present it may be emitted as an empty collection.",
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "accounts"
                  ],
                  "properties": {
                    "accounts": {
                      "anyOf": [
                        {
                          "type": "object",
                          "additionalProperties": {
                            "type": "object",
                            "required": [
                              "account_id",
                              "account_status",
                              "spend_cap",
                              "amount_spent",
                              "balance",
                              "funding_type",
                              "funding_label",
                              "funding_display",
                              "currency"
                            ],
                            "properties": {
                              "account_id": {
                                "type": "string"
                              },
                              "account_status": {
                                "type": "integer"
                              },
                              "spend_cap": {
                                "anyOf": [
                                  {
                                    "type": "number"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "amount_spent": {
                                "type": "number"
                              },
                              "balance": {
                                "type": "number"
                              },
                              "funding_type": {
                                "anyOf": [
                                  {
                                    "type": "integer"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "funding_label": {
                                "type": "string"
                              },
                              "funding_display": {
                                "type": "string"
                              },
                              "currency": {
                                "type": "string"
                              }
                            }
                          }
                        },
                        {
                          "maxItems": 0,
                          "type": "array",
                          "items": {
                            "type": "object",
                            "required": [
                              "account_id",
                              "account_status",
                              "spend_cap",
                              "amount_spent",
                              "balance",
                              "funding_type",
                              "funding_label",
                              "funding_display",
                              "currency"
                            ],
                            "properties": {
                              "account_id": {
                                "type": "string"
                              },
                              "account_status": {
                                "type": "integer"
                              },
                              "spend_cap": {
                                "anyOf": [
                                  {
                                    "type": "number"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "amount_spent": {
                                "type": "number"
                              },
                              "balance": {
                                "type": "number"
                              },
                              "funding_type": {
                                "anyOf": [
                                  {
                                    "type": "integer"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "funding_label": {
                                "type": "string"
                              },
                              "funding_display": {
                                "type": "string"
                              },
                              "currency": {
                                "type": "string"
                              }
                            }
                          }
                        }
                      ]
                    },
                    "skipped": {
                      "type": "object",
                      "required": [
                        "noToken"
                      ],
                      "properties": {
                        "noToken": {
                          "type": "integer"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/ad-accounts": {
      "get": {
        "operationId": "getApiV1AdAccounts",
        "summary": "Get ad accounts (server-side paginated)",
        "tags": [
          "ad-accounts"
        ],
        "description": "Returns a server-side paginated, filtered, sorted list of Meta Ad Accounts. Supports offset pagination, search, and multiple filter dimensions. Results are scoped to the active workspace: accounts stamped with a team of the active scope plus legacy rows owned by accessible sessions.",
        "parameters": [
          {
            "schema": {
              "minimum": 1,
              "maximum": 100,
              "default": 50,
              "type": "integer"
            },
            "in": "query",
            "name": "limit",
            "required": false
          },
          {
            "schema": {
              "minimum": 0,
              "default": 0,
              "type": "integer"
            },
            "in": "query",
            "name": "offset",
            "required": false
          },
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "query",
            "name": "member_id",
            "required": false
          },
          {
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "enum": [
                    "account_name"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "business_name"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "connected"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "account_status"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "account_currency"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "account_timezone_offset_hours_utc"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "amount_spent"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "ownership_type"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "created_at"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "updated_at"
                  ]
                }
              ]
            },
            "in": "query",
            "name": "sort_by",
            "required": false
          },
          {
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "enum": [
                    "asc"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "desc"
                  ]
                }
              ]
            },
            "in": "query",
            "name": "sort_order",
            "required": false
          },
          {
            "schema": {
              "minLength": 2,
              "maxLength": 200,
              "type": "string"
            },
            "in": "query",
            "name": "search",
            "required": false
          },
          {
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "enum": [
                    "connected"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "disconnected"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "error"
                  ]
                }
              ]
            },
            "in": "query",
            "name": "connected",
            "required": false
          },
          {
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "enum": [
                    "active"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "disabled"
                  ]
                }
              ]
            },
            "in": "query",
            "name": "account_status",
            "required": false
          },
          {
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "enum": [
                    "true"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "false"
                  ]
                }
              ]
            },
            "in": "query",
            "name": "is_active",
            "required": false
          },
          {
            "schema": {
              "maxLength": 20,
              "type": "string"
            },
            "in": "query",
            "name": "ownership_type",
            "required": false
          },
          {
            "schema": {
              "maxLength": 1000,
              "type": "string"
            },
            "in": "query",
            "name": "business_id",
            "required": false
          },
          {
            "schema": {
              "maxLength": 10,
              "type": "string"
            },
            "in": "query",
            "name": "currency",
            "required": false
          },
          {
            "schema": {
              "format": "date-time",
              "type": "string"
            },
            "in": "query",
            "name": "created_from",
            "required": false
          },
          {
            "schema": {
              "format": "date-time",
              "type": "string"
            },
            "in": "query",
            "name": "created_to",
            "required": false
          },
          {
            "schema": {
              "format": "date-time",
              "type": "string"
            },
            "in": "query",
            "name": "updated_from",
            "required": false
          },
          {
            "schema": {
              "format": "date-time",
              "type": "string"
            },
            "in": "query",
            "name": "updated_to",
            "required": false
          },
          {
            "schema": {
              "maxLength": 10,
              "type": "string"
            },
            "in": "query",
            "name": "platform",
            "required": false
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "items",
                    "total",
                    "counts"
                  ],
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "id",
                          "account_id",
                          "account_name",
                          "business_id",
                          "business_name",
                          "connected",
                          "is_active",
                          "account_currency",
                          "account_timezone",
                          "account_timezone_offset_hours_utc",
                          "created_at",
                          "updated_at",
                          "account_status",
                          "spend_cap",
                          "amount_spent",
                          "balance",
                          "funding_type",
                          "funding_label",
                          "funding_display",
                          "extended_synced_at",
                          "default_conversion_event",
                          "default_conversion_pixel_id",
                          "advantage_plus_eligible",
                          "threads_placement_enabled",
                          "ai_creative_enabled"
                        ],
                        "properties": {
                          "id": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "account_id": {
                            "type": "string"
                          },
                          "account_name": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "business_id": {
                            "type": "string"
                          },
                          "business_name": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "connected": {
                            "type": "boolean"
                          },
                          "is_active": {
                            "anyOf": [
                              {
                                "type": "boolean"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "account_currency": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "account_timezone": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "account_timezone_offset_hours_utc": {
                            "anyOf": [
                              {
                                "type": "number"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "created_at": {
                            "format": "date-time",
                            "type": "string"
                          },
                          "updated_at": {
                            "anyOf": [
                              {
                                "format": "date-time",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "account_status": {
                            "anyOf": [
                              {
                                "type": "integer"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "spend_cap": {
                            "anyOf": [
                              {
                                "type": "number"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "amount_spent": {
                            "anyOf": [
                              {
                                "type": "number"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "balance": {
                            "anyOf": [
                              {
                                "type": "number"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "funding_type": {
                            "anyOf": [
                              {
                                "type": "integer"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "funding_label": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "funding_display": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "extended_synced_at": {
                            "anyOf": [
                              {
                                "format": "date-time",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "ownership_type": {
                            "type": "string"
                          },
                          "platform": {
                            "type": "string"
                          },
                          "default_conversion_event": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "default_conversion_pixel_id": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "sheet_id": {
                            "type": "string"
                          },
                          "member_name": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "member_email": {
                            "type": "string"
                          },
                          "team_name": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "advantage_plus_eligible": {
                            "anyOf": [
                              {
                                "type": "boolean"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "threads_placement_enabled": {
                            "anyOf": [
                              {
                                "type": "boolean"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "ai_creative_enabled": {
                            "anyOf": [
                              {
                                "type": "boolean"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "platform_status": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "session_id": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "auth_email": {
                            "type": "string"
                          },
                          "auth_display_name": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "token_active": {
                            "type": "boolean"
                          }
                        }
                      }
                    },
                    "total": {
                      "type": "integer"
                    },
                    "counts": {
                      "type": "object",
                      "required": [
                        "total",
                        "connected",
                        "active"
                      ],
                      "properties": {
                        "total": {
                          "type": "integer"
                        },
                        "connected": {
                          "type": "integer"
                        },
                        "active": {
                          "type": "integer"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/ad-accounts/health-map": {
      "get": {
        "operationId": "getApiV1AdAccountsHealthMap",
        "summary": "Get health map of ad accounts (healthy / tokens_expired / disconnected)",
        "tags": [
          "ad-accounts"
        ],
        "description": "Returns a map keyed by Meta ad account id with the best actionable health state across accessible rows. Used by clients to avoid running campaign actions against disconnected accounts or accounts with expired tokens.",
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "items"
                  ],
                  "properties": {
                    "items": {
                      "type": "object",
                      "additionalProperties": {
                        "anyOf": [
                          {
                            "type": "string",
                            "enum": [
                              "healthy"
                            ]
                          },
                          {
                            "type": "string",
                            "enum": [
                              "tokens_expired"
                            ]
                          },
                          {
                            "type": "string",
                            "enum": [
                              "disconnected"
                            ]
                          }
                        ]
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/ad-accounts/businesses": {
      "get": {
        "operationId": "getApiV1AdAccountsBusinesses",
        "summary": "List businesses available for ad accounts",
        "tags": [
          "ad-accounts"
        ],
        "description": "Returns distinct Meta Business Manager ids and names represented by ad accounts visible to the caller, respecting team/member scoping.",
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "items"
                  ],
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "id",
                          "name"
                        ],
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "name": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/ad-accounts/currencies": {
      "get": {
        "operationId": "getApiV1AdAccountsCurrencies",
        "summary": "List currencies available for ad accounts",
        "tags": [
          "ad-accounts"
        ],
        "description": "Returns distinct account currency codes from ad accounts visible to the caller so clients can populate account filters without scanning the full account list.",
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "items"
                  ],
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/ad-accounts/{accountId}/custom-audiences": {
      "get": {
        "operationId": "getApiV1AdAccountsByAccountIdCustomAudiences",
        "summary": "Get custom audiences for an ad account",
        "tags": [
          "ad-accounts"
        ],
        "description": "Fetches custom audiences from Meta Graph API for the specified ad account.",
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "in": "path",
            "name": "accountId",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "audiences"
                  ],
                  "properties": {
                    "audiences": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "id",
                          "name",
                          "description",
                          "approximate_count"
                        ],
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "name": {
                            "type": "string"
                          },
                          "description": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "approximate_count": {
                            "type": "number"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/ad-accounts/assign-all": {
      "post": {
        "operationId": "postApiV1AdAccountsAssignAll",
        "summary": "Assign all eligible ad accounts across team members",
        "tags": [
          "ad-accounts"
        ],
        "description": "Finds all ad accounts for the team, filters out disabled ones (account_status not null and not 1), groups by sheet_id, and assigns each group via the assign service.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "properties": {
                  "connected": {
                    "type": "boolean"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "assigned",
                    "skipped_disabled"
                  ],
                  "properties": {
                    "assigned": {
                      "type": "integer"
                    },
                    "skipped_disabled": {
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/ad-accounts/connect": {
      "post": {
        "operationId": "postApiV1AdAccountsConnect",
        "summary": "Connect non-Meta ad accounts",
        "tags": [
          "ad-accounts"
        ],
        "description": "Marks selected non-Meta platform ad accounts as connected for the authenticated user/team and publishes an ad_accounts asset event.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "account_ids",
                  "platform"
                ],
                "properties": {
                  "account_ids": {
                    "minItems": 1,
                    "maxItems": 100,
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  },
                  "platform": {
                    "maxLength": 10,
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "updated"
                  ],
                  "properties": {
                    "updated": {
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "anyOf": [
                    {
                      "type": "object",
                      "required": [
                        "statusCode",
                        "error",
                        "message",
                        "code",
                        "resource",
                        "current",
                        "max",
                        "plan"
                      ],
                      "properties": {
                        "statusCode": {
                          "type": "number"
                        },
                        "error": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "code": {
                          "type": "string"
                        },
                        "resource": {
                          "type": "string"
                        },
                        "current": {
                          "type": "number"
                        },
                        "max": {
                          "type": "number"
                        },
                        "plan": {
                          "type": "string"
                        }
                      }
                    },
                    {
                      "type": "object",
                      "required": [
                        "statusCode",
                        "error",
                        "message"
                      ],
                      "properties": {
                        "statusCode": {
                          "type": "number"
                        },
                        "error": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        }
                      }
                    }
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/ad-accounts/disconnect": {
      "post": {
        "operationId": "postApiV1AdAccountsDisconnect",
        "summary": "Disconnect non-Meta ad accounts",
        "tags": [
          "ad-accounts"
        ],
        "description": "Marks selected non-Meta platform ad accounts as disconnected for the authenticated user/team and publishes an ad_accounts asset event.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "account_ids",
                  "platform"
                ],
                "properties": {
                  "account_ids": {
                    "minItems": 1,
                    "maxItems": 100,
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  },
                  "platform": {
                    "maxLength": 10,
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "updated"
                  ],
                  "properties": {
                    "updated": {
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/ads/{ad_id}/creative": {
      "get": {
        "operationId": "getAdCreativeFlat",
        "summary": "Get an ad creative (flat)",
        "tags": [
          "campaigns"
        ],
        "description": "Fetches the creative of a Meta ad and normalizes it to a flat shape (primary text, headline, description, CTA, link, url_tags, media). Used to pre-fill the duplicate-ad creative override form.",
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "account_id",
            "required": true
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "path",
            "name": "ad_id",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "ad_name",
                    "page_id",
                    "instagram_user_id",
                    "primary_text",
                    "headline",
                    "description",
                    "call_to_action",
                    "link",
                    "url_tags",
                    "media_type"
                  ],
                  "properties": {
                    "ad_name": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "page_id": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "instagram_user_id": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "primary_text": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "headline": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "description": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "call_to_action": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "link": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "url_tags": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "media_type": {
                      "anyOf": [
                        {
                          "type": "string",
                          "enum": [
                            "image"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "video"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "other"
                          ]
                        }
                      ]
                    },
                    "image_hash": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "video_id": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "thumbnail_url": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/ad-creatives/{adId}": {
      "get": {
        "operationId": "getAdCreative",
        "summary": "Get ad creative details",
        "tags": [
          "ad-creatives"
        ],
        "description": "Fetches creative details for an ad from Meta API, including thumbnail, image, video source, and full picture. For video creatives it also mirrors the video node's read-only `is_ai_generated` flag as `meta_ai_recognized` (present only when Meta reports it; absent means unknown, not \"not AI\"). Falls back to DB-stored thumbnail if the API call fails. Shape tracks Meta Graph v25.0 and tolerates additional pass-through fields.",
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "ad_account_id",
            "required": false
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "sheet_id",
            "required": false
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "path",
            "name": "adId",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "ad_id",
                    "creative"
                  ],
                  "properties": {
                    "ad_id": {
                      "type": "string"
                    },
                    "creative": {
                      "anyOf": [
                        {
                          "type": "null"
                        },
                        {
                          "additionalProperties": {
                            "$comment": "json-value",
                            "description": "Arbitrary JSON value with nested arrays and objects."
                          },
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "string"
                            },
                            "body": {
                              "type": "string"
                            },
                            "title": {
                              "type": "string"
                            },
                            "description": {
                              "type": "string"
                            },
                            "caption": {
                              "type": "string"
                            },
                            "link_url": {
                              "type": "string"
                            },
                            "image_url": {
                              "type": "string"
                            },
                            "thumbnail_url": {
                              "type": "string"
                            },
                            "full_picture": {
                              "type": "string"
                            },
                            "video_id": {
                              "type": "string"
                            },
                            "video_url": {
                              "type": "string"
                            },
                            "video_proxy_url": {
                              "type": "string"
                            },
                            "meta_ai_recognized": {
                              "type": "boolean"
                            },
                            "call_to_action_type": {
                              "type": "string"
                            },
                            "effective_object_story_id": {
                              "type": "string"
                            },
                            "object_story_spec": {
                              "type": "object",
                              "properties": {
                                "link_data": {
                                  "type": "object",
                                  "properties": {
                                    "call_to_action": {
                                      "type": "object",
                                      "properties": {
                                        "type": {
                                          "type": "string"
                                        },
                                        "value": {
                                          "$comment": "json-value",
                                          "description": "Arbitrary JSON value with nested arrays and objects."
                                        }
                                      }
                                    },
                                    "caption": {
                                      "type": "string"
                                    },
                                    "description": {
                                      "type": "string"
                                    },
                                    "link": {
                                      "type": "string"
                                    },
                                    "message": {
                                      "type": "string"
                                    },
                                    "name": {
                                      "type": "string"
                                    },
                                    "video_id": {
                                      "type": "string"
                                    }
                                  }
                                },
                                "video_data": {
                                  "type": "object",
                                  "properties": {
                                    "call_to_action": {
                                      "type": "object",
                                      "properties": {
                                        "type": {
                                          "type": "string"
                                        },
                                        "value": {
                                          "$comment": "json-value",
                                          "description": "Arbitrary JSON value with nested arrays and objects."
                                        }
                                      }
                                    },
                                    "message": {
                                      "type": "string"
                                    },
                                    "title": {
                                      "type": "string"
                                    },
                                    "video_id": {
                                      "type": "string"
                                    }
                                  }
                                }
                              }
                            }
                          }
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/ad-creatives/{adId}/video": {
      "get": {
        "operationId": "getApiV1AdCreativesByAdIdVideo",
        "summary": "Stream ad video",
        "tags": [
          "ad-creatives"
        ],
        "description": "Proxies the Meta video source to avoid CORS issues. Accepts JWT via Authorization header or ?token= query param for use in video tags. Response body is the raw video stream (typically video/mp4) and supports HTTP Range requests; error responses are JSON.",
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "token",
            "required": false
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "sheet_id",
            "required": false
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "ad_account_id",
            "required": false
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "path",
            "name": "adId",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Streamed ad video (typically video/mp4) with HTTP Range support.",
            "content": {
              "video/mp4": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              },
              "video/webm": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/ad-creatives/{adId}/thumbnail-url": {
      "get": {
        "operationId": "getApiV1AdCreativesByAdIdThumbnailUrl",
        "summary": "Get signed thumbnail proxy URL",
        "tags": [
          "ad-creatives"
        ],
        "description": "Returns an HMAC-signed URL for the thumbnail proxy endpoint. The signed URL is valid for 1 hour and can be used directly in <img src> without Bearer auth.",
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "ad_account_id",
            "required": false
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "path",
            "name": "adId",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "url"
                  ],
                  "properties": {
                    "url": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/ad-creatives/{adId}/thumbnail": {
      "get": {
        "operationId": "getApiV1AdCreativesByAdIdThumbnail",
        "summary": "Proxy ad thumbnail image",
        "tags": [
          "ad-creatives"
        ],
        "description": "Fetches a fresh thumbnail from Meta API and streams the image to the client. Requires a valid HMAC signature via sig/exp query parameters.",
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "sig",
            "required": true
          },
          {
            "schema": {
              "type": "number"
            },
            "in": "query",
            "name": "exp",
            "required": true
          },
          {
            "schema": {
              "minimum": 32,
              "maximum": 800,
              "type": "number"
            },
            "in": "query",
            "name": "size",
            "required": false
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "acct",
            "required": false
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "path",
            "name": "adId",
            "required": true
          }
        ],
        "responses": {
          "200": {
            "description": "Ad creative thumbnail image (proxied from Meta).",
            "content": {
              "image/jpeg": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              },
              "image/png": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ]
      }
    },
    "/api/v1/ads/{id}/edit-canonical": {
      "post": {
        "operationId": "postApiV1AdsByIdEditCanonical",
        "summary": "Build an inline canonical campaign for the Edit Ad editor",
        "tags": [
          "ads"
        ],
        "description": "Resolves an existing ad (Meta, Snapchat, Taboola, Google, or TikTok — creative/item, ad set, campaign, account) and returns an `ads_only` canonical campaign prefilled for the campaign-creator pro mode editor. No `campaign_draft` row is created — the editor keeps the canonical inline and posts it back to `/edit-publish` when the user clicks Publish.",
        "parameters": [
          {
            "schema": {
              "minLength": 1,
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "canonical",
                    "platform"
                  ],
                  "properties": {
                    "canonical": {
                      "$comment": "json-value",
                      "description": "Arbitrary JSON value with nested arrays and objects."
                    },
                    "platform": {
                      "anyOf": [
                        {
                          "type": "string",
                          "enum": [
                            "meta"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "snapchat"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "taboola"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "google"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "tiktok"
                          ]
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "422": {
            "description": "Unprocessable entity - semantic validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/adsets/{adsetId}/add-ad-canonical": {
      "post": {
        "operationId": "postApiV1AdsetsByAdsetIdAddAdCanonical",
        "summary": "Build an inline empty-ad canonical campaign for the Add Ad editor",
        "tags": [
          "ads"
        ],
        "description": "Resolves an existing ad set (Meta, Snapchat, Taboola, Google, or TikTok — its parent campaign + account) and returns an `ads_only` canonical campaign with the campaign + ad set read-only and exactly one BLANK ad (no `platformId`) so the publish worker creates a brand-new ad under the reused campaign/ad set. No `campaign_draft` row is created — the editor keeps the canonical inline and posts it back to `/edit-publish`.",
        "parameters": [
          {
            "schema": {
              "minLength": 1,
              "type": "string"
            },
            "in": "path",
            "name": "adsetId",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "canonical",
                    "platform"
                  ],
                  "properties": {
                    "canonical": {
                      "$comment": "json-value",
                      "description": "Arbitrary JSON value with nested arrays and objects."
                    },
                    "platform": {
                      "anyOf": [
                        {
                          "type": "string",
                          "enum": [
                            "meta"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "snapchat"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "taboola"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "google"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "tiktok"
                          ]
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "422": {
            "description": "Unprocessable entity - semantic validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/campaigns/{campaignId}/add-adset-canonical": {
      "post": {
        "operationId": "postApiV1CampaignsByCampaignIdAddAdsetCanonical",
        "summary": "Build an inline add-ad-set canonical campaign for the Add Ad Set editor",
        "tags": [
          "ads"
        ],
        "description": "Resolves an existing Meta campaign (its account + business + default page) and returns an `add_adset` canonical campaign with the campaign read-only and exactly one BRAND-NEW ad set (no `platformId`) carrying one BLANK ad, so the publish worker creates a new ad set under the live campaign. No `campaign_draft` row is created — the editor keeps the canonical inline and posts it back to `/campaigns/:campaignId/add-adset-publish`. Meta only.",
        "parameters": [
          {
            "schema": {
              "minLength": 1,
              "type": "string"
            },
            "in": "path",
            "name": "campaignId",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "canonical",
                    "platform"
                  ],
                  "properties": {
                    "canonical": {
                      "$comment": "json-value",
                      "description": "Arbitrary JSON value with nested arrays and objects."
                    },
                    "platform": {
                      "type": "string",
                      "enum": [
                        "meta"
                      ]
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "422": {
            "description": "Unprocessable entity - semantic validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/adsets/{adsetId}/duplicate-canonical": {
      "post": {
        "operationId": "postApiV1AdsetsByAdsetIdDuplicateCanonical",
        "summary": "Build an inline duplicate-ad-set canonical campaign for the editor",
        "tags": [
          "ads"
        ],
        "description": "Reads an existing Meta ad set (and its ads) and returns an `add_adset` canonical campaign that DUPLICATES it: the parent campaign is reused (read-only) and the ad set + ads are BRAND-NEW (no platformId). The editor edits any field, then posts it back to /campaigns/:campaignId/add-adset-publish which CREATES the new ad set under the live campaign. Mirrors Meta duplicate→editor. No draft row. Meta only.",
        "parameters": [
          {
            "schema": {
              "minLength": 1,
              "type": "string"
            },
            "in": "path",
            "name": "adsetId",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "canonical",
                    "platform"
                  ],
                  "properties": {
                    "canonical": {
                      "$comment": "json-value",
                      "description": "Arbitrary JSON value with nested arrays and objects."
                    },
                    "platform": {
                      "type": "string",
                      "enum": [
                        "meta"
                      ]
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "422": {
            "description": "Unprocessable entity - semantic validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "Service unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/ads/{id}/edit-publish": {
      "post": {
        "operationId": "postApiV1AdsByIdEditPublish",
        "summary": "Publish an inline canonical campaign from the Edit Ad editor (no draft)",
        "tags": [
          "ads"
        ],
        "description": "Accepts a canonical `ads_only` campaign in the body and dispatches it to the standard publish worker via SQS. No `campaign_draft` row is created — the resulting `campaign_publish_job` carries `campaign_draft_id = NULL` and `source = \"edit_ad\"`. Returns the publish job id + worker_run_id for status polling via `/api/v1/campaign-drafts/publish-jobs/:jobId`.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "canonical",
                  "platform"
                ],
                "properties": {
                  "canonical": {
                    "$comment": "json-value",
                    "description": "Arbitrary JSON value with nested arrays and objects."
                  },
                  "platform": {
                    "anyOf": [
                      {
                        "type": "string",
                        "enum": [
                          "meta"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "snapchat"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "taboola"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "google"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "tiktok"
                        ]
                      }
                    ]
                  },
                  "idempotency_key": {
                    "maxLength": 255,
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "schema": {
              "minLength": 1,
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "publish_job_id",
                    "worker_run_id"
                  ],
                  "properties": {
                    "publish_job_id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "worker_run_id": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "422": {
            "description": "Unprocessable entity - semantic validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/campaigns/{campaignId}/add-adset-publish": {
      "post": {
        "operationId": "postApiV1CampaignsByCampaignIdAddAdsetPublish",
        "summary": "Add new ad set(s) to a launched campaign",
        "tags": [
          "ads"
        ],
        "description": "Accepts a canonical campaign with publishMode \"add_adset\" and dispatches it to the standard publish worker. The campaign is reused (platformId set); the worker CREATES the new ad set(s) (those without a platformId) and their ads under it. Meta only. No campaign_draft row is created (source = \"add_adset\"). Returns the publish job id + worker_run_id for polling.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "canonical",
                  "platform"
                ],
                "properties": {
                  "canonical": {
                    "$comment": "json-value",
                    "description": "Arbitrary JSON value with nested arrays and objects."
                  },
                  "platform": {
                    "type": "string",
                    "enum": [
                      "meta"
                    ]
                  },
                  "idempotency_key": {
                    "maxLength": 255,
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "schema": {
              "minLength": 1,
              "type": "string"
            },
            "in": "path",
            "name": "campaignId",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "publish_job_id",
                    "worker_run_id"
                  ],
                  "properties": {
                    "publish_job_id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "worker_run_id": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "422": {
            "description": "Unprocessable entity - semantic validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/ai-action-log": {
      "get": {
        "operationId": "getApiV1AiActionLog",
        "summary": "List AI action log entries (PRD-N6)",
        "tags": [
          "ai-chat"
        ],
        "description": "Paginated read-only feed of `ai_action_log` rows scoped by the caller role. Used by /settings/team/ai-activity and ops tooling.",
        "parameters": [
          {
            "schema": {
              "minimum": 1,
              "maximum": 10000,
              "default": 1,
              "type": "integer"
            },
            "in": "query",
            "name": "page",
            "required": false
          },
          {
            "schema": {
              "minimum": 1,
              "maximum": 200,
              "default": 50,
              "type": "integer"
            },
            "in": "query",
            "name": "page_size",
            "required": false
          },
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "query",
            "name": "user_id",
            "required": false
          },
          {
            "schema": {
              "maxLength": 60,
              "type": "string"
            },
            "in": "query",
            "name": "tool_name",
            "required": false
          },
          {
            "schema": {
              "maxLength": 30,
              "type": "string"
            },
            "in": "query",
            "name": "status",
            "required": false
          },
          {
            "schema": {
              "format": "date-time",
              "type": "string"
            },
            "in": "query",
            "name": "from",
            "required": false
          },
          {
            "schema": {
              "format": "date-time",
              "type": "string"
            },
            "in": "query",
            "name": "to",
            "required": false
          }
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "page",
                    "page_size",
                    "total",
                    "items"
                  ],
                  "properties": {
                    "page": {
                      "type": "integer"
                    },
                    "page_size": {
                      "type": "integer"
                    },
                    "total": {
                      "type": "integer"
                    },
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "id",
                          "user_id",
                          "tool_name",
                          "entity_type",
                          "entity_id",
                          "entity_name",
                          "status",
                          "risk_level",
                          "created_at",
                          "confirmed_at",
                          "executed_at"
                        ],
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "user_id": {
                            "type": "string"
                          },
                          "tool_name": {
                            "type": "string"
                          },
                          "entity_type": {
                            "type": "string"
                          },
                          "entity_id": {
                            "type": "string"
                          },
                          "entity_name": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "status": {
                            "type": "string"
                          },
                          "risk_level": {
                            "type": "string"
                          },
                          "created_at": {
                            "format": "date-time",
                            "type": "string"
                          },
                          "confirmed_at": {
                            "anyOf": [
                              {
                                "format": "date-time",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "executed_at": {
                            "anyOf": [
                              {
                                "format": "date-time",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/ai-memory/preferences": {
      "get": {
        "operationId": "getApiV1AiMemoryPreferences",
        "summary": "Get AI memory preferences",
        "tags": [
          "ai-memory"
        ],
        "description": "Returns the authenticated user AI memory and response preferences with neutral model mode values.",
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "instructions",
                    "preferred_language",
                    "preferred_model",
                    "preferred_metrics"
                  ],
                  "properties": {
                    "id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "user_id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "team_id": {
                      "anyOf": [
                        {
                          "format": "uuid",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "instructions": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "preferred_language": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "preferred_model": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "tone": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "verbosity": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "expertise_level": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "format_preference": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "response_format": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "preferred_metrics": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "preferred_currency": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "memory_enabled": {
                      "type": "boolean"
                    },
                    "memory_opted_out_at": {
                      "anyOf": [
                        {
                          "format": "date-time",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "created_at": {
                      "format": "date-time",
                      "type": "string"
                    },
                    "updated_at": {
                      "anyOf": [
                        {
                          "format": "date-time",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          }
        }
      },
      "patch": {
        "operationId": "patchApiV1AiMemoryPreferences",
        "summary": "Update AI memory preferences",
        "tags": [
          "ai-memory"
        ],
        "description": "Updates user AI memory, language, tone, response format, and preferred metric settings.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "properties": {
                  "currency_display": {
                    "maxLength": 10,
                    "type": "string"
                  },
                  "custom_instructions": {
                    "maxLength": 2000,
                    "type": "string"
                  },
                  "instructions": {
                    "maxLength": 2000,
                    "type": "string"
                  },
                  "language": {
                    "maxLength": 10,
                    "type": "string"
                  },
                  "memory_enabled": {
                    "type": "boolean"
                  },
                  "preferred_currency": {
                    "maxLength": 10,
                    "type": "string"
                  },
                  "preferred_language": {
                    "maxLength": 10,
                    "type": "string"
                  },
                  "preferred_metrics": {
                    "maxItems": 20,
                    "type": "array",
                    "items": {
                      "maxLength": 50,
                      "type": "string"
                    }
                  },
                  "preferred_model": {
                    "anyOf": [
                      {
                        "maxLength": 100,
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "response_format": {
                    "maxLength": 50,
                    "type": "string"
                  },
                  "tone": {
                    "maxLength": 50,
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "instructions",
                    "preferred_language",
                    "preferred_model",
                    "preferred_metrics"
                  ],
                  "properties": {
                    "id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "user_id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "team_id": {
                      "anyOf": [
                        {
                          "format": "uuid",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "instructions": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "preferred_language": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "preferred_model": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "tone": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "verbosity": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "expertise_level": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "format_preference": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "response_format": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "preferred_metrics": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "preferred_currency": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "memory_enabled": {
                      "type": "boolean"
                    },
                    "memory_opted_out_at": {
                      "anyOf": [
                        {
                          "format": "date-time",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "created_at": {
                      "format": "date-time",
                      "type": "string"
                    },
                    "updated_at": {
                      "anyOf": [
                        {
                          "format": "date-time",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/ai/preferences": {
      "get": {
        "operationId": "getAiPreferences",
        "summary": "Get AI memory preferences",
        "tags": [
          "ai-memory"
        ],
        "description": "Returns the authenticated user AI memory and response preferences with neutral model mode values.",
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "instructions",
                    "preferred_language",
                    "preferred_model",
                    "preferred_metrics"
                  ],
                  "properties": {
                    "id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "user_id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "team_id": {
                      "anyOf": [
                        {
                          "format": "uuid",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "instructions": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "preferred_language": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "preferred_model": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "tone": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "verbosity": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "expertise_level": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "format_preference": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "response_format": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "preferred_metrics": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "preferred_currency": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "memory_enabled": {
                      "type": "boolean"
                    },
                    "memory_opted_out_at": {
                      "anyOf": [
                        {
                          "format": "date-time",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "created_at": {
                      "format": "date-time",
                      "type": "string"
                    },
                    "updated_at": {
                      "anyOf": [
                        {
                          "format": "date-time",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          }
        }
      },
      "put": {
        "operationId": "updateAiPreferences",
        "summary": "Update AI memory preferences",
        "tags": [
          "ai-memory"
        ],
        "description": "Updates user AI memory, language, tone, response format, and preferred metric settings.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "properties": {
                  "currency_display": {
                    "maxLength": 10,
                    "type": "string"
                  },
                  "custom_instructions": {
                    "maxLength": 2000,
                    "type": "string"
                  },
                  "instructions": {
                    "maxLength": 2000,
                    "type": "string"
                  },
                  "language": {
                    "maxLength": 10,
                    "type": "string"
                  },
                  "memory_enabled": {
                    "type": "boolean"
                  },
                  "preferred_currency": {
                    "maxLength": 10,
                    "type": "string"
                  },
                  "preferred_language": {
                    "maxLength": 10,
                    "type": "string"
                  },
                  "preferred_metrics": {
                    "maxItems": 20,
                    "type": "array",
                    "items": {
                      "maxLength": 50,
                      "type": "string"
                    }
                  },
                  "preferred_model": {
                    "anyOf": [
                      {
                        "maxLength": 100,
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "response_format": {
                    "maxLength": 50,
                    "type": "string"
                  },
                  "tone": {
                    "maxLength": 50,
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "instructions",
                    "preferred_language",
                    "preferred_model",
                    "preferred_metrics"
                  ],
                  "properties": {
                    "id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "user_id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "team_id": {
                      "anyOf": [
                        {
                          "format": "uuid",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "instructions": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "preferred_language": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "preferred_model": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "tone": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "verbosity": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "expertise_level": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "format_preference": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "response_format": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "preferred_metrics": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "preferred_currency": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "memory_enabled": {
                      "type": "boolean"
                    },
                    "memory_opted_out_at": {
                      "anyOf": [
                        {
                          "format": "date-time",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "created_at": {
                      "format": "date-time",
                      "type": "string"
                    },
                    "updated_at": {
                      "anyOf": [
                        {
                          "format": "date-time",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/ai-memory/facts": {
      "get": {
        "operationId": "getApiV1AiMemoryFacts",
        "summary": "List AI memory facts",
        "tags": [
          "ai-memory"
        ],
        "description": "Lists active project memory facts visible to the authenticated user, optionally scoped to a project.",
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "query",
            "name": "project_id",
            "required": false
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "items"
                  ],
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "additionalProperties": false,
                        "type": "object",
                        "required": [
                          "id",
                          "team_id",
                          "project_id",
                          "user_id",
                          "fact_type",
                          "fact_key",
                          "fact_value",
                          "source_type",
                          "source_id",
                          "confidence",
                          "is_active",
                          "opted_out_at",
                          "created_at",
                          "updated_at"
                        ],
                        "properties": {
                          "id": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "team_id": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "project_id": {
                            "anyOf": [
                              {
                                "format": "uuid",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "user_id": {
                            "anyOf": [
                              {
                                "format": "uuid",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "fact_type": {
                            "type": "string"
                          },
                          "fact_key": {
                            "type": "string"
                          },
                          "fact_value": {
                            "$comment": "json-value"
                          },
                          "source_type": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "source_id": {
                            "anyOf": [
                              {
                                "format": "uuid",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "confidence": {
                            "anyOf": [
                              {
                                "type": "number"
                              },
                              {
                                "type": "string"
                              }
                            ]
                          },
                          "is_active": {
                            "type": "boolean"
                          },
                          "opted_out_at": {
                            "anyOf": [
                              {
                                "format": "date-time",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "created_at": {
                            "format": "date-time",
                            "type": "string"
                          },
                          "updated_at": {
                            "format": "date-time",
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "postApiV1AiMemoryFacts",
        "summary": "Save an AI memory fact",
        "tags": [
          "ai-memory"
        ],
        "description": "Creates or updates a project memory fact for the current team scope.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "fact_key",
                  "fact_type",
                  "fact_value"
                ],
                "properties": {
                  "confidence": {
                    "minimum": 0,
                    "maximum": 1,
                    "type": "number"
                  },
                  "fact_key": {
                    "maxLength": 160,
                    "type": "string"
                  },
                  "fact_type": {
                    "maxLength": 50,
                    "type": "string"
                  },
                  "fact_value": {
                    "$comment": "json-value"
                  },
                  "project_id": {
                    "format": "uuid",
                    "type": "string"
                  },
                  "source_id": {
                    "format": "uuid",
                    "type": "string"
                  },
                  "source_type": {
                    "maxLength": 50,
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "anyOf": [
                    {
                      "additionalProperties": false,
                      "type": "object",
                      "required": [
                        "id",
                        "team_id",
                        "project_id",
                        "user_id",
                        "fact_type",
                        "fact_key",
                        "fact_value",
                        "source_type",
                        "source_id",
                        "confidence",
                        "is_active",
                        "opted_out_at",
                        "created_at",
                        "updated_at"
                      ],
                      "properties": {
                        "id": {
                          "format": "uuid",
                          "type": "string"
                        },
                        "team_id": {
                          "format": "uuid",
                          "type": "string"
                        },
                        "project_id": {
                          "anyOf": [
                            {
                              "format": "uuid",
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "user_id": {
                          "anyOf": [
                            {
                              "format": "uuid",
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "fact_type": {
                          "type": "string"
                        },
                        "fact_key": {
                          "type": "string"
                        },
                        "fact_value": {
                          "$comment": "json-value"
                        },
                        "source_type": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "source_id": {
                          "anyOf": [
                            {
                              "format": "uuid",
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "confidence": {
                          "anyOf": [
                            {
                              "type": "number"
                            },
                            {
                              "type": "string"
                            }
                          ]
                        },
                        "is_active": {
                          "type": "boolean"
                        },
                        "opted_out_at": {
                          "anyOf": [
                            {
                              "format": "date-time",
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "created_at": {
                          "format": "date-time",
                          "type": "string"
                        },
                        "updated_at": {
                          "format": "date-time",
                          "type": "string"
                        }
                      }
                    },
                    {
                      "type": "null"
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/ai/projects/{id}/facts": {
      "get": {
        "operationId": "getApiV1AiProjectsByIdFacts",
        "summary": "List project memory facts",
        "tags": [
          "ai-memory"
        ],
        "description": "Lists active AI memory facts associated with a specific chat project.",
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "items"
                  ],
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "additionalProperties": false,
                        "type": "object",
                        "required": [
                          "id",
                          "team_id",
                          "project_id",
                          "user_id",
                          "fact_type",
                          "fact_key",
                          "fact_value",
                          "source_type",
                          "source_id",
                          "confidence",
                          "is_active",
                          "opted_out_at",
                          "created_at",
                          "updated_at"
                        ],
                        "properties": {
                          "id": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "team_id": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "project_id": {
                            "anyOf": [
                              {
                                "format": "uuid",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "user_id": {
                            "anyOf": [
                              {
                                "format": "uuid",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "fact_type": {
                            "type": "string"
                          },
                          "fact_key": {
                            "type": "string"
                          },
                          "fact_value": {
                            "$comment": "json-value"
                          },
                          "source_type": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "source_id": {
                            "anyOf": [
                              {
                                "format": "uuid",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "confidence": {
                            "anyOf": [
                              {
                                "type": "number"
                              },
                              {
                                "type": "string"
                              }
                            ]
                          },
                          "is_active": {
                            "type": "boolean"
                          },
                          "opted_out_at": {
                            "anyOf": [
                              {
                                "format": "date-time",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "created_at": {
                            "format": "date-time",
                            "type": "string"
                          },
                          "updated_at": {
                            "format": "date-time",
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          }
        }
      },
      "delete": {
        "operationId": "deleteApiV1AiProjectsByIdFacts",
        "summary": "Clear project memory facts",
        "tags": [
          "ai-memory"
        ],
        "description": "Soft-deletes all active AI memory facts for a project and returns the affected row count.",
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "affected"
                  ],
                  "properties": {
                    "affected": {
                      "minimum": 0,
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/ai/projects/{id}/facts/{factId}": {
      "delete": {
        "operationId": "deleteApiV1AiProjectsByIdFactsByFactId",
        "summary": "Delete a project memory fact",
        "tags": [
          "ai-memory"
        ],
        "description": "Soft-deletes a single AI memory fact by id within the current team scope.",
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "factId",
            "required": true
          },
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "id",
                    "team_id",
                    "project_id",
                    "user_id",
                    "fact_type",
                    "fact_key",
                    "fact_value",
                    "source_type",
                    "source_id",
                    "confidence",
                    "is_active",
                    "opted_out_at",
                    "created_at",
                    "updated_at"
                  ],
                  "properties": {
                    "id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "team_id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "project_id": {
                      "anyOf": [
                        {
                          "format": "uuid",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "user_id": {
                      "anyOf": [
                        {
                          "format": "uuid",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "fact_type": {
                      "type": "string"
                    },
                    "fact_key": {
                      "type": "string"
                    },
                    "fact_value": {
                      "$comment": "json-value"
                    },
                    "source_type": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "source_id": {
                      "anyOf": [
                        {
                          "format": "uuid",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "confidence": {
                      "anyOf": [
                        {
                          "type": "number"
                        },
                        {
                          "type": "string"
                        }
                      ]
                    },
                    "is_active": {
                      "type": "boolean"
                    },
                    "opted_out_at": {
                      "anyOf": [
                        {
                          "format": "date-time",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "created_at": {
                      "format": "date-time",
                      "type": "string"
                    },
                    "updated_at": {
                      "format": "date-time",
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/ai-memory/team-credit-caps": {
      "get": {
        "operationId": "getApiV1AiMemoryTeamCreditCaps",
        "summary": "List team AI credit caps",
        "tags": [
          "ai-memory"
        ],
        "description": "Returns monthly AI credit caps for members in the accessible team scope.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "items"
                  ],
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "additionalProperties": false,
                        "type": "object",
                        "required": [
                          "id",
                          "team_id",
                          "member_user_id",
                          "monthly_cap",
                          "enforced",
                          "created_at",
                          "updated_at"
                        ],
                        "properties": {
                          "id": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "team_id": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "member_user_id": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "monthly_cap": {
                            "type": "integer"
                          },
                          "monthly_used": {
                            "type": "integer"
                          },
                          "reset_at": {
                            "anyOf": [
                              {
                                "format": "date-time",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "enforced": {
                            "type": "boolean"
                          },
                          "created_at": {
                            "format": "date-time",
                            "type": "string"
                          },
                          "updated_at": {
                            "format": "date-time",
                            "type": "string"
                          },
                          "email": {
                            "type": "string"
                          },
                          "name": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "role": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "actual_monthly_used": {
                            "type": "integer"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          }
        }
      },
      "put": {
        "operationId": "putApiV1AiMemoryTeamCreditCaps",
        "summary": "Upsert a team AI credit cap",
        "tags": [
          "ai-memory"
        ],
        "description": "Creates or updates a monthly AI credit cap for a team member.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "member_user_id",
                  "monthly_cap"
                ],
                "properties": {
                  "enforced": {
                    "type": "boolean"
                  },
                  "member_user_id": {
                    "format": "uuid",
                    "type": "string"
                  },
                  "monthly_cap": {
                    "minimum": 0,
                    "type": "integer"
                  },
                  "team_id": {
                    "format": "uuid",
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "anyOf": [
                    {
                      "additionalProperties": false,
                      "type": "object",
                      "required": [
                        "id",
                        "team_id",
                        "member_user_id",
                        "monthly_cap",
                        "enforced",
                        "created_at",
                        "updated_at"
                      ],
                      "properties": {
                        "id": {
                          "format": "uuid",
                          "type": "string"
                        },
                        "team_id": {
                          "format": "uuid",
                          "type": "string"
                        },
                        "member_user_id": {
                          "format": "uuid",
                          "type": "string"
                        },
                        "monthly_cap": {
                          "type": "integer"
                        },
                        "monthly_used": {
                          "type": "integer"
                        },
                        "reset_at": {
                          "anyOf": [
                            {
                              "format": "date-time",
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "enforced": {
                          "type": "boolean"
                        },
                        "created_at": {
                          "format": "date-time",
                          "type": "string"
                        },
                        "updated_at": {
                          "format": "date-time",
                          "type": "string"
                        },
                        "email": {
                          "type": "string"
                        },
                        "name": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "role": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "actual_monthly_used": {
                          "type": "integer"
                        }
                      }
                    },
                    {
                      "type": "null"
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/ai-memory/team-credit-usage": {
      "get": {
        "operationId": "getApiV1AiMemoryTeamCreditUsage",
        "summary": "List team AI credit usage",
        "tags": [
          "ai-memory"
        ],
        "description": "Returns current-month AI credit usage for members in the accessible team scope.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "items"
                  ],
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "additionalProperties": false,
                        "type": "object",
                        "required": [
                          "team_id",
                          "member_user_id",
                          "role",
                          "email",
                          "name",
                          "monthly_cap",
                          "reserved_monthly_used",
                          "enforced",
                          "actual_monthly_used",
                          "message_count"
                        ],
                        "properties": {
                          "team_id": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "member_user_id": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "role": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "email": {
                            "type": "string"
                          },
                          "name": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "monthly_cap": {
                            "anyOf": [
                              {
                                "type": "integer"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "reserved_monthly_used": {
                            "anyOf": [
                              {
                                "type": "integer"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "enforced": {
                            "anyOf": [
                              {
                                "type": "boolean"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "actual_monthly_used": {
                            "type": "integer"
                          },
                          "message_count": {
                            "type": "integer"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/team/credit-usage": {
      "get": {
        "operationId": "getApiV1TeamCreditUsage",
        "summary": "List team credit usage",
        "tags": [
          "ai-memory"
        ],
        "description": "Legacy alias returning current-month AI credit usage for team members.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "items"
                  ],
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "additionalProperties": false,
                        "type": "object",
                        "required": [
                          "team_id",
                          "member_user_id",
                          "role",
                          "email",
                          "name",
                          "monthly_cap",
                          "reserved_monthly_used",
                          "enforced",
                          "actual_monthly_used",
                          "message_count"
                        ],
                        "properties": {
                          "team_id": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "member_user_id": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "role": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "email": {
                            "type": "string"
                          },
                          "name": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "monthly_cap": {
                            "anyOf": [
                              {
                                "type": "integer"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "reserved_monthly_used": {
                            "anyOf": [
                              {
                                "type": "integer"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "enforced": {
                            "anyOf": [
                              {
                                "type": "boolean"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "actual_monthly_used": {
                            "type": "integer"
                          },
                          "message_count": {
                            "type": "integer"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/team/credit-caps/{userId}": {
      "put": {
        "operationId": "putApiV1TeamCreditCapsByUserId",
        "summary": "Upsert a member AI credit cap",
        "tags": [
          "ai-memory"
        ],
        "description": "Legacy alias for creating or updating a monthly AI credit cap for a team member.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "monthly_cap"
                ],
                "properties": {
                  "enforced": {
                    "type": "boolean"
                  },
                  "monthly_cap": {
                    "minimum": 0,
                    "type": "integer"
                  },
                  "team_id": {
                    "format": "uuid",
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "userId",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "anyOf": [
                    {
                      "additionalProperties": false,
                      "type": "object",
                      "required": [
                        "id",
                        "team_id",
                        "member_user_id",
                        "monthly_cap",
                        "enforced",
                        "created_at",
                        "updated_at"
                      ],
                      "properties": {
                        "id": {
                          "format": "uuid",
                          "type": "string"
                        },
                        "team_id": {
                          "format": "uuid",
                          "type": "string"
                        },
                        "member_user_id": {
                          "format": "uuid",
                          "type": "string"
                        },
                        "monthly_cap": {
                          "type": "integer"
                        },
                        "monthly_used": {
                          "type": "integer"
                        },
                        "reset_at": {
                          "anyOf": [
                            {
                              "format": "date-time",
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "enforced": {
                          "type": "boolean"
                        },
                        "created_at": {
                          "format": "date-time",
                          "type": "string"
                        },
                        "updated_at": {
                          "format": "date-time",
                          "type": "string"
                        },
                        "email": {
                          "type": "string"
                        },
                        "name": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "role": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "actual_monthly_used": {
                          "type": "integer"
                        }
                      }
                    },
                    {
                      "type": "null"
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/ai-suggestions/benchmark": {
      "get": {
        "operationId": "getApiV1AiSuggestionsBenchmark",
        "summary": "Get cross-team benchmarks for the current team",
        "tags": [
          "ai-suggestions"
        ],
        "description": "Returns anonymized peer-cohort KPI distributions (P25/P50/P75, sample flag) for the current team's industry + spend-tier segment, with a roll-up fallback to coarser cohorts. Privacy-gated: a team only sees benchmarks when it has opted in (team.benchmark_opt_in). When not opted in, opted_in is false and cohorts is empty. Cohorts are k-anonymous (>= 20 distinct teams) by construction.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "opted_in",
                    "segment",
                    "cohorts"
                  ],
                  "properties": {
                    "opted_in": {
                      "description": "Whether the current team consented to cross-team benchmarks.",
                      "type": "boolean"
                    },
                    "segment": {
                      "additionalProperties": false,
                      "type": "object",
                      "required": [
                        "industry",
                        "spend_tier"
                      ],
                      "properties": {
                        "industry": {
                          "description": "Resolved industry for the current team.",
                          "type": "string"
                        },
                        "spend_tier": {
                          "description": "Resolved monthly-spend band, or \"*\" when unknown.",
                          "type": "string"
                        }
                      }
                    },
                    "cohorts": {
                      "description": "Anonymized peer cohorts for the team segment. Empty when the team has not opted in.",
                      "type": "array",
                      "items": {
                        "additionalProperties": false,
                        "type": "object",
                        "required": [
                          "metric_key",
                          "platform",
                          "period",
                          "cohort_size",
                          "p25",
                          "p50",
                          "p75",
                          "sample_flag"
                        ],
                        "properties": {
                          "metric_key": {
                            "description": "KPI the distribution describes (e.g. \"roas\", \"cpa\").",
                            "type": "string"
                          },
                          "platform": {
                            "description": "Ad platform, or \"*\" when the cohort is rolled up across platforms.",
                            "type": "string"
                          },
                          "period": {
                            "description": "Reporting window encoded in the aggregate (e.g. \"last_30d\").",
                            "type": "string"
                          },
                          "cohort_size": {
                            "description": "Distinct contributing teams (>= the k-anonymity floor).",
                            "type": "integer"
                          },
                          "p25": {
                            "anyOf": [
                              {
                                "type": "number"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "p50": {
                            "anyOf": [
                              {
                                "type": "number"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "p75": {
                            "anyOf": [
                              {
                                "type": "number"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "sample_flag": {
                            "description": "\"reliable\" or \"high_variance\" depending on cohort size.",
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "integer"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "integer"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "integer"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/ai-suggestions/benchmark/opt-in": {
      "post": {
        "operationId": "postApiV1AiSuggestionsBenchmarkOptIn",
        "summary": "Set cross-team benchmark consent for the current team",
        "tags": [
          "ai-suggestions"
        ],
        "description": "Updates team.benchmark_opt_in for the requested team context. Opting in lets the team both contribute its anonymized data to and read from peer benchmark cohorts; opting out stops contribution and hides benchmarks. Restricted to super_admin/admin/owner/manager.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "opt_in"
                ],
                "properties": {
                  "opt_in": {
                    "description": "Desired consent state for cross-team benchmarks.",
                    "type": "boolean"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "opt_in"
                  ],
                  "properties": {
                    "opt_in": {
                      "description": "Persisted consent state after the update.",
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "integer"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "integer"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "integer"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/ai-suggestions": {
      "get": {
        "operationId": "getApiV1AiSuggestions",
        "summary": "List proactive Wavo suggestions",
        "tags": [
          "ai-suggestions"
        ],
        "description": "Returns the team-visible proactive suggestions plus pending/unread counters and the last generation run. Each item now includes the nullable `template_id` and `automation_rule_id` deep-link hints.",
        "parameters": [
          {
            "schema": {
              "maximum": 50,
              "minimum": 1,
              "type": "integer"
            },
            "in": "query",
            "name": "limit",
            "required": false
          },
          {
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "enum": [
                    "low"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "medium"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "high"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "critical"
                  ]
                }
              ]
            },
            "in": "query",
            "name": "priority",
            "required": false
          },
          {
            "schema": {
              "maxLength": 50,
              "type": "string"
            },
            "in": "query",
            "name": "scope_type",
            "required": false
          },
          {
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "enum": [
                    "pending"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "active"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "seen"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "approved"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "rejected"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "expired"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "applied"
                  ]
                }
              ]
            },
            "in": "query",
            "name": "status",
            "required": false
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "items",
                    "pending_count",
                    "unread_count",
                    "last_run"
                  ],
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "additionalProperties": true,
                        "type": "object",
                        "required": [
                          "id",
                          "template_id",
                          "automation_rule_id"
                        ],
                        "properties": {
                          "id": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "template_id": {
                            "anyOf": [
                              {
                                "format": "uuid",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "automation_rule_id": {
                            "anyOf": [
                              {
                                "format": "uuid",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          }
                        }
                      }
                    },
                    "pending_count": {
                      "type": "integer"
                    },
                    "unread_count": {
                      "type": "integer"
                    },
                    "last_run": {
                      "anyOf": [
                        {
                          "$comment": "json-value",
                          "description": "Arbitrary JSON value with nested arrays and objects."
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "integer"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "integer"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/ai-suggestions/stats": {
      "get": {
        "operationId": "getApiV1AiSuggestionsStats",
        "summary": "Get proactive Wavo suggestion stats",
        "tags": [
          "ai-suggestions"
        ],
        "description": "Returns proactive suggestion counters for the resolved team scope: a real team.id taken from the `x-team-id` header (wins when present) or from `x-active-scope: team:<team_id>`, falling back to the caller’s primary team membership when neither header is sent.",
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "approved_total",
                    "pending",
                    "rejected_total",
                    "unread"
                  ],
                  "properties": {
                    "approved_total": {
                      "type": "integer"
                    },
                    "pending": {
                      "type": "integer"
                    },
                    "rejected_total": {
                      "type": "integer"
                    },
                    "unread": {
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "integer"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "integer"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/ai-suggestions/generate": {
      "post": {
        "operationId": "postApiV1AiSuggestionsGenerate",
        "summary": "Queue a proactive-suggestion generation job",
        "tags": [
          "ai-suggestions"
        ],
        "description": "Queues proactive suggestion generation for the requested team context. The job runs asynchronously and the UI should poll the list endpoint.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "properties": {
                  "from_date": {
                    "format": "date",
                    "type": "string"
                  },
                  "to_date": {
                    "format": "date",
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "202": {
            "description": "Accepted - processing asynchronously",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "status"
                  ],
                  "properties": {
                    "status": {
                      "type": "string",
                      "enum": [
                        "queued"
                      ]
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "integer"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "integer"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "integer"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "Conflict - resource state prevents the operation",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "integer"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/ai-suggestions/{id}/seen": {
      "post": {
        "operationId": "postApiV1AiSuggestionsByIdSeen",
        "summary": "Mark a proactive suggestion as seen",
        "tags": [
          "ai-suggestions"
        ],
        "description": "Marks a visible proactive suggestion as seen within the requested team context.",
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object",
                  "required": [
                    "id",
                    "template_id",
                    "automation_rule_id"
                  ],
                  "properties": {
                    "id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "template_id": {
                      "anyOf": [
                        {
                          "format": "uuid",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "automation_rule_id": {
                      "anyOf": [
                        {
                          "format": "uuid",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "integer"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "integer"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/ai-suggestions/{id}/approve": {
      "post": {
        "operationId": "postApiV1AiSuggestionsByIdApprove",
        "summary": "Approve a proactive suggestion",
        "tags": [
          "ai-suggestions"
        ],
        "description": "Approves a visible proactive suggestion and dispatches its action when it is executable. Refused with 423 while WAVO autonomy is stopped (kill-switch down or paused) and with 403 when the caller is below the approver floor; `code` names which gate refused.",
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "job_id",
                    "suggestion"
                  ],
                  "properties": {
                    "job_id": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "navigation_only": {
                      "type": "boolean"
                    },
                    "suggestion": {
                      "additionalProperties": true,
                      "type": "object",
                      "required": [
                        "id",
                        "template_id",
                        "automation_rule_id"
                      ],
                      "properties": {
                        "id": {
                          "format": "uuid",
                          "type": "string"
                        },
                        "template_id": {
                          "anyOf": [
                            {
                              "format": "uuid",
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "automation_rule_id": {
                          "anyOf": [
                            {
                              "format": "uuid",
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        }
                      }
                    },
                    "template_id": {
                      "anyOf": [
                        {
                          "format": "uuid",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "integer"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "integer"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "423": {
            "description": "Response 423",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "integer"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/ai-suggestions/{id}/reject": {
      "post": {
        "operationId": "postApiV1AiSuggestionsByIdReject",
        "summary": "Reject a proactive suggestion",
        "tags": [
          "ai-suggestions"
        ],
        "description": "Rejects a visible proactive suggestion within the requested team context.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "properties": {
                  "reason": {
                    "maxLength": 1000,
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object",
                  "required": [
                    "id",
                    "template_id",
                    "automation_rule_id"
                  ],
                  "properties": {
                    "id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "template_id": {
                      "anyOf": [
                        {
                          "format": "uuid",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "automation_rule_id": {
                      "anyOf": [
                        {
                          "format": "uuid",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "integer"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "integer"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/analytics/kpi": {
      "get": {
        "operationId": "getAnalyticsKpi",
        "summary": "Get analytics KPI metrics",
        "tags": [
          "analytics"
        ],
        "description": "Returns key performance indicators (spend, revenue, profit, ROAS, CPA, CPM, CTR) aggregated across all team campaigns for the given date range.",
        "parameters": [
          {
            "schema": {
              "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
              "type": "string"
            },
            "in": "query",
            "name": "from_date",
            "required": true
          },
          {
            "schema": {
              "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
              "type": "string"
            },
            "in": "query",
            "name": "to_date",
            "required": true
          },
          {
            "schema": {
              "pattern": "^[A-Za-z0-9_/+-]+$",
              "type": "string"
            },
            "in": "query",
            "name": "timezone",
            "required": false
          },
          {
            "schema": {
              "minLength": 3,
              "maxLength": 3,
              "type": "string"
            },
            "in": "query",
            "name": "currency",
            "required": false
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "platform",
            "required": false
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "ad_account_ids",
            "required": false
          },
          {
            "schema": {
              "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
              "type": "string"
            },
            "in": "query",
            "name": "compare_from_date",
            "required": false
          },
          {
            "schema": {
              "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
              "type": "string"
            },
            "in": "query",
            "name": "compare_to_date",
            "required": false
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "spend",
                    "revenue",
                    "profit",
                    "roas",
                    "cpa",
                    "cpm",
                    "ctr",
                    "impressions",
                    "clicks",
                    "conversions",
                    "currency",
                    "true_roas",
                    "contribution_profit",
                    "data_source",
                    "data_quality"
                  ],
                  "properties": {
                    "spend": {
                      "type": "number"
                    },
                    "revenue": {
                      "type": "number"
                    },
                    "profit": {
                      "type": "number"
                    },
                    "roas": {
                      "type": "number"
                    },
                    "cpa": {
                      "type": "number"
                    },
                    "cpm": {
                      "type": "number"
                    },
                    "ctr": {
                      "type": "number"
                    },
                    "impressions": {
                      "type": "number"
                    },
                    "clicks": {
                      "type": "number"
                    },
                    "conversions": {
                      "type": "number"
                    },
                    "currency": {
                      "type": "string"
                    },
                    "true_roas": {
                      "anyOf": [
                        {
                          "type": "number"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "contribution_profit": {
                      "anyOf": [
                        {
                          "type": "number"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "data_source": {
                      "anyOf": [
                        {
                          "type": "string",
                          "enum": [
                            "shopify"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "woocommerce"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "keitaro_postback"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "manual_cogs"
                          ]
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "data_quality": {
                      "anyOf": [
                        {
                          "type": "string",
                          "enum": [
                            "full"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "partial"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "estimated"
                          ]
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/analytics/ad-metrics": {
      "get": {
        "operationId": "getAnalyticsAdMetrics",
        "summary": "Get raw ADV metric sums (Analytics v2)",
        "tags": [
          "analytics"
        ],
        "description": "Returns raw ADV metric SUMS (spend, impressions, clicks, inline_link_clicks, add_to_cart, purchases, purchase_value, leads, reach, frequency) for the Analytics v2 page: aggregate totals + per-account rows + optional previous-period totals. Ratios (CPM/CTR/ROAS/CPA/CVR…) are derived client-side via weighted aggregation (Σnumerator / Σdenominator).",
        "parameters": [
          {
            "schema": {
              "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
              "type": "string"
            },
            "in": "query",
            "name": "from_date",
            "required": true
          },
          {
            "schema": {
              "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
              "type": "string"
            },
            "in": "query",
            "name": "to_date",
            "required": true
          },
          {
            "schema": {
              "pattern": "^[A-Za-z0-9_/+-]+$",
              "type": "string"
            },
            "in": "query",
            "name": "timezone",
            "required": false
          },
          {
            "schema": {
              "minLength": 3,
              "maxLength": 3,
              "type": "string"
            },
            "in": "query",
            "name": "currency",
            "required": false
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "platform",
            "required": false
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "ad_account_ids",
            "required": false
          },
          {
            "schema": {
              "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
              "type": "string"
            },
            "in": "query",
            "name": "compare_from_date",
            "required": false
          },
          {
            "schema": {
              "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
              "type": "string"
            },
            "in": "query",
            "name": "compare_to_date",
            "required": false
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "currency",
                    "totals",
                    "previous",
                    "accounts"
                  ],
                  "properties": {
                    "currency": {
                      "type": "string"
                    },
                    "totals": {
                      "type": "object",
                      "required": [
                        "spend",
                        "impressions",
                        "clicks",
                        "inline_link_clicks",
                        "add_to_cart",
                        "purchases",
                        "purchase_value",
                        "leads",
                        "reach",
                        "frequency"
                      ],
                      "properties": {
                        "spend": {
                          "type": "number"
                        },
                        "impressions": {
                          "type": "number"
                        },
                        "clicks": {
                          "type": "number"
                        },
                        "inline_link_clicks": {
                          "type": "number"
                        },
                        "add_to_cart": {
                          "type": "number"
                        },
                        "purchases": {
                          "type": "number"
                        },
                        "purchase_value": {
                          "type": "number"
                        },
                        "leads": {
                          "type": "number"
                        },
                        "reach": {
                          "type": "number"
                        },
                        "frequency": {
                          "type": "number"
                        }
                      }
                    },
                    "previous": {
                      "anyOf": [
                        {
                          "type": "object",
                          "required": [
                            "spend",
                            "impressions",
                            "clicks",
                            "inline_link_clicks",
                            "add_to_cart",
                            "purchases",
                            "purchase_value",
                            "leads",
                            "reach",
                            "frequency"
                          ],
                          "properties": {
                            "spend": {
                              "type": "number"
                            },
                            "impressions": {
                              "type": "number"
                            },
                            "clicks": {
                              "type": "number"
                            },
                            "inline_link_clicks": {
                              "type": "number"
                            },
                            "add_to_cart": {
                              "type": "number"
                            },
                            "purchases": {
                              "type": "number"
                            },
                            "purchase_value": {
                              "type": "number"
                            },
                            "leads": {
                              "type": "number"
                            },
                            "reach": {
                              "type": "number"
                            },
                            "frequency": {
                              "type": "number"
                            }
                          }
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "accounts": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "allOf": [
                          {
                            "type": "object",
                            "required": [
                              "spend",
                              "impressions",
                              "clicks",
                              "inline_link_clicks",
                              "add_to_cart",
                              "purchases",
                              "purchase_value",
                              "leads",
                              "reach",
                              "frequency"
                            ],
                            "properties": {
                              "spend": {
                                "type": "number"
                              },
                              "impressions": {
                                "type": "number"
                              },
                              "clicks": {
                                "type": "number"
                              },
                              "inline_link_clicks": {
                                "type": "number"
                              },
                              "add_to_cart": {
                                "type": "number"
                              },
                              "purchases": {
                                "type": "number"
                              },
                              "purchase_value": {
                                "type": "number"
                              },
                              "leads": {
                                "type": "number"
                              },
                              "reach": {
                                "type": "number"
                              },
                              "frequency": {
                                "type": "number"
                              }
                            }
                          },
                          {
                            "type": "object",
                            "required": [
                              "ad_account_id",
                              "account_name",
                              "platform"
                            ],
                            "properties": {
                              "ad_account_id": {
                                "type": "string"
                              },
                              "account_name": {
                                "anyOf": [
                                  {
                                    "type": "string"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "platform": {
                                "type": "string"
                              }
                            }
                          }
                        ]
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/analytics/ad-metrics-trend": {
      "get": {
        "operationId": "getAnalyticsAdMetricsTrend",
        "summary": "Get per-day, per-platform raw ADV metric sums (Analytics v2)",
        "tags": [
          "analytics"
        ],
        "description": "Returns per-day, per-platform raw ADV metric SUMS (spend, impressions, clicks, inline_link_clicks, add_to_cart, purchases, purchase_value, leads, reach) from campaign_daily_insight for time-series charts. Ratios (CPM/CTR/ROAS/CPA/CVR…) and frequency are derived client-side.",
        "parameters": [
          {
            "schema": {
              "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
              "type": "string"
            },
            "in": "query",
            "name": "from_date",
            "required": true
          },
          {
            "schema": {
              "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
              "type": "string"
            },
            "in": "query",
            "name": "to_date",
            "required": true
          },
          {
            "schema": {
              "pattern": "^[A-Za-z0-9_/+-]+$",
              "type": "string"
            },
            "in": "query",
            "name": "timezone",
            "required": false
          },
          {
            "schema": {
              "minLength": 3,
              "maxLength": 3,
              "type": "string"
            },
            "in": "query",
            "name": "currency",
            "required": false
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "platform",
            "required": false
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "ad_account_ids",
            "required": false
          },
          {
            "schema": {
              "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
              "type": "string"
            },
            "in": "query",
            "name": "compare_from_date",
            "required": false
          },
          {
            "schema": {
              "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
              "type": "string"
            },
            "in": "query",
            "name": "compare_to_date",
            "required": false
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "currency",
                    "series"
                  ],
                  "properties": {
                    "currency": {
                      "type": "string"
                    },
                    "series": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "platform",
                          "date",
                          "spend",
                          "impressions",
                          "clicks",
                          "inline_link_clicks",
                          "add_to_cart",
                          "purchases",
                          "purchase_value",
                          "leads",
                          "reach"
                        ],
                        "properties": {
                          "platform": {
                            "type": "string"
                          },
                          "date": {
                            "type": "string"
                          },
                          "spend": {
                            "type": "number"
                          },
                          "impressions": {
                            "type": "number"
                          },
                          "clicks": {
                            "type": "number"
                          },
                          "inline_link_clicks": {
                            "type": "number"
                          },
                          "add_to_cart": {
                            "type": "number"
                          },
                          "purchases": {
                            "type": "number"
                          },
                          "purchase_value": {
                            "type": "number"
                          },
                          "leads": {
                            "type": "number"
                          },
                          "reach": {
                            "type": "number"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/analytics/geo": {
      "get": {
        "operationId": "getAnalyticsGeo",
        "summary": "Get per-country raw ADV metric sums (Analytics v2)",
        "tags": [
          "analytics"
        ],
        "description": "Returns per-country raw ADV metric SUMS (spend, impressions, clicks, inline_link_clicks, add_to_cart, purchases, purchase_value, leads) from campaign_country_daily_insight for the Analytics v2 \"Geo\" view, ordered by spend DESC. `country` is the ISO-2 region code (e.g. \"IT\"). Ratios are derived client-side.",
        "parameters": [
          {
            "schema": {
              "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
              "type": "string"
            },
            "in": "query",
            "name": "from_date",
            "required": true
          },
          {
            "schema": {
              "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
              "type": "string"
            },
            "in": "query",
            "name": "to_date",
            "required": true
          },
          {
            "schema": {
              "pattern": "^[A-Za-z0-9_/+-]+$",
              "type": "string"
            },
            "in": "query",
            "name": "timezone",
            "required": false
          },
          {
            "schema": {
              "minLength": 3,
              "maxLength": 3,
              "type": "string"
            },
            "in": "query",
            "name": "currency",
            "required": false
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "platform",
            "required": false
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "ad_account_ids",
            "required": false
          },
          {
            "schema": {
              "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
              "type": "string"
            },
            "in": "query",
            "name": "compare_from_date",
            "required": false
          },
          {
            "schema": {
              "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
              "type": "string"
            },
            "in": "query",
            "name": "compare_to_date",
            "required": false
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "currency",
                    "countries"
                  ],
                  "properties": {
                    "currency": {
                      "type": "string"
                    },
                    "countries": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "country",
                          "spend",
                          "impressions",
                          "clicks",
                          "inline_link_clicks",
                          "add_to_cart",
                          "purchases",
                          "purchase_value",
                          "leads"
                        ],
                        "properties": {
                          "country": {
                            "type": "string"
                          },
                          "spend": {
                            "type": "number"
                          },
                          "impressions": {
                            "type": "number"
                          },
                          "clicks": {
                            "type": "number"
                          },
                          "inline_link_clicks": {
                            "type": "number"
                          },
                          "add_to_cart": {
                            "type": "number"
                          },
                          "purchases": {
                            "type": "number"
                          },
                          "purchase_value": {
                            "type": "number"
                          },
                          "leads": {
                            "type": "number"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/analytics/spend-trend": {
      "get": {
        "operationId": "getAnalyticsSpendTrend",
        "summary": "Get daily spend/revenue/profit trend",
        "tags": [
          "analytics"
        ],
        "description": "Returns a day-by-day breakdown of spend, revenue, and profit for charting trends over the selected date range.",
        "parameters": [
          {
            "schema": {
              "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
              "type": "string"
            },
            "in": "query",
            "name": "from_date",
            "required": true
          },
          {
            "schema": {
              "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
              "type": "string"
            },
            "in": "query",
            "name": "to_date",
            "required": true
          },
          {
            "schema": {
              "pattern": "^[A-Za-z0-9_/+-]+$",
              "type": "string"
            },
            "in": "query",
            "name": "timezone",
            "required": false
          },
          {
            "schema": {
              "minLength": 3,
              "maxLength": 3,
              "type": "string"
            },
            "in": "query",
            "name": "currency",
            "required": false
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "platform",
            "required": false
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "ad_account_ids",
            "required": false
          },
          {
            "schema": {
              "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
              "type": "string"
            },
            "in": "query",
            "name": "compare_from_date",
            "required": false
          },
          {
            "schema": {
              "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
              "type": "string"
            },
            "in": "query",
            "name": "compare_to_date",
            "required": false
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "days"
                  ],
                  "properties": {
                    "days": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "date",
                          "spend",
                          "revenue",
                          "profit"
                        ],
                        "properties": {
                          "date": {
                            "type": "string"
                          },
                          "spend": {
                            "type": "number"
                          },
                          "revenue": {
                            "type": "number"
                          },
                          "profit": {
                            "type": "number"
                          }
                        }
                      }
                    },
                    "accounts": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "ad_account_id",
                          "account_name",
                          "days"
                        ],
                        "properties": {
                          "ad_account_id": {
                            "type": "string"
                          },
                          "account_name": {
                            "type": "string"
                          },
                          "days": {
                            "type": "array",
                            "items": {
                              "type": "object",
                              "required": [
                                "date",
                                "spend",
                                "revenue",
                                "profit"
                              ],
                              "properties": {
                                "date": {
                                  "type": "string"
                                },
                                "spend": {
                                  "type": "number"
                                },
                                "revenue": {
                                  "type": "number"
                                },
                                "profit": {
                                  "type": "number"
                                }
                              }
                            }
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/analytics/top-flop": {
      "get": {
        "operationId": "getAnalyticsTopFlop",
        "summary": "Get top and flop campaigns by metric",
        "tags": [
          "analytics"
        ],
        "description": "Returns the best and worst performing campaigns ranked by a chosen metric (ROAS, CPA, CTR, or spend).",
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "from_date",
            "required": true
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "to_date",
            "required": true
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "timezone",
            "required": false
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "currency",
            "required": false
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "platform",
            "required": false
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "ad_account_ids",
            "required": false
          },
          {
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "enum": [
                    "roas"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "cpa"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "ctr"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "spend"
                  ]
                }
              ]
            },
            "in": "query",
            "name": "metric",
            "required": false
          },
          {
            "schema": {
              "minimum": 1,
              "maximum": 20,
              "type": "integer"
            },
            "in": "query",
            "name": "limit",
            "required": false
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "top",
                    "flop"
                  ],
                  "properties": {
                    "top": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "campaign_id",
                          "campaign_name",
                          "metric_value",
                          "spend"
                        ],
                        "properties": {
                          "campaign_id": {
                            "type": "string"
                          },
                          "campaign_name": {
                            "type": "string"
                          },
                          "metric_value": {
                            "type": "number"
                          },
                          "spend": {
                            "type": "number"
                          }
                        }
                      }
                    },
                    "flop": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "campaign_id",
                          "campaign_name",
                          "metric_value",
                          "spend"
                        ],
                        "properties": {
                          "campaign_id": {
                            "type": "string"
                          },
                          "campaign_name": {
                            "type": "string"
                          },
                          "metric_value": {
                            "type": "number"
                          },
                          "spend": {
                            "type": "number"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/analytics/creative-performance": {
      "get": {
        "operationId": "getAnalyticsCreativePerformance",
        "summary": "Get creative (ad) performance ranking",
        "tags": [
          "analytics"
        ],
        "description": "Returns a ranked list of ad creatives by the selected metric (CTR, CPA, or spend), including thumbnail URLs.",
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "from_date",
            "required": true
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "to_date",
            "required": true
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "timezone",
            "required": false
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "currency",
            "required": false
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "platform",
            "required": false
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "ad_account_ids",
            "required": false
          },
          {
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "enum": [
                    "ctr"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "cpa"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "spend"
                  ]
                }
              ]
            },
            "in": "query",
            "name": "metric",
            "required": false
          },
          {
            "schema": {
              "minimum": 1,
              "maximum": 50,
              "type": "integer"
            },
            "in": "query",
            "name": "limit",
            "required": false
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "items"
                  ],
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "ad_id",
                          "ad_name",
                          "thumbnail_url",
                          "ctr",
                          "cpa",
                          "spend",
                          "impressions",
                          "clicks"
                        ],
                        "properties": {
                          "ad_id": {
                            "type": "string"
                          },
                          "ad_name": {
                            "type": "string"
                          },
                          "thumbnail_url": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "ctr": {
                            "type": "number"
                          },
                          "cpa": {
                            "type": "number"
                          },
                          "spend": {
                            "type": "number"
                          },
                          "impressions": {
                            "type": "number"
                          },
                          "clicks": {
                            "type": "number"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/analytics/spend-breakdown": {
      "get": {
        "operationId": "getAnalyticsSpendBreakdown",
        "summary": "Get spend breakdown by campaign",
        "tags": [
          "analytics"
        ],
        "description": "Returns spend distribution across campaigns with percentage share, useful for pie/donut chart visualizations.",
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "from_date",
            "required": true
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "to_date",
            "required": true
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "timezone",
            "required": false
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "currency",
            "required": false
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "platform",
            "required": false
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "ad_account_ids",
            "required": false
          },
          {
            "schema": {
              "minimum": 1,
              "maximum": 30,
              "type": "integer"
            },
            "in": "query",
            "name": "limit",
            "required": false
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "items"
                  ],
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "name",
                          "value",
                          "percentage"
                        ],
                        "properties": {
                          "name": {
                            "type": "string"
                          },
                          "value": {
                            "type": "number"
                          },
                          "percentage": {
                            "type": "number"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/analytics/account-stats": {
      "get": {
        "operationId": "getAnalyticsAccountStats",
        "summary": "Get account health metrics (managed, active, disabled, ban rate, rejected ads)",
        "tags": [
          "analytics"
        ],
        "description": "Returns aggregate account health stats including managed/active/disabled counts, ban rate, and rejected ad totals.",
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "platform",
            "required": false
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "managed_accounts",
                    "active_accounts",
                    "disabled_accounts",
                    "ban_rate",
                    "rejected_ads",
                    "total_ads"
                  ],
                  "properties": {
                    "managed_accounts": {
                      "type": "number"
                    },
                    "active_accounts": {
                      "type": "number"
                    },
                    "disabled_accounts": {
                      "type": "number"
                    },
                    "ban_rate": {
                      "type": "number"
                    },
                    "rejected_ads": {
                      "type": "number"
                    },
                    "total_ads": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/analytics/channel-mix": {
      "get": {
        "operationId": "getCrossChannelMixTrend",
        "summary": "Get cross-channel channel mix trend",
        "tags": [
          "analytics-cross-channel"
        ],
        "description": "Returns daily spend and spend-share percentages by platform for the requested cross-channel analytics window.",
        "parameters": [
          {
            "schema": {
              "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
              "type": "string"
            },
            "in": "query",
            "name": "since",
            "required": true
          },
          {
            "schema": {
              "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
              "type": "string"
            },
            "in": "query",
            "name": "until",
            "required": true
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "platforms",
            "required": false
          },
          {
            "schema": {
              "pattern": "^[A-Z]{3}$",
              "type": "string"
            },
            "in": "query",
            "name": "target_currency",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "items"
                  ],
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "additionalProperties": false,
                        "type": "object",
                        "required": [
                          "date",
                          "platform",
                          "share_pct",
                          "spend"
                        ],
                        "properties": {
                          "date": {
                            "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
                            "type": "string"
                          },
                          "platform": {
                            "anyOf": [
                              {
                                "type": "string",
                                "enum": [
                                  "meta"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "google"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "tiktok"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "taboola"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "snapchat"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "outbrain"
                                ]
                              }
                            ]
                          },
                          "share_pct": {
                            "type": "number"
                          },
                          "spend": {
                            "type": "number"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/analytics/comparison": {
      "get": {
        "operationId": "getCrossChannelComparison",
        "summary": "Get cross-channel platform comparison",
        "tags": [
          "analytics-cross-channel"
        ],
        "description": "Compares current and previous cross-channel analytics windows for each requested platform, including metric deltas.",
        "parameters": [
          {
            "schema": {
              "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
              "type": "string"
            },
            "in": "query",
            "name": "current_since",
            "required": true
          },
          {
            "schema": {
              "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
              "type": "string"
            },
            "in": "query",
            "name": "current_until",
            "required": true
          },
          {
            "schema": {
              "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
              "type": "string"
            },
            "in": "query",
            "name": "previous_since",
            "required": true
          },
          {
            "schema": {
              "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
              "type": "string"
            },
            "in": "query",
            "name": "previous_until",
            "required": true
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "platforms",
            "required": false
          },
          {
            "schema": {
              "pattern": "^[A-Z]{3}$",
              "type": "string"
            },
            "in": "query",
            "name": "target_currency",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "items"
                  ],
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "additionalProperties": false,
                        "type": "object",
                        "required": [
                          "current",
                          "delta_pct",
                          "platform",
                          "previous"
                        ],
                        "properties": {
                          "current": {
                            "additionalProperties": false,
                            "type": "object",
                            "required": [
                              "clicks",
                              "conversions",
                              "cpa",
                              "cpc",
                              "cpm",
                              "ctr",
                              "impressions",
                              "leads",
                              "purchaseValue",
                              "purchases",
                              "revenue",
                              "roas",
                              "spend"
                            ],
                            "properties": {
                              "clicks": {
                                "type": "number"
                              },
                              "conversions": {
                                "type": "number"
                              },
                              "cpa": {
                                "type": "number"
                              },
                              "cpc": {
                                "type": "number"
                              },
                              "cpm": {
                                "type": "number"
                              },
                              "ctr": {
                                "type": "number"
                              },
                              "impressions": {
                                "type": "number"
                              },
                              "leads": {
                                "type": "number"
                              },
                              "purchaseValue": {
                                "type": "number"
                              },
                              "purchases": {
                                "type": "number"
                              },
                              "revenue": {
                                "type": "number"
                              },
                              "roas": {
                                "type": "number"
                              },
                              "spend": {
                                "type": "number"
                              }
                            }
                          },
                          "delta_pct": {
                            "additionalProperties": false,
                            "type": "object",
                            "properties": {
                              "clicks": {
                                "type": "number"
                              },
                              "conversions": {
                                "type": "number"
                              },
                              "cpa": {
                                "type": "number"
                              },
                              "cpc": {
                                "type": "number"
                              },
                              "cpm": {
                                "type": "number"
                              },
                              "ctr": {
                                "type": "number"
                              },
                              "impressions": {
                                "type": "number"
                              },
                              "leads": {
                                "type": "number"
                              },
                              "purchaseValue": {
                                "type": "number"
                              },
                              "purchases": {
                                "type": "number"
                              },
                              "revenue": {
                                "type": "number"
                              },
                              "roas": {
                                "type": "number"
                              },
                              "spend": {
                                "type": "number"
                              }
                            }
                          },
                          "platform": {
                            "anyOf": [
                              {
                                "type": "string",
                                "enum": [
                                  "meta"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "google"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "tiktok"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "taboola"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "snapchat"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "outbrain"
                                ]
                              }
                            ]
                          },
                          "previous": {
                            "additionalProperties": false,
                            "type": "object",
                            "required": [
                              "clicks",
                              "conversions",
                              "cpa",
                              "cpc",
                              "cpm",
                              "ctr",
                              "impressions",
                              "leads",
                              "purchaseValue",
                              "purchases",
                              "revenue",
                              "roas",
                              "spend"
                            ],
                            "properties": {
                              "clicks": {
                                "type": "number"
                              },
                              "conversions": {
                                "type": "number"
                              },
                              "cpa": {
                                "type": "number"
                              },
                              "cpc": {
                                "type": "number"
                              },
                              "cpm": {
                                "type": "number"
                              },
                              "ctr": {
                                "type": "number"
                              },
                              "impressions": {
                                "type": "number"
                              },
                              "leads": {
                                "type": "number"
                              },
                              "purchaseValue": {
                                "type": "number"
                              },
                              "purchases": {
                                "type": "number"
                              },
                              "revenue": {
                                "type": "number"
                              },
                              "roas": {
                                "type": "number"
                              },
                              "spend": {
                                "type": "number"
                              }
                            }
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/analytics/rules/templates": {
      "get": {
        "operationId": "listCrossPlatformRuleTemplates",
        "summary": "List cross-platform rule templates",
        "tags": [
          "analytics-cross-channel"
        ],
        "description": "Returns the cross-platform automation templates whose required platforms are connected for the caller team.",
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "items"
                  ],
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "additionalProperties": false,
                        "type": "object",
                        "required": [
                          "id",
                          "name_en",
                          "name_it",
                          "description_en",
                          "description_it",
                          "condition",
                          "actions",
                          "requires_platforms"
                        ],
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "name_en": {
                            "type": "string"
                          },
                          "name_it": {
                            "type": "string"
                          },
                          "description_en": {
                            "type": "string"
                          },
                          "description_it": {
                            "type": "string"
                          },
                          "condition": {
                            "additionalProperties": false,
                            "type": "object",
                            "required": [
                              "type",
                              "left",
                              "operator",
                              "right"
                            ],
                            "properties": {
                              "type": {
                                "type": "string",
                                "enum": [
                                  "cross_platform_comparison"
                                ]
                              },
                              "left": {
                                "additionalProperties": false,
                                "type": "object",
                                "required": [
                                  "type",
                                  "platform",
                                  "metric",
                                  "level",
                                  "timeframe_days"
                                ],
                                "properties": {
                                  "type": {
                                    "type": "string",
                                    "enum": [
                                      "platform_metric"
                                    ]
                                  },
                                  "platform": {
                                    "anyOf": [
                                      {
                                        "type": "string",
                                        "enum": [
                                          "META"
                                        ]
                                      },
                                      {
                                        "type": "string",
                                        "enum": [
                                          "GOOGLE"
                                        ]
                                      },
                                      {
                                        "type": "string",
                                        "enum": [
                                          "TIKTOK"
                                        ]
                                      },
                                      {
                                        "type": "string",
                                        "enum": [
                                          "LINKEDIN"
                                        ]
                                      }
                                    ]
                                  },
                                  "metric": {
                                    "anyOf": [
                                      {
                                        "type": "string",
                                        "enum": [
                                          "spend"
                                        ]
                                      },
                                      {
                                        "type": "string",
                                        "enum": [
                                          "roas"
                                        ]
                                      },
                                      {
                                        "type": "string",
                                        "enum": [
                                          "cpa"
                                        ]
                                      },
                                      {
                                        "type": "string",
                                        "enum": [
                                          "cpc"
                                        ]
                                      },
                                      {
                                        "type": "string",
                                        "enum": [
                                          "ctr"
                                        ]
                                      },
                                      {
                                        "type": "string",
                                        "enum": [
                                          "cpm"
                                        ]
                                      },
                                      {
                                        "type": "string",
                                        "enum": [
                                          "spend_pct"
                                        ]
                                      }
                                    ]
                                  },
                                  "level": {
                                    "type": "string",
                                    "enum": [
                                      "account"
                                    ]
                                  },
                                  "timeframe_days": {
                                    "anyOf": [
                                      {
                                        "type": "number",
                                        "enum": [
                                          1
                                        ]
                                      },
                                      {
                                        "type": "number",
                                        "enum": [
                                          3
                                        ]
                                      },
                                      {
                                        "type": "number",
                                        "enum": [
                                          7
                                        ]
                                      },
                                      {
                                        "type": "number",
                                        "enum": [
                                          14
                                        ]
                                      },
                                      {
                                        "type": "number",
                                        "enum": [
                                          30
                                        ]
                                      }
                                    ]
                                  },
                                  "multiplier": {
                                    "type": "number"
                                  }
                                }
                              },
                              "operator": {
                                "anyOf": [
                                  {
                                    "type": "string",
                                    "enum": [
                                      "greater_than"
                                    ]
                                  },
                                  {
                                    "type": "string",
                                    "enum": [
                                      "less_than"
                                    ]
                                  },
                                  {
                                    "type": "string",
                                    "enum": [
                                      "greater_or_equal"
                                    ]
                                  },
                                  {
                                    "type": "string",
                                    "enum": [
                                      "less_or_equal"
                                    ]
                                  },
                                  {
                                    "type": "string",
                                    "enum": [
                                      "equal"
                                    ]
                                  }
                                ]
                              },
                              "right": {
                                "anyOf": [
                                  {
                                    "additionalProperties": false,
                                    "type": "object",
                                    "required": [
                                      "type",
                                      "value"
                                    ],
                                    "properties": {
                                      "type": {
                                        "type": "string",
                                        "enum": [
                                          "literal"
                                        ]
                                      },
                                      "value": {
                                        "type": "number"
                                      }
                                    }
                                  },
                                  {
                                    "additionalProperties": false,
                                    "type": "object",
                                    "required": [
                                      "type",
                                      "platform",
                                      "metric",
                                      "level",
                                      "timeframe_days"
                                    ],
                                    "properties": {
                                      "type": {
                                        "type": "string",
                                        "enum": [
                                          "platform_metric"
                                        ]
                                      },
                                      "platform": {
                                        "anyOf": [
                                          {
                                            "type": "string",
                                            "enum": [
                                              "META"
                                            ]
                                          },
                                          {
                                            "type": "string",
                                            "enum": [
                                              "GOOGLE"
                                            ]
                                          },
                                          {
                                            "type": "string",
                                            "enum": [
                                              "TIKTOK"
                                            ]
                                          },
                                          {
                                            "type": "string",
                                            "enum": [
                                              "LINKEDIN"
                                            ]
                                          }
                                        ]
                                      },
                                      "metric": {
                                        "anyOf": [
                                          {
                                            "type": "string",
                                            "enum": [
                                              "spend"
                                            ]
                                          },
                                          {
                                            "type": "string",
                                            "enum": [
                                              "roas"
                                            ]
                                          },
                                          {
                                            "type": "string",
                                            "enum": [
                                              "cpa"
                                            ]
                                          },
                                          {
                                            "type": "string",
                                            "enum": [
                                              "cpc"
                                            ]
                                          },
                                          {
                                            "type": "string",
                                            "enum": [
                                              "ctr"
                                            ]
                                          },
                                          {
                                            "type": "string",
                                            "enum": [
                                              "cpm"
                                            ]
                                          },
                                          {
                                            "type": "string",
                                            "enum": [
                                              "spend_pct"
                                            ]
                                          }
                                        ]
                                      },
                                      "level": {
                                        "type": "string",
                                        "enum": [
                                          "account"
                                        ]
                                      },
                                      "timeframe_days": {
                                        "anyOf": [
                                          {
                                            "type": "number",
                                            "enum": [
                                              1
                                            ]
                                          },
                                          {
                                            "type": "number",
                                            "enum": [
                                              3
                                            ]
                                          },
                                          {
                                            "type": "number",
                                            "enum": [
                                              7
                                            ]
                                          },
                                          {
                                            "type": "number",
                                            "enum": [
                                              14
                                            ]
                                          },
                                          {
                                            "type": "number",
                                            "enum": [
                                              30
                                            ]
                                          }
                                        ]
                                      },
                                      "multiplier": {
                                        "type": "number"
                                      }
                                    }
                                  }
                                ]
                              }
                            }
                          },
                          "actions": {
                            "type": "array",
                            "items": {
                              "anyOf": [
                                {
                                  "additionalProperties": false,
                                  "type": "object",
                                  "required": [
                                    "type",
                                    "platform",
                                    "entity_level"
                                  ],
                                  "properties": {
                                    "type": {
                                      "type": "string",
                                      "enum": [
                                        "PAUSE_TOP_SPEND_CAMPAIGN"
                                      ]
                                    },
                                    "platform": {
                                      "anyOf": [
                                        {
                                          "type": "string",
                                          "enum": [
                                            "META"
                                          ]
                                        },
                                        {
                                          "type": "string",
                                          "enum": [
                                            "GOOGLE"
                                          ]
                                        },
                                        {
                                          "type": "string",
                                          "enum": [
                                            "TIKTOK"
                                          ]
                                        },
                                        {
                                          "type": "string",
                                          "enum": [
                                            "LINKEDIN"
                                          ]
                                        }
                                      ]
                                    },
                                    "entity_level": {
                                      "type": "string",
                                      "enum": [
                                        "campaign"
                                      ]
                                    }
                                  }
                                },
                                {
                                  "additionalProperties": false,
                                  "type": "object",
                                  "required": [
                                    "type",
                                    "platform",
                                    "entity_level",
                                    "pct"
                                  ],
                                  "properties": {
                                    "type": {
                                      "anyOf": [
                                        {
                                          "type": "string",
                                          "enum": [
                                            "INCREASE_BUDGET_PCT"
                                          ]
                                        },
                                        {
                                          "type": "string",
                                          "enum": [
                                            "DECREASE_BUDGET_PCT"
                                          ]
                                        }
                                      ]
                                    },
                                    "platform": {
                                      "anyOf": [
                                        {
                                          "type": "string",
                                          "enum": [
                                            "META"
                                          ]
                                        },
                                        {
                                          "type": "string",
                                          "enum": [
                                            "GOOGLE"
                                          ]
                                        },
                                        {
                                          "type": "string",
                                          "enum": [
                                            "TIKTOK"
                                          ]
                                        },
                                        {
                                          "type": "string",
                                          "enum": [
                                            "LINKEDIN"
                                          ]
                                        }
                                      ]
                                    },
                                    "entity_level": {
                                      "type": "string",
                                      "enum": [
                                        "campaign"
                                      ]
                                    },
                                    "pct": {
                                      "type": "number"
                                    }
                                  }
                                },
                                {
                                  "additionalProperties": false,
                                  "type": "object",
                                  "required": [
                                    "type",
                                    "channel",
                                    "message_template"
                                  ],
                                  "properties": {
                                    "type": {
                                      "type": "string",
                                      "enum": [
                                        "NOTIFY_CHANNEL"
                                      ]
                                    },
                                    "channel": {
                                      "anyOf": [
                                        {
                                          "type": "string",
                                          "enum": [
                                            "in_app"
                                          ]
                                        },
                                        {
                                          "type": "string",
                                          "enum": [
                                            "email"
                                          ]
                                        },
                                        {
                                          "type": "string",
                                          "enum": [
                                            "telegram"
                                          ]
                                        }
                                      ]
                                    },
                                    "message_template": {
                                      "type": "string"
                                    }
                                  }
                                }
                              ]
                            }
                          },
                          "requires_platforms": {
                            "type": "array",
                            "items": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "enum": [
                                    "META"
                                  ]
                                },
                                {
                                  "type": "string",
                                  "enum": [
                                    "GOOGLE"
                                  ]
                                },
                                {
                                  "type": "string",
                                  "enum": [
                                    "TIKTOK"
                                  ]
                                },
                                {
                                  "type": "string",
                                  "enum": [
                                    "LINKEDIN"
                                  ]
                                }
                              ]
                            }
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/analytics/rules/from-template": {
      "post": {
        "operationId": "createCrossPlatformRuleFromTemplate",
        "summary": "Create automation rule from a cross-platform template",
        "tags": [
          "analytics-cross-channel"
        ],
        "description": "Creates a paused automation rule from a template after verifying that the caller team has all required platforms connected and that optional schedule overrides are valid.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "template_id"
                ],
                "properties": {
                  "template_id": {
                    "minLength": 1,
                    "maxLength": 100,
                    "type": "string"
                  },
                  "name_override": {
                    "minLength": 1,
                    "maxLength": 200,
                    "type": "string"
                  },
                  "schedule_overrides": {
                    "additionalProperties": false,
                    "type": "object",
                    "properties": {
                      "interval_minutes": {
                        "minimum": 15,
                        "maximum": 1440,
                        "type": "integer"
                      },
                      "cooldown_minutes": {
                        "minimum": 60,
                        "maximum": 10080,
                        "type": "integer"
                      },
                      "max_executions_per_day": {
                        "minimum": 1,
                        "maximum": 10,
                        "type": "integer"
                      }
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "201": {
            "description": "Resource created",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "id"
                  ],
                  "properties": {
                    "id": {
                      "format": "uuid",
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "422": {
            "description": "Unprocessable entity - semantic validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/analytics/export": {
      "post": {
        "operationId": "createUnifiedAnalyticsExport",
        "summary": "Create a unified cross-channel export job",
        "tags": [
          "analytics-cross-channel"
        ],
        "description": "Creates a CSV or PDF export job. V1 rejects date ranges longer than 90 days.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "since",
                  "until",
                  "platforms",
                  "format",
                  "target_currency"
                ],
                "properties": {
                  "since": {
                    "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
                    "type": "string"
                  },
                  "until": {
                    "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
                    "type": "string"
                  },
                  "platforms": {
                    "minItems": 1,
                    "maxItems": 8,
                    "type": "array",
                    "items": {
                      "minLength": 2,
                      "maxLength": 20,
                      "type": "string"
                    }
                  },
                  "format": {
                    "anyOf": [
                      {
                        "type": "string",
                        "enum": [
                          "CSV"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "PDF"
                        ]
                      }
                    ]
                  },
                  "target_currency": {
                    "pattern": "^[A-Z]{3}$",
                    "type": "string"
                  },
                  "timezone": {
                    "maxLength": 100,
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "202": {
            "description": "Accepted - processing asynchronously",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "job_id",
                    "status"
                  ],
                  "properties": {
                    "job_id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "status": {
                      "type": "string",
                      "enum": [
                        "PENDING"
                      ]
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/analytics/export/{job_id}": {
      "get": {
        "operationId": "getUnifiedAnalyticsExport",
        "summary": "Get unified cross-channel export job status",
        "tags": [
          "analytics-cross-channel"
        ],
        "description": "Returns the current lifecycle state for a unified analytics export job and the download metadata once completed.",
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "job_id",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "data",
                    "error",
                    "job_id",
                    "status"
                  ],
                  "properties": {
                    "data": {
                      "anyOf": [
                        {
                          "additionalProperties": false,
                          "type": "object",
                          "required": [
                            "format",
                            "platforms",
                            "since",
                            "target_currency",
                            "until"
                          ],
                          "properties": {
                            "format": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "enum": [
                                    "CSV"
                                  ]
                                },
                                {
                                  "type": "string",
                                  "enum": [
                                    "PDF"
                                  ]
                                }
                              ]
                            },
                            "platforms": {
                              "type": "array",
                              "items": {
                                "anyOf": [
                                  {
                                    "type": "string",
                                    "enum": [
                                      "meta"
                                    ]
                                  },
                                  {
                                    "type": "string",
                                    "enum": [
                                      "google"
                                    ]
                                  },
                                  {
                                    "type": "string",
                                    "enum": [
                                      "tiktok"
                                    ]
                                  },
                                  {
                                    "type": "string",
                                    "enum": [
                                      "taboola"
                                    ]
                                  },
                                  {
                                    "type": "string",
                                    "enum": [
                                      "snapchat"
                                    ]
                                  },
                                  {
                                    "type": "string",
                                    "enum": [
                                      "outbrain"
                                    ]
                                  }
                                ]
                              }
                            },
                            "since": {
                              "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
                              "type": "string"
                            },
                            "target_currency": {
                              "pattern": "^[A-Z]{3}$",
                              "type": "string"
                            },
                            "until": {
                              "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
                              "type": "string"
                            }
                          }
                        },
                        {
                          "additionalProperties": false,
                          "type": "object",
                          "required": [
                            "download_url",
                            "format",
                            "rows",
                            "storage_key"
                          ],
                          "properties": {
                            "download_url": {
                              "format": "uri",
                              "type": "string"
                            },
                            "format": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "enum": [
                                    "CSV"
                                  ]
                                },
                                {
                                  "type": "string",
                                  "enum": [
                                    "PDF"
                                  ]
                                }
                              ]
                            },
                            "rows": {
                              "minimum": 0,
                              "type": "integer"
                            },
                            "storage_key": {
                              "type": "string"
                            }
                          }
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "error": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "job_id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "status": {
                      "anyOf": [
                        {
                          "type": "string",
                          "enum": [
                            "PENDING"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "RUNNING"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "COMPLETED"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "FAILED"
                          ]
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/analytics/recommendation": {
      "get": {
        "operationId": "getCrossChannelRecommendation",
        "summary": "Get consultative cross-channel budget recommendation",
        "tags": [
          "analytics-cross-channel"
        ],
        "description": "Returns the 30-day consultative budget mix recommendation and guardrail status for cross-channel analytics.",
        "parameters": [
          {
            "schema": {
              "pattern": "^[A-Z]{3}$",
              "type": "string"
            },
            "in": "query",
            "name": "target_currency",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "averageRoas",
                    "guardrails",
                    "perPlatform",
                    "windowDays"
                  ],
                  "properties": {
                    "averageRoas": {
                      "type": "number"
                    },
                    "guardrails": {
                      "additionalProperties": false,
                      "type": "object",
                      "required": [
                        "passed",
                        "reasons"
                      ],
                      "properties": {
                        "passed": {
                          "type": "boolean"
                        },
                        "reasons": {
                          "type": "array",
                          "items": {
                            "type": "string"
                          }
                        }
                      }
                    },
                    "perPlatform": {
                      "type": "array",
                      "items": {
                        "additionalProperties": false,
                        "type": "object",
                        "required": [
                          "avgDailySpend",
                          "current_budget_pct",
                          "multiplier",
                          "platform",
                          "recommended_budget_pct",
                          "recommendedBudgetDeltaPct",
                          "roas",
                          "spend",
                          "suggestion_pct"
                        ],
                        "properties": {
                          "avgDailySpend": {
                            "type": "number"
                          },
                          "current_budget_pct": {
                            "type": "number"
                          },
                          "multiplier": {
                            "type": "number"
                          },
                          "platform": {
                            "anyOf": [
                              {
                                "type": "string",
                                "enum": [
                                  "meta"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "google"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "tiktok"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "taboola"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "snapchat"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "outbrain"
                                ]
                              }
                            ]
                          },
                          "recommended_budget_pct": {
                            "type": "number"
                          },
                          "recommendedBudgetDeltaPct": {
                            "type": "number"
                          },
                          "roas": {
                            "type": "number"
                          },
                          "spend": {
                            "type": "number"
                          },
                          "suggestion_pct": {
                            "type": "number"
                          }
                        }
                      }
                    },
                    "windowDays": {
                      "type": "number",
                      "enum": [
                        30
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/analytics/top-campaigns-cross-platform": {
      "get": {
        "operationId": "getTopCampaignsCrossPlatform",
        "summary": "Get top campaigns across platforms",
        "tags": [
          "analytics-cross-channel"
        ],
        "description": "Returns ranked campaign performance across the requested platforms and date range using the selected metric.",
        "parameters": [
          {
            "schema": {
              "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
              "type": "string"
            },
            "in": "query",
            "name": "since",
            "required": true
          },
          {
            "schema": {
              "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
              "type": "string"
            },
            "in": "query",
            "name": "until",
            "required": true
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "platforms",
            "required": false
          },
          {
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "enum": [
                    "spend"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "roas"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "cpa"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "conversions"
                  ]
                }
              ]
            },
            "in": "query",
            "name": "metric",
            "required": false
          },
          {
            "schema": {
              "minimum": 1,
              "maximum": 50,
              "default": 10,
              "type": "integer"
            },
            "in": "query",
            "name": "limit",
            "required": false
          },
          {
            "schema": {
              "pattern": "^[A-Z]{3}$",
              "type": "string"
            },
            "in": "query",
            "name": "target_currency",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "items"
                  ],
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "additionalProperties": false,
                        "type": "object",
                        "required": [
                          "campaign_id",
                          "campaign_name",
                          "clicks",
                          "conversions",
                          "cpa",
                          "cpc",
                          "cpm",
                          "ctr",
                          "impressions",
                          "leads",
                          "metric_value",
                          "platform",
                          "purchaseValue",
                          "purchases",
                          "revenue",
                          "roas",
                          "spend"
                        ],
                        "properties": {
                          "campaign_id": {
                            "type": "string"
                          },
                          "campaign_name": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "clicks": {
                            "type": "number"
                          },
                          "conversions": {
                            "type": "number"
                          },
                          "cpa": {
                            "type": "number"
                          },
                          "cpc": {
                            "type": "number"
                          },
                          "cpm": {
                            "type": "number"
                          },
                          "ctr": {
                            "type": "number"
                          },
                          "impressions": {
                            "type": "number"
                          },
                          "leads": {
                            "type": "number"
                          },
                          "metric_value": {
                            "type": "number"
                          },
                          "platform": {
                            "anyOf": [
                              {
                                "type": "string",
                                "enum": [
                                  "meta"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "google"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "tiktok"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "taboola"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "snapchat"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "outbrain"
                                ]
                              }
                            ]
                          },
                          "purchaseValue": {
                            "type": "number"
                          },
                          "purchases": {
                            "type": "number"
                          },
                          "revenue": {
                            "type": "number"
                          },
                          "roas": {
                            "type": "number"
                          },
                          "spend": {
                            "type": "number"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/analytics/unified": {
      "get": {
        "operationId": "getCrossChannelUnifiedAnalytics",
        "summary": "Get cross-channel unified analytics metrics",
        "tags": [
          "analytics-cross-channel"
        ],
        "description": "Returns aggregated cross-channel KPI totals, per-platform KPI breakdowns, spend share and the latest included insight date.",
        "parameters": [
          {
            "schema": {
              "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
              "type": "string"
            },
            "in": "query",
            "name": "since",
            "required": true
          },
          {
            "schema": {
              "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
              "type": "string"
            },
            "in": "query",
            "name": "until",
            "required": true
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "platforms",
            "required": false,
            "description": "Comma-separated platform list."
          },
          {
            "schema": {
              "pattern": "^[A-Z]{3}$",
              "type": "string"
            },
            "in": "query",
            "name": "target_currency",
            "required": true
          },
          {
            "schema": {
              "pattern": "^[A-Za-z0-9_/+-]+$",
              "type": "string"
            },
            "in": "query",
            "name": "timezone",
            "required": false
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "asOfDate",
                    "perPlatform",
                    "totals"
                  ],
                  "properties": {
                    "asOfDate": {
                      "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
                      "type": "string"
                    },
                    "perPlatform": {
                      "type": "array",
                      "items": {
                        "additionalProperties": false,
                        "type": "object",
                        "required": [
                          "platform",
                          "clicks",
                          "conversions",
                          "cpa",
                          "cpc",
                          "cpm",
                          "ctr",
                          "impressions",
                          "leads",
                          "purchaseValue",
                          "purchases",
                          "revenue",
                          "roas",
                          "spend",
                          "share_pct"
                        ],
                        "properties": {
                          "platform": {
                            "anyOf": [
                              {
                                "type": "string",
                                "enum": [
                                  "meta"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "google"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "tiktok"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "taboola"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "snapchat"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "outbrain"
                                ]
                              }
                            ]
                          },
                          "clicks": {
                            "type": "number"
                          },
                          "conversions": {
                            "type": "number"
                          },
                          "cpa": {
                            "type": "number"
                          },
                          "cpc": {
                            "type": "number"
                          },
                          "cpm": {
                            "type": "number"
                          },
                          "ctr": {
                            "type": "number"
                          },
                          "impressions": {
                            "type": "number"
                          },
                          "leads": {
                            "type": "number"
                          },
                          "purchaseValue": {
                            "type": "number"
                          },
                          "purchases": {
                            "type": "number"
                          },
                          "revenue": {
                            "type": "number"
                          },
                          "roas": {
                            "type": "number"
                          },
                          "spend": {
                            "type": "number"
                          },
                          "share_pct": {
                            "type": "number"
                          }
                        }
                      }
                    },
                    "totals": {
                      "additionalProperties": false,
                      "type": "object",
                      "required": [
                        "clicks",
                        "conversions",
                        "cpa",
                        "cpc",
                        "cpm",
                        "ctr",
                        "impressions",
                        "leads",
                        "purchaseValue",
                        "purchases",
                        "revenue",
                        "roas",
                        "spend"
                      ],
                      "properties": {
                        "clicks": {
                          "type": "number"
                        },
                        "conversions": {
                          "type": "number"
                        },
                        "cpa": {
                          "type": "number"
                        },
                        "cpc": {
                          "type": "number"
                        },
                        "cpm": {
                          "type": "number"
                        },
                        "ctr": {
                          "type": "number"
                        },
                        "impressions": {
                          "type": "number"
                        },
                        "leads": {
                          "type": "number"
                        },
                        "purchaseValue": {
                          "type": "number"
                        },
                        "purchases": {
                          "type": "number"
                        },
                        "revenue": {
                          "type": "number"
                        },
                        "roas": {
                          "type": "number"
                        },
                        "spend": {
                          "type": "number"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/api-keys": {
      "get": {
        "operationId": "getApiV1ApiKeys",
        "summary": "List API keys",
        "tags": [
          "api-keys"
        ],
        "description": "Returns all API keys owned by the authenticated user (never returns the key itself).",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "items"
                  ],
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "id",
                          "name",
                          "start",
                          "prefix",
                          "enabled",
                          "permissions",
                          "last_request",
                          "expires_at",
                          "created_at",
                          "updated_at"
                        ],
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "name": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "start": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "prefix": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "enabled": {
                            "type": "boolean"
                          },
                          "permissions": {
                            "type": "object",
                            "additionalProperties": {
                              "uniqueItems": true,
                              "type": "array",
                              "items": {
                                "type": "string"
                              }
                            }
                          },
                          "last_request": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "expires_at": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "created_at": {
                            "type": "string"
                          },
                          "updated_at": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "postApiV1ApiKeys",
        "summary": "Create API key",
        "tags": [
          "api-keys"
        ],
        "description": "Generates a new M2M API key. The plain-text key is returned exactly ONCE.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "name",
                  "permissions"
                ],
                "properties": {
                  "name": {
                    "minLength": 1,
                    "maxLength": 64,
                    "type": "string"
                  },
                  "permissions": {
                    "type": "object",
                    "additionalProperties": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  },
                  "expires_in_days": {
                    "minimum": 1,
                    "maximum": 365,
                    "type": "integer"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "201": {
            "description": "Resource created",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "id",
                    "name",
                    "key",
                    "start",
                    "prefix",
                    "permissions",
                    "expires_at",
                    "created_at"
                  ],
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "name": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "key": {
                      "type": "string"
                    },
                    "start": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "prefix": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "permissions": {
                      "type": "object",
                      "additionalProperties": {
                        "uniqueItems": true,
                        "type": "array",
                        "items": {
                          "type": "string"
                        }
                      }
                    },
                    "expires_at": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "created_at": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "anyOf": [
                    {
                      "type": "object",
                      "required": [
                        "statusCode",
                        "error",
                        "message",
                        "code",
                        "feature"
                      ],
                      "properties": {
                        "statusCode": {
                          "type": "number"
                        },
                        "error": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "code": {
                          "type": "string"
                        },
                        "feature": {
                          "type": "string"
                        }
                      }
                    },
                    {
                      "type": "object",
                      "required": [
                        "statusCode",
                        "error",
                        "message"
                      ],
                      "properties": {
                        "statusCode": {
                          "type": "number"
                        },
                        "error": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "code": {
                          "type": "string"
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/api-keys/{id}": {
      "patch": {
        "operationId": "patchApiV1ApiKeysById",
        "summary": "Update API key",
        "tags": [
          "api-keys"
        ],
        "description": "Update name, permissions, or enabled flag. Setting enabled=false soft-revokes the key.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "properties": {
                  "name": {
                    "minLength": 1,
                    "maxLength": 64,
                    "type": "string"
                  },
                  "permissions": {
                    "type": "object",
                    "additionalProperties": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  },
                  "enabled": {
                    "type": "boolean"
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "id",
                    "name",
                    "start",
                    "prefix",
                    "enabled",
                    "permissions",
                    "last_request",
                    "expires_at",
                    "created_at",
                    "updated_at"
                  ],
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "name": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "start": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "prefix": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "enabled": {
                      "type": "boolean"
                    },
                    "permissions": {
                      "type": "object",
                      "additionalProperties": {
                        "uniqueItems": true,
                        "type": "array",
                        "items": {
                          "type": "string"
                        }
                      }
                    },
                    "last_request": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "expires_at": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "created_at": {
                      "type": "string"
                    },
                    "updated_at": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      },
      "delete": {
        "operationId": "deleteApiV1ApiKeysById",
        "summary": "Delete API key",
        "tags": [
          "api-keys"
        ],
        "description": "Permanently deletes an API key. For reversible revoke, PATCH enabled=false instead.",
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "message"
                  ],
                  "properties": {
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/asset-events/stream": {
      "get": {
        "operationId": "getApiV1AssetEventsStream",
        "summary": "Subscribe to asset events via SSE",
        "tags": [
          "asset-events"
        ],
        "description": "Opens a long-lived Server-Sent Events (SSE) stream that emits asset lifecycle events (uploads, generations, deletions) for the authenticated session. The response never completes under normal operation - clients consume `data: <json>\\n\\n` frames and rely on heartbeat comments (`:\\n\\n`) every 30s to keep the connection alive. This endpoint uses `reply.hijack()` and writes directly to the raw socket; the JSON response schemas declared by other routes do NOT apply here.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Server-Sent Events stream. Each frame is either a heartbeat comment (`:\\n\\n`) or a `data: <json>\\n\\n` line whose payload is the JSON-serialized asset event published via `subscribeAssetEvents`.",
            "content": {
              "text/event-stream": {
                "schema": {
                  "type": "string",
                  "description": "Raw SSE frames. See the endpoint description for the JSON payload carried by each `data:` line."
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/audience-hub/comparison": {
      "post": {
        "operationId": "compareAudiencePerformance",
        "summary": "Compare audience performance",
        "tags": [
          "audience-hub"
        ],
        "description": "Compares stored Audience Hub audiences over a date range and returns per-audience performance metrics.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "platform",
                  "audience_ids",
                  "from_date",
                  "to_date"
                ],
                "properties": {
                  "platform": {
                    "anyOf": [
                      {
                        "type": "string",
                        "enum": [
                          "meta"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "google"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "tiktok"
                        ]
                      }
                    ]
                  },
                  "audience_ids": {
                    "minItems": 2,
                    "maxItems": 10,
                    "type": "array",
                    "items": {
                      "format": "uuid",
                      "type": "string"
                    }
                  },
                  "from_date": {
                    "format": "date",
                    "type": "string"
                  },
                  "to_date": {
                    "format": "date",
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "rows"
                  ],
                  "properties": {
                    "rows": {
                      "type": "array",
                      "items": {
                        "additionalProperties": false,
                        "type": "object",
                        "required": [
                          "audience_id",
                          "audience_name",
                          "spend",
                          "impressions",
                          "clicks",
                          "conversions",
                          "cpa",
                          "ctr"
                        ],
                        "properties": {
                          "audience_id": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "audience_name": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "spend": {
                            "type": "number"
                          },
                          "impressions": {
                            "type": "number"
                          },
                          "clicks": {
                            "type": "number"
                          },
                          "conversions": {
                            "type": "number"
                          },
                          "cpa": {
                            "anyOf": [
                              {
                                "type": "number"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "ctr": {
                            "anyOf": [
                              {
                                "type": "number"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "integer"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/audience-hub/google/user-lists": {
      "get": {
        "operationId": "listGoogleUserLists",
        "summary": "List Google Ads user lists",
        "tags": [
          "audience-hub"
        ],
        "description": "Returns Google Ads audience user lists visible to the authenticated user, optionally filtered by account.",
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "account_id",
            "required": false
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "items"
                  ],
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "additionalProperties": true,
                        "type": "object",
                        "properties": {
                          "id": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "session_id": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "google_account_id": {
                            "type": "string"
                          },
                          "user_list_id": {
                            "type": "string"
                          },
                          "resource_name": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "name": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "description": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "list_type": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "upload_key_type": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "membership_status": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "size_for_display": {
                            "anyOf": [
                              {
                                "type": "number"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "size_for_search": {
                            "anyOf": [
                              {
                                "type": "number"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "origin_user_list_id": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "last_synced_at": {
                            "anyOf": [
                              {
                                "format": "date-time",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "created_at": {
                            "format": "date-time",
                            "type": "string"
                          },
                          "updated_at": {
                            "anyOf": [
                              {
                                "format": "date-time",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "deleted_at": {
                            "anyOf": [
                              {
                                "format": "date-time",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "integer"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/audience-hub/google/user-lists/sync": {
      "post": {
        "operationId": "syncGoogleUserLists",
        "summary": "Sync Google Ads user lists",
        "tags": [
          "audience-hub"
        ],
        "description": "Fetches user lists from Google Ads for the requested account and stores the latest Audience Hub snapshot.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "account_id"
                ],
                "properties": {
                  "account_id": {
                    "type": "string"
                  },
                  "login_customer_id": {
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "synced"
                  ],
                  "properties": {
                    "synced": {
                      "minimum": 0,
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "422": {
            "description": "Unprocessable entity - semantic validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "integer"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "integer"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/audience-hub/google/user-lists/crm": {
      "post": {
        "operationId": "createGoogleCrmUserList",
        "summary": "Create a Google Customer Match user list",
        "tags": [
          "audience-hub"
        ],
        "description": "Creates a CRM-based Google Ads user list and stores the created resource in Audience Hub.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "account_id",
                  "name",
                  "upload_key_type"
                ],
                "properties": {
                  "account_id": {
                    "type": "string"
                  },
                  "name": {
                    "minLength": 1,
                    "maxLength": 255,
                    "type": "string"
                  },
                  "description": {
                    "type": "string"
                  },
                  "upload_key_type": {
                    "anyOf": [
                      {
                        "type": "string",
                        "enum": [
                          "CONTACT_INFO"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "CRM_ID"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "MOBILE_ADVERTISING_ID"
                        ]
                      }
                    ]
                  },
                  "membership_life_span": {
                    "minimum": 1,
                    "maximum": 540,
                    "type": "integer"
                  },
                  "login_customer_id": {
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "resource_name",
                    "user_list_id"
                  ],
                  "properties": {
                    "resource_name": {
                      "type": "string"
                    },
                    "user_list_id": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "422": {
            "description": "Unprocessable entity - semantic validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "integer"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "integer"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/audience-hub/google/user-lists/lookalike": {
      "post": {
        "operationId": "createGoogleLookalikeUserList",
        "summary": "Create a Google lookalike user list",
        "tags": [
          "audience-hub"
        ],
        "description": "Creates a Google Ads lookalike user list from one or more seed user lists.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "account_id",
                  "name",
                  "seed_user_list_ids",
                  "country_codes"
                ],
                "properties": {
                  "account_id": {
                    "type": "string"
                  },
                  "name": {
                    "minLength": 1,
                    "maxLength": 255,
                    "type": "string"
                  },
                  "description": {
                    "type": "string"
                  },
                  "seed_user_list_ids": {
                    "minItems": 1,
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  },
                  "country_codes": {
                    "minItems": 1,
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  },
                  "expansion_level": {
                    "anyOf": [
                      {
                        "type": "string",
                        "enum": [
                          "NARROW"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "BALANCED"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "BROAD"
                        ]
                      }
                    ]
                  },
                  "login_customer_id": {
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "resource_name",
                    "user_list_id"
                  ],
                  "properties": {
                    "resource_name": {
                      "type": "string"
                    },
                    "user_list_id": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "422": {
            "description": "Unprocessable entity - semantic validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "integer"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "integer"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/audience-hub/google/user-lists/{user_list_id}": {
      "delete": {
        "operationId": "deleteGoogleUserList",
        "summary": "Delete a Google Ads user list",
        "tags": [
          "audience-hub"
        ],
        "description": "Removes a Google Ads user list and soft-deletes the matching Audience Hub record when present.",
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "account_id",
            "required": true
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "login_customer_id",
            "required": false
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "path",
            "name": "user_list_id",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "ok"
                  ],
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "422": {
            "description": "Unprocessable entity - semantic validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "integer"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "integer"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/audience-hub/google/user-lists/{user_list_id}/customer-match": {
      "post": {
        "operationId": "uploadGoogleCustomerMatch",
        "summary": "Upload Google Customer Match members",
        "tags": [
          "audience-hub"
        ],
        "description": "Parses a CSV, uploads hashed identifiers to a Google Customer Match user list, and deletes the staged file.",
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "account_id",
            "required": true
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "login_customer_id",
            "required": false
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "path",
            "name": "user_list_id",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "job_resource_name",
                    "uploaded",
                    "parsed_rows",
                    "invalid_lines"
                  ],
                  "properties": {
                    "job_resource_name": {
                      "type": "string"
                    },
                    "uploaded": {
                      "minimum": 0,
                      "type": "integer"
                    },
                    "parsed_rows": {
                      "minimum": 0,
                      "type": "integer"
                    },
                    "invalid_lines": {
                      "minimum": 0,
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "integer"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "422": {
            "description": "Unprocessable entity - semantic validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "integer"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "integer"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        },
        "requestBody": {
          "content": {
            "multipart/form-data": {
              "schema": {
                "type": "object",
                "required": [
                  "file"
                ],
                "properties": {
                  "file": {
                    "type": "string",
                    "format": "binary",
                    "description": "CSV customer match file."
                  }
                },
                "additionalProperties": false
              }
            }
          }
        }
      }
    },
    "/api/v1/audience-hub/insights/demographics": {
      "get": {
        "operationId": "getAudienceHubDemographics",
        "summary": "Audience Hub - demographic / geo / device breakdown (cross-provider, cached 24h)",
        "tags": [
          "audience-hub"
        ],
        "description": "Returns cached or freshly fetched demographic, geo, or device breakdown rows for a connected ad account.",
        "parameters": [
          {
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "enum": [
                    "meta"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "google"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "tiktok"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "taboola"
                  ]
                }
              ]
            },
            "in": "query",
            "name": "platform",
            "required": true
          },
          {
            "schema": {
              "minLength": 1,
              "type": "string"
            },
            "in": "query",
            "name": "external_account_id",
            "required": true
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "campaign_id",
            "required": false
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "adset_id",
            "required": false
          },
          {
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "enum": [
                    "age_gender"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "geo"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "device"
                  ]
                }
              ]
            },
            "in": "query",
            "name": "breakdown",
            "required": true
          },
          {
            "schema": {
              "format": "date",
              "type": "string"
            },
            "in": "query",
            "name": "from_date",
            "required": true
          },
          {
            "schema": {
              "format": "date",
              "type": "string"
            },
            "in": "query",
            "name": "to_date",
            "required": true
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "login_customer_id",
            "required": false
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "data",
                    "cache_hit"
                  ],
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "anyOf": [
                          {
                            "additionalProperties": true,
                            "type": "object",
                            "properties": {
                              "age": {
                                "type": "string"
                              },
                              "gender": {
                                "type": "string"
                              },
                              "country": {
                                "type": "string"
                              },
                              "region": {
                                "type": "string"
                              },
                              "device_platform": {
                                "type": "string"
                              },
                              "impression_device": {
                                "type": "string"
                              },
                              "spend": {
                                "type": "string"
                              },
                              "impressions": {
                                "type": "string"
                              },
                              "clicks": {
                                "type": "string"
                              },
                              "reach": {
                                "type": "string"
                              },
                              "actions": {
                                "type": "array",
                                "items": {
                                  "additionalProperties": false,
                                  "type": "object",
                                  "required": [
                                    "action_type",
                                    "value"
                                  ],
                                  "properties": {
                                    "action_type": {
                                      "type": "string"
                                    },
                                    "value": {
                                      "type": "string"
                                    }
                                  }
                                }
                              },
                              "action_values": {
                                "type": "array",
                                "items": {
                                  "additionalProperties": false,
                                  "type": "object",
                                  "required": [
                                    "action_type",
                                    "value"
                                  ],
                                  "properties": {
                                    "action_type": {
                                      "type": "string"
                                    },
                                    "value": {
                                      "type": "string"
                                    }
                                  }
                                }
                              }
                            }
                          },
                          {
                            "additionalProperties": true,
                            "type": "object",
                            "properties": {
                              "age_range": {
                                "type": "string"
                              },
                              "gender": {
                                "type": "string"
                              },
                              "country": {
                                "type": "string"
                              },
                              "region": {
                                "type": "string"
                              },
                              "device": {
                                "type": "string"
                              },
                              "cost_micros": {
                                "type": "number"
                              },
                              "impressions": {
                                "type": "number"
                              },
                              "clicks": {
                                "type": "number"
                              },
                              "conversions": {
                                "type": "number"
                              },
                              "conversions_value": {
                                "type": "number"
                              }
                            }
                          },
                          {
                            "additionalProperties": true,
                            "type": "object",
                            "properties": {
                              "age": {
                                "type": "string"
                              },
                              "gender": {
                                "type": "string"
                              },
                              "country_code": {
                                "type": "string"
                              },
                              "province_id": {
                                "type": "string"
                              },
                              "placement": {
                                "type": "string"
                              },
                              "spend": {
                                "type": "number"
                              },
                              "impressions": {
                                "type": "number"
                              },
                              "clicks": {
                                "type": "number"
                              },
                              "conversions": {
                                "type": "number"
                              }
                            }
                          },
                          {
                            "additionalProperties": true,
                            "type": "object",
                            "properties": {
                              "country": {
                                "type": "string"
                              },
                              "region": {
                                "type": "string"
                              },
                              "spend": {
                                "type": "number"
                              },
                              "impressions": {
                                "type": "number"
                              },
                              "clicks": {
                                "type": "number"
                              },
                              "conversions": {
                                "type": "number"
                              }
                            }
                          }
                        ]
                      }
                    },
                    "cache_hit": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "integer"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "integer"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/audience-hub/meta/audiences": {
      "get": {
        "operationId": "listMetaAudiences",
        "summary": "List Meta custom audiences",
        "tags": [
          "audience-hub"
        ],
        "description": "Returns Meta custom audiences visible to the authenticated user, optionally filtered by ad account.",
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "account_id",
            "required": false
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "items"
                  ],
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "additionalProperties": true,
                        "type": "object",
                        "properties": {
                          "id": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "session_id": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "meta_account_id": {
                            "type": "string"
                          },
                          "meta_audience_id": {
                            "type": "string"
                          },
                          "name": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "description": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "audience_type": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "subtype": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "approximate_count": {
                            "anyOf": [
                              {
                                "type": "number"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "status": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "delivery_status": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "rule": {
                            "$comment": "json-value"
                          },
                          "origin_audience_id": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "lookalike_spec": {
                            "$comment": "json-value"
                          },
                          "origin": {
                            "type": "string"
                          },
                          "source_catalog_id": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "last_synced_at": {
                            "anyOf": [
                              {
                                "format": "date-time",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "created_at": {
                            "format": "date-time",
                            "type": "string"
                          },
                          "updated_at": {
                            "anyOf": [
                              {
                                "format": "date-time",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "deleted_at": {
                            "anyOf": [
                              {
                                "format": "date-time",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "integer"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/audience-hub/meta/audiences/sync": {
      "post": {
        "operationId": "syncMetaAudiences",
        "summary": "Sync Meta custom audiences",
        "tags": [
          "audience-hub"
        ],
        "description": "Fetches custom audiences from Meta for the requested account and stores the latest Audience Hub snapshot.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "account_id"
                ],
                "properties": {
                  "account_id": {
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "synced"
                  ],
                  "properties": {
                    "synced": {
                      "minimum": 0,
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "integer"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/audience-hub/meta/audiences/custom": {
      "post": {
        "operationId": "createMetaCustomAudience",
        "summary": "Create a Meta custom audience",
        "tags": [
          "audience-hub"
        ],
        "description": "Creates a Meta customer-file custom audience and stores the created audience in Audience Hub.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "account_id",
                  "name"
                ],
                "properties": {
                  "account_id": {
                    "type": "string"
                  },
                  "name": {
                    "minLength": 1,
                    "maxLength": 255,
                    "type": "string"
                  },
                  "description": {
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "id"
                  ],
                  "properties": {
                    "id": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "410": {
            "description": "Gone - resource is permanently removed",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "integer"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "422": {
            "description": "Unprocessable entity - semantic validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "integer"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "integer"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/audience-hub/meta/audiences/website": {
      "post": {
        "operationId": "createMetaWebsiteAudience",
        "summary": "Create a Meta website audience",
        "tags": [
          "audience-hub"
        ],
        "description": "Creates a Meta website custom audience using the supplied pixel rule JSON.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "account_id",
                  "name",
                  "pixel_id",
                  "rule"
                ],
                "properties": {
                  "account_id": {
                    "type": "string"
                  },
                  "name": {
                    "minLength": 1,
                    "maxLength": 255,
                    "type": "string"
                  },
                  "pixel_id": {
                    "type": "string"
                  },
                  "rule": {
                    "type": "object",
                    "additionalProperties": {
                      "$comment": "json-value"
                    }
                  },
                  "retention_days": {
                    "minimum": 1,
                    "maximum": 540,
                    "type": "integer"
                  },
                  "description": {
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "id"
                  ],
                  "properties": {
                    "id": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "410": {
            "description": "Gone - resource is permanently removed",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "integer"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "422": {
            "description": "Unprocessable entity - semantic validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "integer"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "integer"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/audience-hub/meta/audiences/lookalike": {
      "post": {
        "operationId": "createMetaLookalikeAudience",
        "summary": "Create a Meta lookalike audience",
        "tags": [
          "audience-hub"
        ],
        "description": "Creates a Meta lookalike audience from an origin custom audience.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "account_id",
                  "name",
                  "origin_audience_id",
                  "country"
                ],
                "properties": {
                  "account_id": {
                    "type": "string"
                  },
                  "name": {
                    "minLength": 1,
                    "maxLength": 255,
                    "type": "string"
                  },
                  "origin_audience_id": {
                    "type": "string"
                  },
                  "country": {
                    "minLength": 2,
                    "maxLength": 2,
                    "type": "string"
                  },
                  "ratio": {
                    "minimum": 0.01,
                    "maximum": 0.2,
                    "type": "number"
                  },
                  "type": {
                    "anyOf": [
                      {
                        "type": "string",
                        "enum": [
                          "similarity"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "reach"
                        ]
                      }
                    ]
                  },
                  "description": {
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "id"
                  ],
                  "properties": {
                    "id": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "410": {
            "description": "Gone - resource is permanently removed",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "integer"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "422": {
            "description": "Unprocessable entity - semantic validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "integer"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "integer"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/audience-hub/meta/audiences/{audience_id}": {
      "delete": {
        "operationId": "deleteMetaAudience",
        "summary": "Delete a Meta custom audience",
        "tags": [
          "audience-hub"
        ],
        "description": "Deletes a Meta custom audience and soft-deletes the matching Audience Hub record.",
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "account_id",
            "required": true
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "path",
            "name": "audience_id",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "ok"
                  ],
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "410": {
            "description": "Gone - resource is permanently removed",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "integer"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "422": {
            "description": "Unprocessable entity - semantic validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "integer"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "integer"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/audience-hub/meta/audiences/{audience_id}/customer-list": {
      "post": {
        "operationId": "uploadMetaCustomerList",
        "summary": "Upload Meta customer-list members",
        "tags": [
          "audience-hub"
        ],
        "description": "Parses a CSV, hashes customer identifiers, uploads them to the Meta custom audience, and deletes the staged file.",
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "account_id",
            "required": true
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "path",
            "name": "audience_id",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "received",
                    "invalid",
                    "parsed_rows",
                    "invalid_lines"
                  ],
                  "properties": {
                    "received": {
                      "minimum": 0,
                      "type": "integer"
                    },
                    "invalid": {
                      "minimum": 0,
                      "type": "integer"
                    },
                    "parsed_rows": {
                      "minimum": 0,
                      "type": "integer"
                    },
                    "invalid_lines": {
                      "minimum": 0,
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "integer"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "integer"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        },
        "requestBody": {
          "content": {
            "multipart/form-data": {
              "schema": {
                "type": "object",
                "required": [
                  "file"
                ],
                "properties": {
                  "file": {
                    "type": "string",
                    "format": "binary",
                    "description": "CSV customer list file."
                  }
                },
                "additionalProperties": false
              }
            }
          }
        }
      }
    },
    "/api/v1/audience-hub/meta/audiences/overlap": {
      "post": {
        "operationId": "computeMetaAudienceOverlap",
        "summary": "Compute Meta audience overlap",
        "tags": [
          "audience-hub"
        ],
        "description": "Returns Meta audience-overlap rows for two to five audience ids when the native endpoint is available.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "account_id",
                  "audience_ids"
                ],
                "properties": {
                  "account_id": {
                    "type": "string"
                  },
                  "audience_ids": {
                    "minItems": 2,
                    "maxItems": 5,
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "overlap"
                  ],
                  "properties": {
                    "overlap": {
                      "type": "array",
                      "items": {
                        "additionalProperties": false,
                        "type": "object",
                        "required": [
                          "audience_id",
                          "audience_name",
                          "audience_size",
                          "overlap_audiences"
                        ],
                        "properties": {
                          "audience_id": {
                            "type": "string"
                          },
                          "audience_name": {
                            "type": "string"
                          },
                          "audience_size": {
                            "type": "number"
                          },
                          "overlap_audiences": {
                            "type": "array",
                            "items": {
                              "additionalProperties": false,
                              "type": "object",
                              "required": [
                                "audience_id",
                                "audience_size",
                                "ratio"
                              ],
                              "properties": {
                                "audience_id": {
                                  "type": "string"
                                },
                                "audience_size": {
                                  "type": "number"
                                },
                                "ratio": {
                                  "type": "number"
                                }
                              }
                            }
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "410": {
            "description": "Gone - resource is permanently removed",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "integer"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "422": {
            "description": "Unprocessable entity - semantic validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "integer"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "integer"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/audience-hub/scopes": {
      "get": {
        "operationId": "getAudienceHubScopes",
        "summary": "Audience Hub - scope status across all providers for the authenticated session",
        "tags": [
          "audience-hub"
        ],
        "description": "Checks whether the authenticated user has the provider scopes required by Audience Hub features.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "items"
                  ],
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "additionalProperties": false,
                        "type": "object",
                        "required": [
                          "ok",
                          "platform",
                          "missing"
                        ],
                        "properties": {
                          "ok": {
                            "type": "boolean"
                          },
                          "platform": {
                            "anyOf": [
                              {
                                "type": "string",
                                "enum": [
                                  "meta"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "google"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "tiktok"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "taboola"
                                ]
                              }
                            ]
                          },
                          "missing": {
                            "type": "array",
                            "items": {
                              "type": "string"
                            }
                          },
                          "reason": {
                            "anyOf": [
                              {
                                "type": "string",
                                "enum": [
                                  "no_token"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "token_expired"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "missing_scope"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "not_supported"
                                ]
                              }
                            ]
                          },
                          "message": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "integer"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/audience-hub/tiktok/audiences": {
      "get": {
        "operationId": "listTikTokAudiences",
        "summary": "List TikTok audiences",
        "tags": [
          "audience-hub"
        ],
        "description": "Returns TikTok DMP audiences visible to the authenticated user, optionally filtered by advertiser.",
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "advertiser_id",
            "required": false
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "items"
                  ],
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "additionalProperties": true,
                        "type": "object",
                        "properties": {
                          "id": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "session_id": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "advertiser_id": {
                            "type": "string"
                          },
                          "audience_id": {
                            "type": "string"
                          },
                          "name": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "description": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "audience_type": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "audience_sub_type": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "approximate_count": {
                            "anyOf": [
                              {
                                "type": "number"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "status": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "origin_audience_id": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "last_synced_at": {
                            "anyOf": [
                              {
                                "format": "date-time",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "created_at": {
                            "format": "date-time",
                            "type": "string"
                          },
                          "updated_at": {
                            "anyOf": [
                              {
                                "format": "date-time",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "deleted_at": {
                            "anyOf": [
                              {
                                "format": "date-time",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "integer"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/audience-hub/tiktok/audiences/sync": {
      "post": {
        "operationId": "syncTikTokAudiences",
        "summary": "Sync TikTok audiences",
        "tags": [
          "audience-hub"
        ],
        "description": "Fetches TikTok custom audiences for the requested advertiser and stores the latest Audience Hub snapshot.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "advertiser_id"
                ],
                "properties": {
                  "advertiser_id": {
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "synced"
                  ],
                  "properties": {
                    "synced": {
                      "minimum": 0,
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "422": {
            "description": "Unprocessable entity - semantic validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "integer"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "integer"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/audience-hub/tiktok/audiences/customer-file": {
      "post": {
        "operationId": "createTikTokCustomerFileAudience",
        "summary": "Create a TikTok customer-file audience",
        "tags": [
          "audience-hub"
        ],
        "description": "Parses a CSV, uploads hashed identifiers to TikTok, and creates a customer-file audience.",
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "advertiser_id",
            "required": true
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "custom_audience_name",
            "required": true
          },
          {
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "enum": [
                    "EMAIL_SHA256"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "PHONE_SHA256"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "IDFA_SHA256"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "GAID_SHA256"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "EXTERNAL_ID"
                  ]
                }
              ]
            },
            "in": "query",
            "name": "calculate_type",
            "required": false
          }
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "custom_audience_id",
                    "parsed_rows",
                    "invalid_lines"
                  ],
                  "properties": {
                    "custom_audience_id": {
                      "type": "string"
                    },
                    "parsed_rows": {
                      "minimum": 0,
                      "type": "integer"
                    },
                    "invalid_lines": {
                      "minimum": 0,
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "integer"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "422": {
            "description": "Unprocessable entity - semantic validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "integer"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "integer"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/audience-hub/tiktok/audiences/lookalike": {
      "post": {
        "operationId": "createTikTokLookalikeAudience",
        "summary": "Create a TikTok lookalike audience",
        "tags": [
          "audience-hub"
        ],
        "description": "Creates a TikTok lookalike audience from a source custom audience.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "advertiser_id",
                  "custom_audience_name",
                  "source_audience_id",
                  "location_ids"
                ],
                "properties": {
                  "advertiser_id": {
                    "type": "string"
                  },
                  "custom_audience_name": {
                    "minLength": 1,
                    "maxLength": 255,
                    "type": "string"
                  },
                  "source_audience_id": {
                    "type": "string"
                  },
                  "location_ids": {
                    "minItems": 1,
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  },
                  "lookalike_spec_type": {
                    "anyOf": [
                      {
                        "type": "string",
                        "enum": [
                          "NARROW"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "BALANCE"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "BROAD"
                        ]
                      }
                    ]
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "custom_audience_id"
                  ],
                  "properties": {
                    "custom_audience_id": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "422": {
            "description": "Unprocessable entity - semantic validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "integer"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "integer"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/audience-hub/tiktok/audiences/{audience_id}": {
      "delete": {
        "operationId": "deleteTikTokAudience",
        "summary": "Delete a TikTok audience",
        "tags": [
          "audience-hub"
        ],
        "description": "Deletes a TikTok custom audience and soft-deletes the matching Audience Hub record when present.",
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "advertiser_id",
            "required": true
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "path",
            "name": "audience_id",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "ok"
                  ],
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "422": {
            "description": "Unprocessable entity - semantic validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "integer"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "integer"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/audience-saturation/alerts": {
      "get": {
        "operationId": "getApiV1AudienceSaturationAlerts",
        "summary": "List audience saturation alerts",
        "tags": [
          "audience-saturation"
        ],
        "description": "Returns active audience saturation alerts visible to the caller. Set dismissed=true to include recently dismissed alerts.",
        "parameters": [
          {
            "schema": {
              "type": "boolean"
            },
            "in": "query",
            "name": "dismissed",
            "required": false
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "items"
                  ],
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "additionalProperties": false,
                        "type": "object",
                        "required": [
                          "id",
                          "team_id",
                          "session_id",
                          "adset_id",
                          "adset_name",
                          "ad_account_id",
                          "severity",
                          "signals",
                          "suggestion",
                          "root_cause",
                          "confidence_pct",
                          "analysis_md",
                          "baseline_window_days",
                          "is_read",
                          "is_dismissed",
                          "dismissed_at",
                          "detected_at",
                          "resolved_at",
                          "snoozed_until"
                        ],
                        "properties": {
                          "id": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "team_id": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "session_id": {
                            "anyOf": [
                              {
                                "format": "uuid",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "adset_id": {
                            "type": "string"
                          },
                          "adset_name": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "ad_account_id": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "severity": {
                            "type": "string"
                          },
                          "signals": {
                            "$comment": "json-value",
                            "description": "Arbitrary JSON value with nested arrays and objects."
                          },
                          "suggestion": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "root_cause": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "confidence_pct": {
                            "anyOf": [
                              {
                                "type": "integer"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "analysis_md": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "baseline_window_days": {
                            "anyOf": [
                              {
                                "type": "integer"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "is_read": {
                            "type": "boolean"
                          },
                          "is_dismissed": {
                            "type": "boolean"
                          },
                          "dismissed_at": {
                            "anyOf": [
                              {
                                "format": "date-time",
                                "description": "ISO 8601 UTC timestamp.",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "detected_at": {
                            "format": "date-time",
                            "description": "ISO 8601 UTC timestamp.",
                            "type": "string"
                          },
                          "resolved_at": {
                            "anyOf": [
                              {
                                "format": "date-time",
                                "description": "ISO 8601 UTC timestamp.",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "snoozed_until": {
                            "anyOf": [
                              {
                                "format": "date-time",
                                "description": "ISO 8601 UTC timestamp.",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/audience-saturation/alerts/{id}/dismiss": {
      "patch": {
        "operationId": "patchApiV1AudienceSaturationAlertsByIdDismiss",
        "summary": "Dismiss audience saturation alert",
        "tags": [
          "audience-saturation"
        ],
        "description": "Marks an audience saturation alert as dismissed when it belongs to a team accessible to the caller.",
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "id",
                    "team_id",
                    "session_id",
                    "adset_id",
                    "adset_name",
                    "ad_account_id",
                    "severity",
                    "signals",
                    "suggestion",
                    "root_cause",
                    "confidence_pct",
                    "analysis_md",
                    "baseline_window_days",
                    "is_read",
                    "is_dismissed",
                    "dismissed_at",
                    "detected_at",
                    "resolved_at",
                    "snoozed_until"
                  ],
                  "properties": {
                    "id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "team_id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "session_id": {
                      "anyOf": [
                        {
                          "format": "uuid",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "adset_id": {
                      "type": "string"
                    },
                    "adset_name": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "ad_account_id": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "severity": {
                      "type": "string"
                    },
                    "signals": {
                      "$comment": "json-value",
                      "description": "Arbitrary JSON value with nested arrays and objects."
                    },
                    "suggestion": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "root_cause": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "confidence_pct": {
                      "anyOf": [
                        {
                          "type": "integer"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "analysis_md": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "baseline_window_days": {
                      "anyOf": [
                        {
                          "type": "integer"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "is_read": {
                      "type": "boolean"
                    },
                    "is_dismissed": {
                      "type": "boolean"
                    },
                    "dismissed_at": {
                      "anyOf": [
                        {
                          "format": "date-time",
                          "description": "ISO 8601 UTC timestamp.",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "detected_at": {
                      "format": "date-time",
                      "description": "ISO 8601 UTC timestamp.",
                      "type": "string"
                    },
                    "resolved_at": {
                      "anyOf": [
                        {
                          "format": "date-time",
                          "description": "ISO 8601 UTC timestamp.",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "snoozed_until": {
                      "anyOf": [
                        {
                          "format": "date-time",
                          "description": "ISO 8601 UTC timestamp.",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/audience-saturation/alerts/{id}/snooze": {
      "patch": {
        "operationId": "patchApiV1AudienceSaturationAlertsByIdSnooze",
        "summary": "Snooze audience saturation alert",
        "tags": [
          "audience-saturation"
        ],
        "description": "Sets a snooze window on an audience saturation alert when it belongs to a team accessible to the caller.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "days"
                ],
                "properties": {
                  "days": {
                    "anyOf": [
                      {
                        "type": "number",
                        "enum": [
                          1
                        ]
                      },
                      {
                        "type": "number",
                        "enum": [
                          7
                        ]
                      },
                      {
                        "type": "number",
                        "enum": [
                          30
                        ]
                      }
                    ]
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "id",
                    "team_id",
                    "session_id",
                    "adset_id",
                    "adset_name",
                    "ad_account_id",
                    "severity",
                    "signals",
                    "suggestion",
                    "root_cause",
                    "confidence_pct",
                    "analysis_md",
                    "baseline_window_days",
                    "is_read",
                    "is_dismissed",
                    "dismissed_at",
                    "detected_at",
                    "resolved_at",
                    "snoozed_until"
                  ],
                  "properties": {
                    "id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "team_id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "session_id": {
                      "anyOf": [
                        {
                          "format": "uuid",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "adset_id": {
                      "type": "string"
                    },
                    "adset_name": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "ad_account_id": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "severity": {
                      "type": "string"
                    },
                    "signals": {
                      "$comment": "json-value",
                      "description": "Arbitrary JSON value with nested arrays and objects."
                    },
                    "suggestion": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "root_cause": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "confidence_pct": {
                      "anyOf": [
                        {
                          "type": "integer"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "analysis_md": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "baseline_window_days": {
                      "anyOf": [
                        {
                          "type": "integer"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "is_read": {
                      "type": "boolean"
                    },
                    "is_dismissed": {
                      "type": "boolean"
                    },
                    "dismissed_at": {
                      "anyOf": [
                        {
                          "format": "date-time",
                          "description": "ISO 8601 UTC timestamp.",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "detected_at": {
                      "format": "date-time",
                      "description": "ISO 8601 UTC timestamp.",
                      "type": "string"
                    },
                    "resolved_at": {
                      "anyOf": [
                        {
                          "format": "date-time",
                          "description": "ISO 8601 UTC timestamp.",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "snoozed_until": {
                      "anyOf": [
                        {
                          "format": "date-time",
                          "description": "ISO 8601 UTC timestamp.",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/market-intelligence/saturation-alerts": {
      "get": {
        "operationId": "getApiV1MarketIntelligenceSaturationAlerts",
        "summary": "List audience saturation alerts (legacy path)",
        "tags": [
          "audience-saturation"
        ],
        "description": "Legacy alias for listing audience saturation alerts. Prefer GET /api/v1/audience-saturation/alerts for new clients.",
        "parameters": [
          {
            "schema": {
              "type": "boolean"
            },
            "in": "query",
            "name": "dismissed",
            "required": false
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "items"
                  ],
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "additionalProperties": false,
                        "type": "object",
                        "required": [
                          "id",
                          "team_id",
                          "session_id",
                          "adset_id",
                          "adset_name",
                          "ad_account_id",
                          "severity",
                          "signals",
                          "suggestion",
                          "root_cause",
                          "confidence_pct",
                          "analysis_md",
                          "baseline_window_days",
                          "is_read",
                          "is_dismissed",
                          "dismissed_at",
                          "detected_at",
                          "resolved_at",
                          "snoozed_until"
                        ],
                        "properties": {
                          "id": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "team_id": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "session_id": {
                            "anyOf": [
                              {
                                "format": "uuid",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "adset_id": {
                            "type": "string"
                          },
                          "adset_name": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "ad_account_id": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "severity": {
                            "type": "string"
                          },
                          "signals": {
                            "$comment": "json-value",
                            "description": "Arbitrary JSON value with nested arrays and objects."
                          },
                          "suggestion": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "root_cause": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "confidence_pct": {
                            "anyOf": [
                              {
                                "type": "integer"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "analysis_md": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "baseline_window_days": {
                            "anyOf": [
                              {
                                "type": "integer"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "is_read": {
                            "type": "boolean"
                          },
                          "is_dismissed": {
                            "type": "boolean"
                          },
                          "dismissed_at": {
                            "anyOf": [
                              {
                                "format": "date-time",
                                "description": "ISO 8601 UTC timestamp.",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "detected_at": {
                            "format": "date-time",
                            "description": "ISO 8601 UTC timestamp.",
                            "type": "string"
                          },
                          "resolved_at": {
                            "anyOf": [
                              {
                                "format": "date-time",
                                "description": "ISO 8601 UTC timestamp.",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "snoozed_until": {
                            "anyOf": [
                              {
                                "format": "date-time",
                                "description": "ISO 8601 UTC timestamp.",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/market-intelligence/saturation-alerts/{id}/dismiss": {
      "patch": {
        "operationId": "patchApiV1MarketIntelligenceSaturationAlertsByIdDismiss",
        "summary": "Dismiss audience saturation alert (legacy path)",
        "tags": [
          "audience-saturation"
        ],
        "description": "Legacy alias for dismissing an audience saturation alert. Prefer PATCH /api/v1/audience-saturation/alerts/{id}/dismiss for new clients.",
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "id",
                    "team_id",
                    "session_id",
                    "adset_id",
                    "adset_name",
                    "ad_account_id",
                    "severity",
                    "signals",
                    "suggestion",
                    "root_cause",
                    "confidence_pct",
                    "analysis_md",
                    "baseline_window_days",
                    "is_read",
                    "is_dismissed",
                    "dismissed_at",
                    "detected_at",
                    "resolved_at",
                    "snoozed_until"
                  ],
                  "properties": {
                    "id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "team_id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "session_id": {
                      "anyOf": [
                        {
                          "format": "uuid",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "adset_id": {
                      "type": "string"
                    },
                    "adset_name": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "ad_account_id": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "severity": {
                      "type": "string"
                    },
                    "signals": {
                      "$comment": "json-value",
                      "description": "Arbitrary JSON value with nested arrays and objects."
                    },
                    "suggestion": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "root_cause": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "confidence_pct": {
                      "anyOf": [
                        {
                          "type": "integer"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "analysis_md": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "baseline_window_days": {
                      "anyOf": [
                        {
                          "type": "integer"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "is_read": {
                      "type": "boolean"
                    },
                    "is_dismissed": {
                      "type": "boolean"
                    },
                    "dismissed_at": {
                      "anyOf": [
                        {
                          "format": "date-time",
                          "description": "ISO 8601 UTC timestamp.",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "detected_at": {
                      "format": "date-time",
                      "description": "ISO 8601 UTC timestamp.",
                      "type": "string"
                    },
                    "resolved_at": {
                      "anyOf": [
                        {
                          "format": "date-time",
                          "description": "ISO 8601 UTC timestamp.",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "snoozed_until": {
                      "anyOf": [
                        {
                          "format": "date-time",
                          "description": "ISO 8601 UTC timestamp.",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/market-intelligence/saturation-alerts/{id}/snooze": {
      "patch": {
        "operationId": "patchApiV1MarketIntelligenceSaturationAlertsByIdSnooze",
        "summary": "Snooze audience saturation alert (legacy path)",
        "tags": [
          "audience-saturation"
        ],
        "description": "Legacy alias for snoozing an audience saturation alert. Prefer PATCH /api/v1/audience-saturation/alerts/{id}/snooze for new clients.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "days"
                ],
                "properties": {
                  "days": {
                    "anyOf": [
                      {
                        "type": "number",
                        "enum": [
                          1
                        ]
                      },
                      {
                        "type": "number",
                        "enum": [
                          7
                        ]
                      },
                      {
                        "type": "number",
                        "enum": [
                          30
                        ]
                      }
                    ]
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "id",
                    "team_id",
                    "session_id",
                    "adset_id",
                    "adset_name",
                    "ad_account_id",
                    "severity",
                    "signals",
                    "suggestion",
                    "root_cause",
                    "confidence_pct",
                    "analysis_md",
                    "baseline_window_days",
                    "is_read",
                    "is_dismissed",
                    "dismissed_at",
                    "detected_at",
                    "resolved_at",
                    "snoozed_until"
                  ],
                  "properties": {
                    "id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "team_id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "session_id": {
                      "anyOf": [
                        {
                          "format": "uuid",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "adset_id": {
                      "type": "string"
                    },
                    "adset_name": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "ad_account_id": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "severity": {
                      "type": "string"
                    },
                    "signals": {
                      "$comment": "json-value",
                      "description": "Arbitrary JSON value with nested arrays and objects."
                    },
                    "suggestion": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "root_cause": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "confidence_pct": {
                      "anyOf": [
                        {
                          "type": "integer"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "analysis_md": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "baseline_window_days": {
                      "anyOf": [
                        {
                          "type": "integer"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "is_read": {
                      "type": "boolean"
                    },
                    "is_dismissed": {
                      "type": "boolean"
                    },
                    "dismissed_at": {
                      "anyOf": [
                        {
                          "format": "date-time",
                          "description": "ISO 8601 UTC timestamp.",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "detected_at": {
                      "format": "date-time",
                      "description": "ISO 8601 UTC timestamp.",
                      "type": "string"
                    },
                    "resolved_at": {
                      "anyOf": [
                        {
                          "format": "date-time",
                          "description": "ISO 8601 UTC timestamp.",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "snoozed_until": {
                      "anyOf": [
                        {
                          "format": "date-time",
                          "description": "ISO 8601 UTC timestamp.",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/audit-log": {
      "get": {
        "operationId": "getApiV1AuditLog",
        "summary": "Get audit log",
        "tags": [
          "audit"
        ],
        "description": "Returns paginated audit log entries for the team.",
        "parameters": [
          {
            "schema": {
              "minimum": 1,
              "default": 1,
              "type": "integer"
            },
            "in": "query",
            "name": "page",
            "required": false
          },
          {
            "schema": {
              "minimum": 1,
              "maximum": 50,
              "default": 20,
              "type": "integer"
            },
            "in": "query",
            "name": "limit",
            "required": false
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "action",
            "required": false
          },
          {
            "schema": {
              "format": "date",
              "type": "string"
            },
            "in": "query",
            "name": "from_date",
            "required": false
          },
          {
            "schema": {
              "format": "date",
              "type": "string"
            },
            "in": "query",
            "name": "to_date",
            "required": false
          }
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "items",
                    "total",
                    "page",
                    "limit"
                  ],
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "id",
                          "user_id",
                          "user_email",
                          "user_name",
                          "action",
                          "resource_type",
                          "resource_id",
                          "metadata",
                          "ip_address",
                          "user_agent",
                          "created_at"
                        ],
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "user_id": {
                            "type": "string"
                          },
                          "user_email": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "user_name": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "action": {
                            "type": "string"
                          },
                          "resource_type": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "resource_id": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "metadata": {
                            "$comment": "json-value",
                            "description": "Arbitrary JSON value with nested arrays and objects."
                          },
                          "ip_address": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "user_agent": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "created_at": {
                            "type": "string"
                          }
                        }
                      }
                    },
                    "total": {
                      "type": "integer"
                    },
                    "page": {
                      "type": "integer"
                    },
                    "limit": {
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/audit-log/export": {
      "get": {
        "operationId": "getApiV1AuditLogExport",
        "summary": "Export audit log as CSV",
        "tags": [
          "audit"
        ],
        "description": "Exports audit log entries as a CSV file (max 1000 rows).",
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "action",
            "required": false
          },
          {
            "schema": {
              "format": "date",
              "type": "string"
            },
            "in": "query",
            "name": "from_date",
            "required": false
          },
          {
            "schema": {
              "format": "date",
              "type": "string"
            },
            "in": "query",
            "name": "to_date",
            "required": false
          }
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "CSV file content.",
            "content": {
              "text/csv": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/auth/2fa/setup": {
      "post": {
        "operationId": "postApiV1Auth2faSetup",
        "summary": "Start 2FA setup",
        "tags": [
          "auth"
        ],
        "description": "Generates a new inactive TOTP secret and QR code for first-time 2FA setup. Account password is never required inside the app.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "properties": {}
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "secret",
                    "qr_code",
                    "otpauth_url"
                  ],
                  "properties": {
                    "secret": {
                      "type": "string"
                    },
                    "qr_code": {
                      "type": "string"
                    },
                    "otpauth_url": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/auth/2fa/verify": {
      "post": {
        "operationId": "postApiV1Auth2faVerify",
        "summary": "Verify TOTP and activate 2FA",
        "tags": [
          "auth"
        ],
        "description": "Verifies the TOTP code from the authenticator app. On success, activates 2FA and returns backup codes.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "code"
                ],
                "properties": {
                  "code": {
                    "minLength": 6,
                    "maxLength": 6,
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "backup_codes"
                  ],
                  "properties": {
                    "backup_codes": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "Service unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/auth/2fa/disable": {
      "post": {
        "operationId": "postApiV1Auth2faDisable",
        "summary": "Remove TOTP authenticator factor",
        "tags": [
          "auth"
        ],
        "description": "Requires TOTP/backup code to remove the authenticator-app factor. At least one passkey must already exist, so this endpoint can never leave the account without 2FA. Account password is never accepted.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "code"
                ],
                "properties": {
                  "code": {
                    "minLength": 6,
                    "maxLength": 8,
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "message"
                  ],
                  "properties": {
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/auth/2fa/validate": {
      "post": {
        "operationId": "postApiV1Auth2faValidate",
        "summary": "Validate 2FA during login",
        "tags": [
          "auth"
        ],
        "description": "Verifies TOTP code or backup code after login when 2FA is enabled.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "code"
                ],
                "properties": {
                  "code": {
                    "minLength": 6,
                    "maxLength": 8,
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "message"
                  ],
                  "properties": {
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "Service unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/auth/2fa/passkeys/register-options": {
      "get": {
        "operationId": "getApiV1Auth2faPasskeysRegisterOptions",
        "summary": "Generate passkey registration options",
        "tags": [
          "auth"
        ],
        "description": "Generates WebAuthn registration options for adding a passkey as a 2FA method. The route is protected by the Wevion auth gate: missing-2FA users can enroll during setup, while existing 2FA users must already have passed the current-session challenge. Pass `replacingPasskeyId` when resetting an existing passkey so it is left out of `excludeCredentials` — otherwise the authenticator that already holds that credential rejects the new registration outright.",
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "query",
            "name": "replacingPasskeyId",
            "required": false
          }
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "challenge",
                    "pubKeyCredParams",
                    "rp",
                    "user"
                  ],
                  "properties": {
                    "attestation": {
                      "type": "string"
                    },
                    "authenticatorSelection": {
                      "additionalProperties": false,
                      "type": "object",
                      "properties": {
                        "authenticatorAttachment": {
                          "type": "string"
                        },
                        "requireResidentKey": {
                          "type": "boolean"
                        },
                        "residentKey": {
                          "type": "string"
                        },
                        "userVerification": {
                          "type": "string"
                        }
                      }
                    },
                    "challenge": {
                      "type": "string"
                    },
                    "excludeCredentials": {
                      "type": "array",
                      "items": {
                        "additionalProperties": false,
                        "type": "object",
                        "required": [
                          "id",
                          "type"
                        ],
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "transports": {
                            "type": "array",
                            "items": {
                              "type": "string"
                            }
                          },
                          "type": {
                            "type": "string",
                            "enum": [
                              "public-key"
                            ]
                          }
                        }
                      }
                    },
                    "extensions": {
                      "type": "object",
                      "additionalProperties": {
                        "anyOf": [
                          {
                            "$comment": "json-value"
                          },
                          {
                            "type": "array",
                            "items": {
                              "$comment": "json-value"
                            }
                          },
                          {
                            "additionalProperties": {
                              "$comment": "json-value"
                            },
                            "type": "object",
                            "properties": {}
                          }
                        ]
                      }
                    },
                    "pubKeyCredParams": {
                      "type": "array",
                      "items": {
                        "additionalProperties": false,
                        "type": "object",
                        "required": [
                          "alg",
                          "type"
                        ],
                        "properties": {
                          "alg": {
                            "type": "number"
                          },
                          "type": {
                            "type": "string",
                            "enum": [
                              "public-key"
                            ]
                          }
                        }
                      }
                    },
                    "rp": {
                      "additionalProperties": false,
                      "type": "object",
                      "required": [
                        "id",
                        "name"
                      ],
                      "properties": {
                        "id": {
                          "type": "string"
                        },
                        "name": {
                          "type": "string"
                        }
                      }
                    },
                    "timeout": {
                      "type": "number"
                    },
                    "user": {
                      "additionalProperties": false,
                      "type": "object",
                      "required": [
                        "displayName",
                        "id",
                        "name"
                      ],
                      "properties": {
                        "displayName": {
                          "type": "string"
                        },
                        "id": {
                          "type": "string"
                        },
                        "name": {
                          "type": "string"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "Service unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/auth/2fa/passkeys/register-verify": {
      "post": {
        "operationId": "postApiV1Auth2faPasskeysRegisterVerify",
        "summary": "Verify passkey registration",
        "tags": [
          "auth"
        ],
        "description": "Verifies a WebAuthn registration response and stores the passkey as a 2FA method. On success it clears any support-reset re-enrollment flag and marks the current BetterAuth session as 2FA-verified.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "response"
                ],
                "properties": {
                  "name": {
                    "maxLength": 100,
                    "type": "string"
                  },
                  "response": {
                    "additionalProperties": false,
                    "type": "object",
                    "required": [
                      "id",
                      "rawId",
                      "response",
                      "type"
                    ],
                    "properties": {
                      "authenticatorAttachment": {
                        "type": "string"
                      },
                      "clientExtensionResults": {
                        "type": "object",
                        "additionalProperties": {
                          "anyOf": [
                            {
                              "$comment": "json-value"
                            },
                            {
                              "type": "array",
                              "items": {
                                "$comment": "json-value"
                              }
                            },
                            {
                              "additionalProperties": {
                                "$comment": "json-value"
                              },
                              "type": "object",
                              "properties": {}
                            }
                          ]
                        }
                      },
                      "id": {
                        "type": "string"
                      },
                      "rawId": {
                        "type": "string"
                      },
                      "response": {
                        "additionalProperties": false,
                        "type": "object",
                        "required": [
                          "attestationObject",
                          "clientDataJSON"
                        ],
                        "properties": {
                          "attestationObject": {
                            "type": "string"
                          },
                          "authenticatorData": {
                            "type": "string"
                          },
                          "clientDataJSON": {
                            "type": "string"
                          },
                          "publicKey": {
                            "type": "string"
                          },
                          "publicKeyAlgorithm": {
                            "type": "number"
                          },
                          "transports": {
                            "type": "array",
                            "items": {
                              "type": "string"
                            }
                          }
                        }
                      },
                      "type": {
                        "type": "string",
                        "enum": [
                          "public-key"
                        ]
                      }
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "backed_up",
                    "created_at",
                    "device_type",
                    "id",
                    "name"
                  ],
                  "properties": {
                    "backed_up": {
                      "type": "boolean"
                    },
                    "created_at": {
                      "format": "date-time",
                      "type": "string"
                    },
                    "device_type": {
                      "type": "string"
                    },
                    "id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "name": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "Service unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/auth/2fa/passkey/options": {
      "get": {
        "operationId": "getApiV1Auth2faPasskeyOptions",
        "summary": "Generate passkey 2FA challenge",
        "tags": [
          "auth"
        ],
        "description": "Generates WebAuthn authentication options for the current 2FA-pending session. The challenge is stored server-side and scoped to the BetterAuth session id.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "allowCredentials",
                    "challenge",
                    "rpId",
                    "timeout",
                    "userVerification"
                  ],
                  "properties": {
                    "allowCredentials": {
                      "type": "array",
                      "items": {
                        "additionalProperties": false,
                        "type": "object",
                        "required": [
                          "id",
                          "type"
                        ],
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "transports": {
                            "type": "array",
                            "items": {
                              "type": "string"
                            }
                          },
                          "type": {
                            "type": "string",
                            "enum": [
                              "public-key"
                            ]
                          }
                        }
                      }
                    },
                    "challenge": {
                      "type": "string"
                    },
                    "rpId": {
                      "type": "string"
                    },
                    "timeout": {
                      "type": "number"
                    },
                    "userVerification": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "Service unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/auth/2fa/passkey/verify": {
      "post": {
        "operationId": "postApiV1Auth2faPasskeyVerify",
        "summary": "Verify passkey 2FA challenge",
        "tags": [
          "auth"
        ],
        "description": "Verifies a WebAuthn passkey response for the current session and marks that BetterAuth session as second-factor verified. Also used, on an already-verified session, to satisfy the step-up requirement for passkey-management actions (e.g. DELETE /2fa/passkeys/:passkeyId): a short-lived single-use confirmation is stored and consumed there in place of a TOTP/backup code.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "id",
                  "rawId",
                  "response",
                  "type"
                ],
                "properties": {
                  "clientExtensionResults": {
                    "type": "object",
                    "additionalProperties": {
                      "anyOf": [
                        {
                          "$comment": "json-value"
                        },
                        {
                          "type": "array",
                          "items": {
                            "$comment": "json-value"
                          }
                        },
                        {
                          "additionalProperties": {
                            "$comment": "json-value"
                          },
                          "type": "object",
                          "properties": {}
                        }
                      ]
                    }
                  },
                  "id": {
                    "type": "string"
                  },
                  "rawId": {
                    "type": "string"
                  },
                  "response": {
                    "additionalProperties": false,
                    "type": "object",
                    "required": [
                      "authenticatorData",
                      "clientDataJSON",
                      "signature"
                    ],
                    "properties": {
                      "authenticatorData": {
                        "type": "string"
                      },
                      "clientDataJSON": {
                        "type": "string"
                      },
                      "signature": {
                        "type": "string"
                      },
                      "userHandle": {
                        "anyOf": [
                          {
                            "type": "string"
                          },
                          {
                            "type": "null"
                          }
                        ]
                      }
                    }
                  },
                  "type": {
                    "type": "string",
                    "enum": [
                      "public-key"
                    ]
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "message"
                  ],
                  "properties": {
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "Service unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/auth/2fa/passkeys": {
      "get": {
        "operationId": "getApiV1Auth2faPasskeys",
        "summary": "List registered passkeys",
        "tags": [
          "auth"
        ],
        "description": "Returns passkeys registered for the current user, for display in Security settings.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "items"
                  ],
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "additionalProperties": false,
                        "type": "object",
                        "required": [
                          "backed_up",
                          "created_at",
                          "device_type",
                          "id",
                          "name"
                        ],
                        "properties": {
                          "backed_up": {
                            "type": "boolean"
                          },
                          "created_at": {
                            "format": "date-time",
                            "type": "string"
                          },
                          "device_type": {
                            "type": "string"
                          },
                          "id": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "name": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/auth/2fa/passkeys/{passkeyId}": {
      "patch": {
        "operationId": "patchApiV1Auth2faPasskeysByPasskeyId",
        "summary": "Rename a registered passkey",
        "tags": [
          "auth"
        ],
        "description": "Updates the display name of one passkey owned by the current user. Cosmetic only — no step-up required, since renaming can't weaken the account's 2FA posture.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "name"
                ],
                "properties": {
                  "name": {
                    "minLength": 1,
                    "maxLength": 100,
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "passkeyId",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "backed_up",
                    "created_at",
                    "device_type",
                    "id",
                    "name"
                  ],
                  "properties": {
                    "backed_up": {
                      "type": "boolean"
                    },
                    "created_at": {
                      "format": "date-time",
                      "type": "string"
                    },
                    "device_type": {
                      "type": "string"
                    },
                    "id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "name": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      },
      "delete": {
        "operationId": "deleteApiV1Auth2faPasskeysByPasskeyId",
        "summary": "Remove a registered passkey",
        "tags": [
          "auth"
        ],
        "description": "Deletes one passkey owned by the current user. The last passkey cannot be removed unless a TOTP authenticator is active, preserving the invariant that the account always has at least one 2FA method. If the account also has TOTP enabled, step-up is required: either a fresh TOTP/backup code in `code`, or a fresh passkey re-authentication via POST /2fa/passkey/verify (its short-lived confirmation is consumed here instead) — mirrors /2fa/disable, and gives passkey-related actions a passkey-based step-up option too, so a hijacked session cannot silently strip factors.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "properties": {
                  "code": {
                    "minLength": 6,
                    "maxLength": 8,
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "passkeyId",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "message"
                  ],
                  "properties": {
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/auth/2fa/backup-codes": {
      "post": {
        "operationId": "postApiV1Auth2faBackupCodes",
        "summary": "Regenerate backup codes",
        "tags": [
          "auth"
        ],
        "description": "Generates a new set of backup codes. Requires step-up authentication on top of the JWT session: the user must provide a valid current TOTP or one existing backup code. Account password is never accepted.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "code"
                ],
                "properties": {
                  "code": {
                    "minLength": 6,
                    "maxLength": 8,
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "backup_codes"
                  ],
                  "properties": {
                    "backup_codes": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/auth/claim-contact": {
      "post": {
        "operationId": "postApiV1AuthClaimContact",
        "summary": "Claim a contact identity",
        "tags": [
          "auth"
        ],
        "description": "Attempts to link the authenticated user to a candidate identity, returning whether the claim linked immediately or requires verification.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "candidate_user_session_id"
                ],
                "properties": {
                  "candidate_user_session_id": {
                    "format": "uuid",
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "state"
                  ],
                  "properties": {
                    "state": {
                      "anyOf": [
                        {
                          "type": "string",
                          "enum": [
                            "linked"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "pending_verification"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "self_block"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "already_linked"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "forbidden_already_multi_linked"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "race_lost"
                          ]
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "202": {
            "description": "Accepted - processing asynchronously",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "state"
                  ],
                  "properties": {
                    "state": {
                      "anyOf": [
                        {
                          "type": "string",
                          "enum": [
                            "linked"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "pending_verification"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "self_block"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "already_linked"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "forbidden_already_multi_linked"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "race_lost"
                          ]
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "Conflict - resource state prevents the operation",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "Too many requests - rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/auth/claim-verify": {
      "get": {
        "operationId": "getApiV1AuthClaimVerify",
        "summary": "Verify identity claim token",
        "tags": [
          "auth"
        ],
        "description": "Consumes a one-time identity-claim verification token and reports whether the identity was linked.",
        "parameters": [
          {
            "schema": {
              "minLength": 32,
              "maxLength": 128,
              "type": "string"
            },
            "in": "query",
            "name": "token",
            "required": true
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "state"
                  ],
                  "properties": {
                    "state": {
                      "anyOf": [
                        {
                          "type": "string",
                          "enum": [
                            "linked"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "expired"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "race_lost"
                          ]
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "Conflict - resource state prevents the operation",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "state"
                  ],
                  "properties": {
                    "state": {
                      "anyOf": [
                        {
                          "type": "string",
                          "enum": [
                            "linked"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "expired"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "race_lost"
                          ]
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "410": {
            "description": "Gone - resource is permanently removed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "state"
                  ],
                  "properties": {
                    "state": {
                      "anyOf": [
                        {
                          "type": "string",
                          "enum": [
                            "linked"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "expired"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "race_lost"
                          ]
                        }
                      ]
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/auth/identity-candidates": {
      "get": {
        "operationId": "getApiV1AuthIdentityCandidates",
        "summary": "Find identity claim candidates",
        "tags": [
          "auth"
        ],
        "description": "Looks up masked user identities that may match the provided email/name so an authenticated user can start a claim flow.",
        "parameters": [
          {
            "schema": {
              "format": "email",
              "maxLength": 320,
              "type": "string"
            },
            "in": "query",
            "name": "email",
            "required": true
          },
          {
            "schema": {
              "maxLength": 200,
              "type": "string"
            },
            "in": "query",
            "name": "name",
            "required": false
          }
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "candidates"
                  ],
                  "properties": {
                    "candidates": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "id",
                          "email_masked",
                          "name",
                          "confidence_score",
                          "confidence_level"
                        ],
                        "properties": {
                          "id": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "email_masked": {
                            "type": "string"
                          },
                          "name": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "confidence_score": {
                            "type": "number"
                          },
                          "confidence_level": {
                            "anyOf": [
                              {
                                "type": "string",
                                "enum": [
                                  "high"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "medium"
                                ]
                              }
                            ]
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "request_id": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "request_id": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/auth/login-history": {
      "get": {
        "operationId": "getApiV1AuthLoginHistory",
        "summary": "Get login history",
        "tags": [
          "auth"
        ],
        "description": "Returns paginated login history for the current user.",
        "parameters": [
          {
            "schema": {
              "minimum": 1,
              "default": 1,
              "type": "integer"
            },
            "in": "query",
            "name": "page",
            "required": false
          },
          {
            "schema": {
              "minimum": 1,
              "maximum": 50,
              "default": 20,
              "type": "integer"
            },
            "in": "query",
            "name": "limit",
            "required": false
          }
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "items",
                    "total",
                    "page",
                    "limit"
                  ],
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "id",
                          "ip_address",
                          "user_agent",
                          "login_method",
                          "success",
                          "failure_reason",
                          "created_at",
                          "country",
                          "is_new_device",
                          "is_new_country"
                        ],
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "ip_address": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "user_agent": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "login_method": {
                            "type": "string"
                          },
                          "success": {
                            "type": "boolean"
                          },
                          "failure_reason": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "created_at": {
                            "type": "string"
                          },
                          "country": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "is_new_device": {
                            "anyOf": [
                              {
                                "type": "boolean"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "is_new_country": {
                            "anyOf": [
                              {
                                "type": "boolean"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          }
                        }
                      }
                    },
                    "total": {
                      "type": "integer"
                    },
                    "page": {
                      "type": "integer"
                    },
                    "limit": {
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/auth/active-sessions": {
      "get": {
        "operationId": "getApiV1AuthActiveSessions",
        "summary": "Get active sessions",
        "tags": [
          "auth"
        ],
        "description": "Returns the REAL non-expired BetterAuth sessions (auth_session rows) for the current user — one per signed-in device. The current device (`is_current`) is identified by the JWT `sid` claim (= auth_session.id, exposed as request.authSessionId); legacy tokens with no `sid` fall back to an IP + user-agent match. Revoking these truly logs out the corresponding device.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "items"
                  ],
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "id",
                          "ip_address",
                          "user_agent",
                          "login_method",
                          "last_seen",
                          "is_current"
                        ],
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "ip_address": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "user_agent": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "login_method": {
                            "type": "string"
                          },
                          "last_seen": {
                            "type": "string"
                          },
                          "is_current": {
                            "type": "boolean"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/auth/revoke-sessions": {
      "post": {
        "operationId": "postApiV1AuthRevokeSessions",
        "summary": "Revoke all sessions",
        "tags": [
          "auth"
        ],
        "description": "Logs out all devices, including the current one: deletes every BetterAuth session (auth_session row) for the user, denylists every sid in Redis for immediate JWT rejection, and sets token_invalidated_before=now so already-issued short-lived JWTs are rejected at once. Requires a current TOTP or backup code; account password is never accepted.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "code"
                ],
                "properties": {
                  "code": {
                    "minLength": 6,
                    "maxLength": 8,
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "message"
                  ],
                  "properties": {
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/auth/sessions/{sessionId}": {
      "delete": {
        "operationId": "deleteApiV1AuthSessionsBySessionId",
        "summary": "Revoke a single session",
        "tags": [
          "auth"
        ],
        "description": "Truly revokes a specific device by deleting its BetterAuth session (auth_session row). The :sessionId is an auth_session.id (= the JWT `sid`). The session identified as current (sessionId === the caller’s sid) cannot be revoked here. The revoked sid is denylisted in Redis so the device’s outstanding short-lived JWT is rejected immediately.",
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "sessionId",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "message"
                  ],
                  "properties": {
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/auth/account/delete": {
      "post": {
        "operationId": "postApiV1AuthAccountDelete",
        "summary": "Schedule account deletion",
        "tags": [
          "auth"
        ],
        "description": "Schedules account for deletion after 30-day grace period. Requires typing \"DELETE\". Also requires a current TOTP or backup code; account password is never accepted.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "confirmation",
                  "code"
                ],
                "properties": {
                  "confirmation": {
                    "type": "string",
                    "enum": [
                      "DELETE"
                    ]
                  },
                  "code": {
                    "minLength": 6,
                    "maxLength": 8,
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "message",
                    "deletion_scheduled_at"
                  ],
                  "properties": {
                    "message": {
                      "type": "string"
                    },
                    "deletion_scheduled_at": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "Conflict - resource state prevents the operation",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/auth/account/cancel-deletion": {
      "post": {
        "operationId": "postApiV1AuthAccountCancelDeletion",
        "summary": "Cancel account deletion",
        "tags": [
          "auth"
        ],
        "description": "Cancels a previously scheduled account deletion.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "message"
                  ],
                  "properties": {
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/auth/account/deletion-status": {
      "get": {
        "operationId": "getApiV1AuthAccountDeletionStatus",
        "summary": "Get account deletion status",
        "tags": [
          "auth"
        ],
        "description": "Returns the current deletion schedule status.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "scheduled",
                    "deletion_scheduled_at"
                  ],
                  "properties": {
                    "scheduled": {
                      "type": "boolean"
                    },
                    "deletion_scheduled_at": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/auth/security-nudge": {
      "get": {
        "operationId": "getApiV1AuthSecurityNudge",
        "summary": "Get 2FA nudge state",
        "tags": [
          "auth"
        ],
        "description": "Returns the current user's 2FA-enable nudge banner state (last dismissal time, last shown time, snooze count). Defaults are returned when no state has been persisted yet.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "dismissed_at",
                    "last_shown_at",
                    "snooze_count"
                  ],
                  "properties": {
                    "dismissed_at": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "last_shown_at": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "snooze_count": {
                      "minimum": 0,
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      },
      "put": {
        "operationId": "putApiV1AuthSecurityNudge",
        "summary": "Update 2FA nudge state",
        "tags": [
          "auth"
        ],
        "description": "Merges the provided fields into the current user's 2FA-enable nudge banner state and persists it. Used when the user snoozes (\"Più tardi\") or when the banner records that it was shown. Opt-in only; this never enforces 2FA.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "properties": {
                  "dismissed_at": {
                    "anyOf": [
                      {
                        "format": "date-time",
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "last_shown_at": {
                    "anyOf": [
                      {
                        "format": "date-time",
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "snooze_count": {
                    "minimum": 0,
                    "type": "integer"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "dismissed_at",
                    "last_shown_at",
                    "snooze_count"
                  ],
                  "properties": {
                    "dismissed_at": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "last_shown_at": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "snooze_count": {
                      "minimum": 0,
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/auth/me": {
      "get": {
        "operationId": "getApiV1AuthMe",
        "summary": "Get current user",
        "tags": [
          "auth"
        ],
        "description": "Returns the authenticated user profile. Requires a valid JWT token. Includes `is_internal`: true when the profile is outside the clean analytics cohort (internal/staff e-mail domain, Gold/ULTRA, comped, allowlisted, backoffice staff role, or the demo account) — the same population every backoffice dashboard excludes. Used by the SPA to tag the session cohort in analytics; it carries no entitlement and grants nothing. Also includes `organization_id` (the backoffice `organization.id`), used by the SPA to tag the Clarity Live session for a direct backoffice lookup.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "id",
                    "email",
                    "name",
                    "role",
                    "created_at",
                    "last_login",
                    "is_active",
                    "company_name",
                    "company_address",
                    "company_city",
                    "company_zip",
                    "company_country",
                    "company_vat",
                    "team_name",
                    "preferred_language",
                    "avatar_url"
                  ],
                  "properties": {
                    "id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "email": {
                      "type": "string"
                    },
                    "name": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "role": {
                      "type": "string"
                    },
                    "created_at": {
                      "format": "date-time",
                      "type": "string"
                    },
                    "last_login": {
                      "anyOf": [
                        {
                          "format": "date-time",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "is_active": {
                      "type": "boolean"
                    },
                    "company_name": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "company_address": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "company_city": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "company_zip": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "company_country": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "company_vat": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "team_name": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "preferred_language": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "avatar_url": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "onboarding_state": {
                      "$comment": "json-value",
                      "description": "Arbitrary JSON value with nested arrays and objects."
                    },
                    "two_factor_enabled": {
                      "type": "boolean"
                    },
                    "two_factor_methods": {
                      "additionalProperties": false,
                      "type": "object",
                      "required": [
                        "passkey",
                        "totp"
                      ],
                      "properties": {
                        "passkey": {
                          "type": "boolean"
                        },
                        "totp": {
                          "type": "boolean"
                        }
                      }
                    },
                    "two_factor_required": {
                      "type": "boolean"
                    },
                    "two_factor_setup_required": {
                      "type": "boolean"
                    },
                    "two_factor_reenroll_required": {
                      "type": "boolean"
                    },
                    "two_factor_rollout": {
                      "additionalProperties": false,
                      "type": "object",
                      "required": [
                        "enabled",
                        "is_enforced",
                        "mandatory_after",
                        "missing_policy",
                        "rollout_started_at",
                        "seconds_remaining"
                      ],
                      "properties": {
                        "enabled": {
                          "type": "boolean"
                        },
                        "is_enforced": {
                          "type": "boolean"
                        },
                        "mandatory_after": {
                          "anyOf": [
                            {
                              "format": "date-time",
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "missing_policy": {
                          "type": "boolean"
                        },
                        "rollout_started_at": {
                          "anyOf": [
                            {
                              "format": "date-time",
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "seconds_remaining": {
                          "anyOf": [
                            {
                              "minimum": 0,
                              "type": "integer"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        }
                      }
                    },
                    "two_factor_mandatory": {
                      "type": "boolean"
                    },
                    "has_password": {
                      "type": "boolean"
                    },
                    "deletion_scheduled_at": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "tos_accepted_at": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "tos_version": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "tos_accepted_versions": {
                      "anyOf": [
                        {
                          "type": "object",
                          "additionalProperties": {
                            "type": "string"
                          }
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "first_spend_at": {
                      "anyOf": [
                        {
                          "format": "date-time",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "owner_id": {
                      "anyOf": [
                        {
                          "format": "uuid",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "is_internal": {
                      "type": "boolean"
                    },
                    "organization_id": {
                      "anyOf": [
                        {
                          "format": "uuid",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "subscription": {
                      "type": "object",
                      "required": [
                        "status",
                        "is_read_only",
                        "read_only_reason",
                        "plan_name",
                        "plan_display_name",
                        "trial_end"
                      ],
                      "properties": {
                        "status": {
                          "type": "string"
                        },
                        "is_read_only": {
                          "type": "boolean"
                        },
                        "read_only_reason": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "plan_name": {
                          "type": "string"
                        },
                        "plan_display_name": {
                          "type": "string"
                        },
                        "trial_end": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        }
                      }
                    },
                    "impersonation": {
                      "additionalProperties": false,
                      "type": "object",
                      "required": [
                        "active",
                        "impersonator"
                      ],
                      "properties": {
                        "active": {
                          "type": "boolean"
                        },
                        "impersonator": {
                          "anyOf": [
                            {
                              "type": "object",
                              "required": [
                                "id",
                                "email",
                                "role"
                              ],
                              "properties": {
                                "id": {
                                  "format": "uuid",
                                  "type": "string"
                                },
                                "email": {
                                  "type": "string"
                                },
                                "role": {
                                  "type": "string"
                                }
                              }
                            },
                            {
                              "type": "null"
                            }
                          ]
                        }
                      }
                    },
                    "partner": {
                      "anyOf": [
                        {
                          "additionalProperties": false,
                          "type": "object",
                          "required": [
                            "partner_id",
                            "status",
                            "lane",
                            "profile",
                            "collection_mode",
                            "partner_only",
                            "panel_enabled",
                            "public_profile_approved",
                            "kyc_level",
                            "payout_ready",
                            "redirector_origin"
                          ],
                          "properties": {
                            "partner_id": {
                              "format": "uuid",
                              "type": "string"
                            },
                            "status": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "enum": [
                                    "approved"
                                  ]
                                },
                                {
                                  "type": "string",
                                  "enum": [
                                    "suspended"
                                  ]
                                },
                                {
                                  "type": "string",
                                  "enum": [
                                    "terminated"
                                  ]
                                }
                              ]
                            },
                            "lane": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "enum": [
                                    "C1_creator"
                                  ]
                                },
                                {
                                  "type": "string",
                                  "enum": [
                                    "C2_community"
                                  ]
                                },
                                {
                                  "type": "string",
                                  "enum": [
                                    "C3_ugc"
                                  ]
                                },
                                {
                                  "type": "string",
                                  "enum": [
                                    "C4_newsletter"
                                  ]
                                },
                                {
                                  "type": "string",
                                  "enum": [
                                    "C5_referrer"
                                  ]
                                },
                                {
                                  "type": "string",
                                  "enum": [
                                    "C6_agency"
                                  ]
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "profile": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "enum": [
                                    "cliente-referrer"
                                  ]
                                },
                                {
                                  "type": "string",
                                  "enum": [
                                    "creator"
                                  ]
                                },
                                {
                                  "type": "string",
                                  "enum": [
                                    "ugc"
                                  ]
                                },
                                {
                                  "type": "string",
                                  "enum": [
                                    "closer"
                                  ]
                                }
                              ]
                            },
                            "collection_mode": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "enum": [
                                    "cash"
                                  ]
                                },
                                {
                                  "type": "string",
                                  "enum": [
                                    "accrual"
                                  ]
                                },
                                {
                                  "type": "string",
                                  "enum": [
                                    "community_benefit"
                                  ]
                                }
                              ]
                            },
                            "partner_only": {
                              "type": "boolean"
                            },
                            "panel_enabled": {
                              "type": "boolean"
                            },
                            "public_profile_approved": {
                              "type": "boolean"
                            },
                            "kyc_level": {
                              "anyOf": [
                                {
                                  "type": "number",
                                  "enum": [
                                    0
                                  ]
                                },
                                {
                                  "type": "number",
                                  "enum": [
                                    1
                                  ]
                                },
                                {
                                  "type": "number",
                                  "enum": [
                                    2
                                  ]
                                },
                                {
                                  "type": "number",
                                  "enum": [
                                    3
                                  ]
                                }
                              ]
                            },
                            "payout_ready": {
                              "type": "boolean"
                            },
                            "redirector_origin": {
                              "type": "string"
                            }
                          }
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "team": {
                      "anyOf": [
                        {
                          "type": "object",
                          "required": [
                            "id",
                            "name",
                            "app_install_source"
                          ],
                          "properties": {
                            "id": {
                              "format": "uuid",
                              "type": "string"
                            },
                            "name": {
                              "type": "string"
                            },
                            "app_install_source": {
                              "anyOf": [
                                {
                                  "type": "string"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            }
                          }
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "request_id": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "request_id": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "request_id": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "request_id": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      },
      "patch": {
        "operationId": "patchApiV1AuthMe",
        "summary": "Update current user profile",
        "tags": [
          "auth"
        ],
        "description": "Updates the authenticated user profile (name, company, language, onboarding_state). Requires a valid JWT token. If `onboarding_state.segment` is present it must be one of: agency, dtc, media_buyer, dropshipper, generic.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "properties": {
                  "name": {
                    "anyOf": [
                      {
                        "maxLength": 255,
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "company_name": {
                    "anyOf": [
                      {
                        "minLength": 2,
                        "maxLength": 255,
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "company_address": {
                    "anyOf": [
                      {
                        "maxLength": 500,
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "company_city": {
                    "anyOf": [
                      {
                        "maxLength": 255,
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "company_zip": {
                    "anyOf": [
                      {
                        "minLength": 3,
                        "maxLength": 20,
                        "pattern": "^[A-Za-z0-9 \\-]{3,20}$",
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "company_country": {
                    "anyOf": [
                      {
                        "maxLength": 100,
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "company_vat": {
                    "anyOf": [
                      {
                        "minLength": 5,
                        "maxLength": 100,
                        "pattern": "^[A-Za-z0-9 .\\-/]{5,100}$",
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "team_name": {
                    "anyOf": [
                      {
                        "maxLength": 255,
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "preferred_language": {
                    "anyOf": [
                      {
                        "anyOf": [
                          {
                            "type": "string",
                            "enum": [
                              "en"
                            ]
                          },
                          {
                            "type": "string",
                            "enum": [
                              "it"
                            ]
                          },
                          {
                            "type": "string",
                            "enum": [
                              "es"
                            ]
                          },
                          {
                            "type": "string",
                            "enum": [
                              "fr"
                            ]
                          },
                          {
                            "type": "string",
                            "enum": [
                              "de"
                            ]
                          },
                          {
                            "type": "string",
                            "enum": [
                              "pt"
                            ]
                          },
                          {
                            "type": "string",
                            "enum": [
                              "ja"
                            ]
                          },
                          {
                            "type": "string",
                            "enum": [
                              "ru"
                            ]
                          },
                          {
                            "type": "string",
                            "enum": [
                              "zh"
                            ]
                          },
                          {
                            "type": "string",
                            "enum": [
                              "ko"
                            ]
                          },
                          {
                            "type": "string",
                            "enum": [
                              "ar"
                            ]
                          },
                          {
                            "type": "string",
                            "enum": [
                              "hi"
                            ]
                          },
                          {
                            "type": "string",
                            "enum": [
                              "id"
                            ]
                          },
                          {
                            "type": "string",
                            "enum": [
                              "pl"
                            ]
                          },
                          {
                            "type": "string",
                            "enum": [
                              "ro"
                            ]
                          },
                          {
                            "type": "string",
                            "enum": [
                              "sr"
                            ]
                          },
                          {
                            "type": "string",
                            "enum": [
                              "th"
                            ]
                          },
                          {
                            "type": "string",
                            "enum": [
                              "tr"
                            ]
                          },
                          {
                            "type": "string",
                            "enum": [
                              "uk"
                            ]
                          }
                        ]
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "onboarding_state": {
                    "$comment": "json-value",
                    "description": "Arbitrary JSON value with nested arrays and objects."
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "id",
                    "email",
                    "name",
                    "role",
                    "created_at",
                    "last_login",
                    "is_active",
                    "company_name",
                    "company_address",
                    "company_city",
                    "company_zip",
                    "company_country",
                    "company_vat",
                    "team_name",
                    "preferred_language",
                    "avatar_url"
                  ],
                  "properties": {
                    "id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "email": {
                      "type": "string"
                    },
                    "name": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "role": {
                      "type": "string"
                    },
                    "created_at": {
                      "format": "date-time",
                      "type": "string"
                    },
                    "last_login": {
                      "anyOf": [
                        {
                          "format": "date-time",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "is_active": {
                      "type": "boolean"
                    },
                    "company_name": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "company_address": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "company_city": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "company_zip": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "company_country": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "company_vat": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "team_name": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "preferred_language": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "avatar_url": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "onboarding_state": {
                      "$comment": "json-value",
                      "description": "Arbitrary JSON value with nested arrays and objects."
                    },
                    "two_factor_enabled": {
                      "type": "boolean"
                    },
                    "two_factor_methods": {
                      "additionalProperties": false,
                      "type": "object",
                      "required": [
                        "passkey",
                        "totp"
                      ],
                      "properties": {
                        "passkey": {
                          "type": "boolean"
                        },
                        "totp": {
                          "type": "boolean"
                        }
                      }
                    },
                    "two_factor_required": {
                      "type": "boolean"
                    },
                    "two_factor_setup_required": {
                      "type": "boolean"
                    },
                    "two_factor_reenroll_required": {
                      "type": "boolean"
                    },
                    "two_factor_rollout": {
                      "additionalProperties": false,
                      "type": "object",
                      "required": [
                        "enabled",
                        "is_enforced",
                        "mandatory_after",
                        "missing_policy",
                        "rollout_started_at",
                        "seconds_remaining"
                      ],
                      "properties": {
                        "enabled": {
                          "type": "boolean"
                        },
                        "is_enforced": {
                          "type": "boolean"
                        },
                        "mandatory_after": {
                          "anyOf": [
                            {
                              "format": "date-time",
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "missing_policy": {
                          "type": "boolean"
                        },
                        "rollout_started_at": {
                          "anyOf": [
                            {
                              "format": "date-time",
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "seconds_remaining": {
                          "anyOf": [
                            {
                              "minimum": 0,
                              "type": "integer"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        }
                      }
                    },
                    "two_factor_mandatory": {
                      "type": "boolean"
                    },
                    "has_password": {
                      "type": "boolean"
                    },
                    "deletion_scheduled_at": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "tos_accepted_at": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "tos_version": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "tos_accepted_versions": {
                      "anyOf": [
                        {
                          "type": "object",
                          "additionalProperties": {
                            "type": "string"
                          }
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "first_spend_at": {
                      "anyOf": [
                        {
                          "format": "date-time",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "owner_id": {
                      "anyOf": [
                        {
                          "format": "uuid",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "is_internal": {
                      "type": "boolean"
                    },
                    "organization_id": {
                      "anyOf": [
                        {
                          "format": "uuid",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "subscription": {
                      "type": "object",
                      "required": [
                        "status",
                        "is_read_only",
                        "read_only_reason",
                        "plan_name",
                        "plan_display_name",
                        "trial_end"
                      ],
                      "properties": {
                        "status": {
                          "type": "string"
                        },
                        "is_read_only": {
                          "type": "boolean"
                        },
                        "read_only_reason": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "plan_name": {
                          "type": "string"
                        },
                        "plan_display_name": {
                          "type": "string"
                        },
                        "trial_end": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        }
                      }
                    },
                    "impersonation": {
                      "additionalProperties": false,
                      "type": "object",
                      "required": [
                        "active",
                        "impersonator"
                      ],
                      "properties": {
                        "active": {
                          "type": "boolean"
                        },
                        "impersonator": {
                          "anyOf": [
                            {
                              "type": "object",
                              "required": [
                                "id",
                                "email",
                                "role"
                              ],
                              "properties": {
                                "id": {
                                  "format": "uuid",
                                  "type": "string"
                                },
                                "email": {
                                  "type": "string"
                                },
                                "role": {
                                  "type": "string"
                                }
                              }
                            },
                            {
                              "type": "null"
                            }
                          ]
                        }
                      }
                    },
                    "partner": {
                      "anyOf": [
                        {
                          "additionalProperties": false,
                          "type": "object",
                          "required": [
                            "partner_id",
                            "status",
                            "lane",
                            "profile",
                            "collection_mode",
                            "partner_only",
                            "panel_enabled",
                            "public_profile_approved",
                            "kyc_level",
                            "payout_ready",
                            "redirector_origin"
                          ],
                          "properties": {
                            "partner_id": {
                              "format": "uuid",
                              "type": "string"
                            },
                            "status": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "enum": [
                                    "approved"
                                  ]
                                },
                                {
                                  "type": "string",
                                  "enum": [
                                    "suspended"
                                  ]
                                },
                                {
                                  "type": "string",
                                  "enum": [
                                    "terminated"
                                  ]
                                }
                              ]
                            },
                            "lane": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "enum": [
                                    "C1_creator"
                                  ]
                                },
                                {
                                  "type": "string",
                                  "enum": [
                                    "C2_community"
                                  ]
                                },
                                {
                                  "type": "string",
                                  "enum": [
                                    "C3_ugc"
                                  ]
                                },
                                {
                                  "type": "string",
                                  "enum": [
                                    "C4_newsletter"
                                  ]
                                },
                                {
                                  "type": "string",
                                  "enum": [
                                    "C5_referrer"
                                  ]
                                },
                                {
                                  "type": "string",
                                  "enum": [
                                    "C6_agency"
                                  ]
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "profile": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "enum": [
                                    "cliente-referrer"
                                  ]
                                },
                                {
                                  "type": "string",
                                  "enum": [
                                    "creator"
                                  ]
                                },
                                {
                                  "type": "string",
                                  "enum": [
                                    "ugc"
                                  ]
                                },
                                {
                                  "type": "string",
                                  "enum": [
                                    "closer"
                                  ]
                                }
                              ]
                            },
                            "collection_mode": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "enum": [
                                    "cash"
                                  ]
                                },
                                {
                                  "type": "string",
                                  "enum": [
                                    "accrual"
                                  ]
                                },
                                {
                                  "type": "string",
                                  "enum": [
                                    "community_benefit"
                                  ]
                                }
                              ]
                            },
                            "partner_only": {
                              "type": "boolean"
                            },
                            "panel_enabled": {
                              "type": "boolean"
                            },
                            "public_profile_approved": {
                              "type": "boolean"
                            },
                            "kyc_level": {
                              "anyOf": [
                                {
                                  "type": "number",
                                  "enum": [
                                    0
                                  ]
                                },
                                {
                                  "type": "number",
                                  "enum": [
                                    1
                                  ]
                                },
                                {
                                  "type": "number",
                                  "enum": [
                                    2
                                  ]
                                },
                                {
                                  "type": "number",
                                  "enum": [
                                    3
                                  ]
                                }
                              ]
                            },
                            "payout_ready": {
                              "type": "boolean"
                            },
                            "redirector_origin": {
                              "type": "string"
                            }
                          }
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "team": {
                      "anyOf": [
                        {
                          "type": "object",
                          "required": [
                            "id",
                            "name",
                            "app_install_source"
                          ],
                          "properties": {
                            "id": {
                              "format": "uuid",
                              "type": "string"
                            },
                            "name": {
                              "type": "string"
                            },
                            "app_install_source": {
                              "anyOf": [
                                {
                                  "type": "string"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            }
                          }
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "request_id": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "request_id": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "request_id": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/auth/accept-tos": {
      "post": {
        "operationId": "postApiV1AuthAcceptTos",
        "summary": "Accept Terms of Service",
        "tags": [
          "auth"
        ],
        "description": "Records the user acceptance of the current legal documents. Accepts an optional per-document `documents[]` array (each version must match the current one); a legacy body with only `tos_version` accepts the whole current bundle. Writes an append-only row per document to the legal_consent ledger and updates the user acceptance state in one transaction.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "tos_version"
                ],
                "properties": {
                  "tos_version": {
                    "minLength": 1,
                    "maxLength": 10,
                    "type": "string"
                  },
                  "documents": {
                    "minItems": 1,
                    "type": "array",
                    "items": {
                      "additionalProperties": false,
                      "type": "object",
                      "required": [
                        "document",
                        "version"
                      ],
                      "properties": {
                        "document": {
                          "anyOf": [
                            {
                              "type": "string",
                              "enum": [
                                "termsOfService"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "privacyPolicy"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "cookiePolicy"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "dataProcessingAgreement"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "acceptableUsePolicy"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "subProcessors"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "dataDeletion"
                              ]
                            }
                          ]
                        },
                        "version": {
                          "minLength": 1,
                          "maxLength": 20,
                          "type": "string"
                        }
                      }
                    }
                  },
                  "method": {
                    "anyOf": [
                      {
                        "type": "string",
                        "enum": [
                          "in_app"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "reconsent_prompt"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "signup_checkbox"
                        ]
                      }
                    ]
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "id",
                    "email",
                    "name",
                    "role",
                    "created_at",
                    "last_login",
                    "is_active",
                    "company_name",
                    "company_address",
                    "company_city",
                    "company_zip",
                    "company_country",
                    "company_vat",
                    "team_name",
                    "preferred_language",
                    "avatar_url"
                  ],
                  "properties": {
                    "id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "email": {
                      "type": "string"
                    },
                    "name": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "role": {
                      "type": "string"
                    },
                    "created_at": {
                      "format": "date-time",
                      "type": "string"
                    },
                    "last_login": {
                      "anyOf": [
                        {
                          "format": "date-time",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "is_active": {
                      "type": "boolean"
                    },
                    "company_name": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "company_address": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "company_city": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "company_zip": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "company_country": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "company_vat": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "team_name": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "preferred_language": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "avatar_url": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "onboarding_state": {
                      "$comment": "json-value",
                      "description": "Arbitrary JSON value with nested arrays and objects."
                    },
                    "two_factor_enabled": {
                      "type": "boolean"
                    },
                    "two_factor_methods": {
                      "additionalProperties": false,
                      "type": "object",
                      "required": [
                        "passkey",
                        "totp"
                      ],
                      "properties": {
                        "passkey": {
                          "type": "boolean"
                        },
                        "totp": {
                          "type": "boolean"
                        }
                      }
                    },
                    "two_factor_required": {
                      "type": "boolean"
                    },
                    "two_factor_setup_required": {
                      "type": "boolean"
                    },
                    "two_factor_reenroll_required": {
                      "type": "boolean"
                    },
                    "two_factor_rollout": {
                      "additionalProperties": false,
                      "type": "object",
                      "required": [
                        "enabled",
                        "is_enforced",
                        "mandatory_after",
                        "missing_policy",
                        "rollout_started_at",
                        "seconds_remaining"
                      ],
                      "properties": {
                        "enabled": {
                          "type": "boolean"
                        },
                        "is_enforced": {
                          "type": "boolean"
                        },
                        "mandatory_after": {
                          "anyOf": [
                            {
                              "format": "date-time",
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "missing_policy": {
                          "type": "boolean"
                        },
                        "rollout_started_at": {
                          "anyOf": [
                            {
                              "format": "date-time",
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "seconds_remaining": {
                          "anyOf": [
                            {
                              "minimum": 0,
                              "type": "integer"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        }
                      }
                    },
                    "two_factor_mandatory": {
                      "type": "boolean"
                    },
                    "has_password": {
                      "type": "boolean"
                    },
                    "deletion_scheduled_at": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "tos_accepted_at": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "tos_version": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "tos_accepted_versions": {
                      "anyOf": [
                        {
                          "type": "object",
                          "additionalProperties": {
                            "type": "string"
                          }
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "first_spend_at": {
                      "anyOf": [
                        {
                          "format": "date-time",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "owner_id": {
                      "anyOf": [
                        {
                          "format": "uuid",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "is_internal": {
                      "type": "boolean"
                    },
                    "organization_id": {
                      "anyOf": [
                        {
                          "format": "uuid",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "subscription": {
                      "type": "object",
                      "required": [
                        "status",
                        "is_read_only",
                        "read_only_reason",
                        "plan_name",
                        "plan_display_name",
                        "trial_end"
                      ],
                      "properties": {
                        "status": {
                          "type": "string"
                        },
                        "is_read_only": {
                          "type": "boolean"
                        },
                        "read_only_reason": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "plan_name": {
                          "type": "string"
                        },
                        "plan_display_name": {
                          "type": "string"
                        },
                        "trial_end": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        }
                      }
                    },
                    "impersonation": {
                      "additionalProperties": false,
                      "type": "object",
                      "required": [
                        "active",
                        "impersonator"
                      ],
                      "properties": {
                        "active": {
                          "type": "boolean"
                        },
                        "impersonator": {
                          "anyOf": [
                            {
                              "type": "object",
                              "required": [
                                "id",
                                "email",
                                "role"
                              ],
                              "properties": {
                                "id": {
                                  "format": "uuid",
                                  "type": "string"
                                },
                                "email": {
                                  "type": "string"
                                },
                                "role": {
                                  "type": "string"
                                }
                              }
                            },
                            {
                              "type": "null"
                            }
                          ]
                        }
                      }
                    },
                    "partner": {
                      "anyOf": [
                        {
                          "additionalProperties": false,
                          "type": "object",
                          "required": [
                            "partner_id",
                            "status",
                            "lane",
                            "profile",
                            "collection_mode",
                            "partner_only",
                            "panel_enabled",
                            "public_profile_approved",
                            "kyc_level",
                            "payout_ready",
                            "redirector_origin"
                          ],
                          "properties": {
                            "partner_id": {
                              "format": "uuid",
                              "type": "string"
                            },
                            "status": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "enum": [
                                    "approved"
                                  ]
                                },
                                {
                                  "type": "string",
                                  "enum": [
                                    "suspended"
                                  ]
                                },
                                {
                                  "type": "string",
                                  "enum": [
                                    "terminated"
                                  ]
                                }
                              ]
                            },
                            "lane": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "enum": [
                                    "C1_creator"
                                  ]
                                },
                                {
                                  "type": "string",
                                  "enum": [
                                    "C2_community"
                                  ]
                                },
                                {
                                  "type": "string",
                                  "enum": [
                                    "C3_ugc"
                                  ]
                                },
                                {
                                  "type": "string",
                                  "enum": [
                                    "C4_newsletter"
                                  ]
                                },
                                {
                                  "type": "string",
                                  "enum": [
                                    "C5_referrer"
                                  ]
                                },
                                {
                                  "type": "string",
                                  "enum": [
                                    "C6_agency"
                                  ]
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "profile": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "enum": [
                                    "cliente-referrer"
                                  ]
                                },
                                {
                                  "type": "string",
                                  "enum": [
                                    "creator"
                                  ]
                                },
                                {
                                  "type": "string",
                                  "enum": [
                                    "ugc"
                                  ]
                                },
                                {
                                  "type": "string",
                                  "enum": [
                                    "closer"
                                  ]
                                }
                              ]
                            },
                            "collection_mode": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "enum": [
                                    "cash"
                                  ]
                                },
                                {
                                  "type": "string",
                                  "enum": [
                                    "accrual"
                                  ]
                                },
                                {
                                  "type": "string",
                                  "enum": [
                                    "community_benefit"
                                  ]
                                }
                              ]
                            },
                            "partner_only": {
                              "type": "boolean"
                            },
                            "panel_enabled": {
                              "type": "boolean"
                            },
                            "public_profile_approved": {
                              "type": "boolean"
                            },
                            "kyc_level": {
                              "anyOf": [
                                {
                                  "type": "number",
                                  "enum": [
                                    0
                                  ]
                                },
                                {
                                  "type": "number",
                                  "enum": [
                                    1
                                  ]
                                },
                                {
                                  "type": "number",
                                  "enum": [
                                    2
                                  ]
                                },
                                {
                                  "type": "number",
                                  "enum": [
                                    3
                                  ]
                                }
                              ]
                            },
                            "payout_ready": {
                              "type": "boolean"
                            },
                            "redirector_origin": {
                              "type": "string"
                            }
                          }
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "team": {
                      "anyOf": [
                        {
                          "type": "object",
                          "required": [
                            "id",
                            "name",
                            "app_install_source"
                          ],
                          "properties": {
                            "id": {
                              "format": "uuid",
                              "type": "string"
                            },
                            "name": {
                              "type": "string"
                            },
                            "app_install_source": {
                              "anyOf": [
                                {
                                  "type": "string"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            }
                          }
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "request_id": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "request_id": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "request_id": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/auth/change-password": {
      "post": {
        "operationId": "postApiV1AuthChangePassword",
        "summary": "Change or set password",
        "tags": [
          "auth"
        ],
        "description": "Changes the authenticated user password. Requires current password verification when one exists. For SSO-only users with no local credential (e.g. Google sign-in) this endpoint sets the initial password and current_password is not required.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "new_password"
                ],
                "properties": {
                  "current_password": {
                    "maxLength": 128,
                    "type": "string"
                  },
                  "new_password": {
                    "minLength": 12,
                    "maxLength": 128,
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "message"
                  ],
                  "properties": {
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "request_id": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "request_id": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "request_id": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "request_id": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/auth/avatar": {
      "post": {
        "operationId": "postApiV1AuthAvatar",
        "summary": "Upload user avatar",
        "tags": [
          "auth"
        ],
        "description": "Uploads a profile avatar image. Accepted formats: JPEG, PNG, WebP. Max 5MB. Image is resized to 256x256.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "avatar_url"
                  ],
                  "properties": {
                    "avatar_url": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "request_id": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "request_id": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "request_id": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      },
      "delete": {
        "operationId": "deleteApiV1AuthAvatar",
        "summary": "Delete user avatar",
        "tags": [
          "auth"
        ],
        "description": "Removes the user profile avatar.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "message"
                  ],
                  "properties": {
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "request_id": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "request_id": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/auth/notifications": {
      "get": {
        "operationId": "getApiV1AuthNotifications",
        "summary": "[Deprecated] Get notification preferences",
        "tags": [
          "auth"
        ],
        "description": "Deprecated. Use GET /api/v1/notifications/preferences instead. Returns email and browser notification settings.",
        "deprecated": true,
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "email_reports",
                    "email_errors",
                    "browser_notifications"
                  ],
                  "properties": {
                    "email_reports": {
                      "type": "boolean"
                    },
                    "email_errors": {
                      "type": "boolean"
                    },
                    "browser_notifications": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "request_id": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "request_id": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      },
      "put": {
        "operationId": "putApiV1AuthNotifications",
        "summary": "[Deprecated] Update notification preferences",
        "tags": [
          "auth"
        ],
        "description": "Deprecated. Use PUT /api/v1/notifications/preferences instead. Updates email and browser notification settings.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "email_reports",
                  "email_errors",
                  "browser_notifications"
                ],
                "properties": {
                  "email_reports": {
                    "type": "boolean"
                  },
                  "email_errors": {
                    "type": "boolean"
                  },
                  "browser_notifications": {
                    "type": "boolean"
                  }
                }
              }
            }
          }
        },
        "deprecated": true,
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "email_reports",
                    "email_errors",
                    "browser_notifications"
                  ],
                  "properties": {
                    "email_reports": {
                      "type": "boolean"
                    },
                    "email_errors": {
                      "type": "boolean"
                    },
                    "browser_notifications": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "request_id": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "request_id": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/beta-feedback/export": {
      "get": {
        "operationId": "getApiV1BetaFeedbackExport",
        "summary": "Export beta feedback as markdown",
        "tags": [
          "beta-feedback"
        ],
        "description": "Generates a markdown file with all bug reports for Claude Code.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Markdown export content.",
            "content": {
              "text/markdown": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/beta-feedback/bugs": {
      "get": {
        "operationId": "getApiV1BetaFeedbackBugs",
        "summary": "List beta feedback bugs",
        "tags": [
          "beta-feedback"
        ],
        "description": "Returns bug reports with optional filters.",
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "status",
            "required": false
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "category",
            "required": false
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "severity",
            "required": false
          },
          {
            "schema": {
              "minimum": 1,
              "maximum": 200,
              "default": 50,
              "type": "number"
            },
            "in": "query",
            "name": "limit",
            "required": false
          },
          {
            "schema": {
              "minimum": 0,
              "default": 0,
              "type": "number"
            },
            "in": "query",
            "name": "offset",
            "required": false
          }
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "items",
                    "total"
                  ],
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "id",
                          "category",
                          "severity",
                          "title",
                          "description",
                          "affected_page",
                          "affected_component",
                          "image_urls",
                          "reporter_username",
                          "reporter_name",
                          "status",
                          "developer_notes",
                          "created_at"
                        ],
                        "properties": {
                          "id": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "category": {
                            "type": "string"
                          },
                          "severity": {
                            "type": "string"
                          },
                          "title": {
                            "type": "string"
                          },
                          "description": {
                            "type": "string"
                          },
                          "affected_page": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "affected_component": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "image_urls": {
                            "type": "array",
                            "items": {
                              "type": "string"
                            }
                          },
                          "reporter_username": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "reporter_name": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "status": {
                            "type": "string"
                          },
                          "developer_notes": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "created_at": {
                            "format": "date-time",
                            "type": "string"
                          }
                        }
                      }
                    },
                    "total": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/beta-feedback/bugs/{id}": {
      "patch": {
        "operationId": "patchApiV1BetaFeedbackBugsById",
        "summary": "Update beta feedback bug",
        "tags": [
          "beta-feedback"
        ],
        "description": "Update status or developer notes on a bug report.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "properties": {
                  "status": {
                    "anyOf": [
                      {
                        "type": "string",
                        "enum": [
                          "open"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "triaged"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "in_progress"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "fixed"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "wontfix"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "duplicate"
                        ]
                      }
                    ]
                  },
                  "developer_notes": {
                    "anyOf": [
                      {
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "message"
                  ],
                  "properties": {
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/billing/verify-checkout": {
      "post": {
        "operationId": "billingVerifyCheckout",
        "summary": "Verify Stripe Checkout session",
        "tags": [
          "billing"
        ],
        "description": "Verifies a completed checkout session and creates the subscription if the webhook has not arrived yet.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "properties": {
                  "stripe_session_id": {
                    "type": "string"
                  },
                  "session_id": {
                    "type": "string"
                  },
                  "user_id": {
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "verified"
                  ],
                  "properties": {
                    "verified": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "503": {
            "description": "Service unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/billing/checkout": {
      "post": {
        "operationId": "billingCreateCheckout",
        "summary": "Create Stripe Checkout session",
        "tags": [
          "billing"
        ],
        "description": "Initiates a Stripe Checkout session for subscribing to a plan. Returns the checkout URL.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "plan_id",
                  "interval"
                ],
                "properties": {
                  "plan_id": {
                    "format": "uuid",
                    "type": "string"
                  },
                  "interval": {
                    "anyOf": [
                      {
                        "type": "string",
                        "enum": [
                          "monthly"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "annual"
                        ]
                      }
                    ]
                  },
                  "partner_code": {
                    "description": "Opaque partner referral code carried from signup (Crockford base32, 8-20 chars).",
                    "maxLength": 20,
                    "minLength": 8,
                    "pattern": "^[0-9A-HJKMNP-TV-Z]{8,20}$",
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "url"
                  ],
                  "properties": {
                    "url": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "Service unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/billing/bank-transfer/pay-now": {
      "post": {
        "operationId": "billingBankTransferPayNow",
        "summary": "Pay the annual plan now by bank transfer",
        "tags": [
          "billing"
        ],
        "description": "Pays the ANNUAL EUR plan by SEPA bank transfer: Stripe issues an open invoice with virtual-IBAN payment instructions and the subscription stays active while the funds are in transit (trust window of BANK_TRANSFER_DUE_DAYS days, then the account is blocked if unpaid). While trialing, the trial ends immediately and the existing subscription is converted to plan_id (defaults to the current plan) — a trialing subscription can switch plan via this call, not just interval; switching to a plan with lower resource caps than the team currently uses is rejected with 400 DOWNGRADE_RESOURCE_LIMIT. With no live Stripe subscription (Free after trial, or canceled) a new send_invoice subscription is created for plan_id (defaults to the current plan) — re-subscribe by bank transfer cannot go through Checkout, which rejects customer_balance in subscription mode. Only available for EUR billing countries and when the bank-transfer feature flag is enabled — otherwise 409 BANK_TRANSFER_NOT_ELIGIBLE. Idempotent: re-calling inside an open trust window returns the existing open invoice URL for the SAME plan; a different plan_id while that window is open is rejected with 409 BANK_TRANSFER_NOT_ELIGIBLE instead of silently re-serving the old invoice.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "properties": {
                  "plan_id": {
                    "format": "uuid",
                    "description": "Plan to buy (or switch to while trialing). Defaults to the current plan.",
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "invoice_url",
                    "due_date"
                  ],
                  "properties": {
                    "invoice_url": {
                      "description": "Stripe hosted invoice page carrying the bank-transfer payment instructions.",
                      "type": "string"
                    },
                    "due_date": {
                      "format": "date-time",
                      "description": "When the invoice is due (end of the bank-transfer trust window).",
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message",
                    "code",
                    "violations"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "DOWNGRADE_RESOURCE_LIMIT"
                      ]
                    },
                    "violations": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "resource",
                          "current",
                          "limit"
                        ],
                        "properties": {
                          "resource": {
                            "type": "string"
                          },
                          "current": {
                            "type": "number"
                          },
                          "limit": {
                            "type": "number"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "Conflict - resource state prevents the operation",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message",
                    "code"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "BANK_TRANSFER_NOT_ELIGIBLE"
                      ]
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "Service unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/billing/cancel": {
      "post": {
        "operationId": "billingCancelSubscription",
        "summary": "Cancel subscription",
        "tags": [
          "billing"
        ],
        "description": "Cancels the subscription. During trial: cancels at trial end. Paid: cancels at period end.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "cancel_at"
                  ],
                  "properties": {
                    "cancel_at": {
                      "format": "date-time",
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "409": {
            "description": "Conflict - resource state prevents the operation",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "Service unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/billing/reactivate": {
      "post": {
        "operationId": "billingReactivateSubscription",
        "summary": "Reactivate cancelled subscription",
        "tags": [
          "billing"
        ],
        "description": "Removes cancel_at_period_end flag to reactivate a subscription that was set to cancel.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "message"
                  ],
                  "properties": {
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "Service unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/billing/change-plan": {
      "post": {
        "operationId": "postApiV1BillingChangePlan",
        "summary": "Change subscription plan",
        "tags": [
          "billing"
        ],
        "description": "Changes the subscription to a different plan. Cooldown: max 1 downgrade per 7 days. Upgrades apply immediately; downgrades are deferred to the end of the current billing period (scheduled=true, effective_at set). Downgrades are rejected until usage fits the target plan limits.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "plan_id",
                  "interval"
                ],
                "properties": {
                  "plan_id": {
                    "format": "uuid",
                    "type": "string"
                  },
                  "interval": {
                    "anyOf": [
                      {
                        "type": "string",
                        "enum": [
                          "monthly"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "annual"
                        ]
                      }
                    ]
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "success"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "scheduled": {
                      "type": "boolean"
                    },
                    "effective_at": {
                      "format": "date-time",
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "violations": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "resource",
                          "current",
                          "limit"
                        ],
                        "properties": {
                          "resource": {
                            "type": "string"
                          },
                          "current": {
                            "type": "number"
                          },
                          "limit": {
                            "type": "number"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "409": {
            "description": "Conflict - resource state prevents the operation",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "Too many requests - rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message",
                    "next_change_at"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "next_change_at": {
                      "format": "date-time",
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "502": {
            "description": "Bad gateway - upstream provider failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "Service unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/billing/plan-change-cooldown": {
      "get": {
        "operationId": "getApiV1BillingPlanChangeCooldown",
        "summary": "Check plan change cooldown",
        "tags": [
          "billing"
        ],
        "description": "Returns whether the user can change plan and, if not, when the next change is available.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "can_change",
                    "next_change_at"
                  ],
                  "properties": {
                    "can_change": {
                      "type": "boolean"
                    },
                    "next_change_at": {
                      "anyOf": [
                        {
                          "format": "date-time",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/billing/downgrade-preflight": {
      "get": {
        "operationId": "getApiV1BillingDowngradePreflight",
        "summary": "Downgrade preflight check",
        "tags": [
          "billing"
        ],
        "description": "Read-only check of whether the team can downgrade to the given plan, or which connected resources / seats exceed that plan's caps. Reports a LIVE snapshot of quantities — it does NOT measure downstream consequences (OAuth tokens, sync history, active rules, CAPI dedup), and is not the enforcement gate: the change-plan call performs the authoritative block. Counts can drift between this check and the actual change.",
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "query",
            "name": "plan_id",
            "required": true,
            "description": "Target (lower) plan to downgrade to."
          }
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "can_downgrade",
                    "violations"
                  ],
                  "properties": {
                    "can_downgrade": {
                      "description": "True when no connected-resource or seat count exceeds the target plan caps.",
                      "type": "boolean"
                    },
                    "violations": {
                      "type": "array",
                      "items": {
                        "additionalProperties": false,
                        "type": "object",
                        "required": [
                          "resource",
                          "current",
                          "limit",
                          "excess"
                        ],
                        "properties": {
                          "resource": {
                            "description": "Category over the cap: \"ad accounts\" | \"fan pages\" | \"pixels\" | \"catalogs\" | \"team members\".",
                            "type": "string"
                          },
                          "current": {
                            "description": "Currently connected/used count for the team.",
                            "type": "number"
                          },
                          "limit": {
                            "description": "Maximum the target plan allows.",
                            "type": "number"
                          },
                          "excess": {
                            "description": "How many must be removed before the downgrade is allowed (current - limit).",
                            "type": "number"
                          }
                        }
                      }
                    },
                    "seats_carried": {
                      "description": "Purchased extra-user seats that will be carried onto the target plan (0 when none are carriable — those are then counted against the seat cap as a violation).",
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "Service unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/billing/downgrade-disconnectable": {
      "get": {
        "operationId": "getApiV1BillingDowngradeDisconnectable",
        "summary": "List disconnectable resources blocking a downgrade",
        "tags": [
          "billing"
        ],
        "description": "Read-only. For each connected-resource category that exceeds the target plan's caps, lists the team's currently-connected instances the OWNER can choose to disconnect. Granular categories (ad accounts, fan pages) carry per-item handles; pixels/catalogs are returned as non_removable (the honest block stays — no first-class single-item disconnect / Outbrain detaches the whole session). Seat (team-member) violations are omitted (not a connected resource). LIVE snapshot — the change-plan call is the authoritative gate.",
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "query",
            "name": "plan_id",
            "required": true,
            "description": "Target (lower) plan to downgrade to."
          }
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "can_downgrade",
                    "groups"
                  ],
                  "properties": {
                    "can_downgrade": {
                      "description": "True when nothing exceeds the target plan caps.",
                      "type": "boolean"
                    },
                    "groups": {
                      "type": "array",
                      "items": {
                        "additionalProperties": false,
                        "type": "object",
                        "required": [
                          "resource",
                          "current",
                          "limit",
                          "excess",
                          "capability",
                          "items"
                        ],
                        "properties": {
                          "resource": {
                            "description": "Connected-resource category that exceeds the target plan cap.",
                            "anyOf": [
                              {
                                "type": "string",
                                "enum": [
                                  "ad_accounts"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "fan_pages"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "pixels"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "catalogs"
                                ]
                              }
                            ]
                          },
                          "current": {
                            "type": "number"
                          },
                          "limit": {
                            "type": "number"
                          },
                          "excess": {
                            "description": "How many to remove (current - limit).",
                            "type": "number"
                          },
                          "capability": {
                            "description": "\"granular\" → items can be disconnected one at a time (selector). \"non_removable\" (pixels/catalogs) → no per-item disconnect; the honest block stays.",
                            "anyOf": [
                              {
                                "type": "string",
                                "enum": [
                                  "granular"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "non_removable"
                                ]
                              }
                            ]
                          },
                          "items": {
                            "description": "Team-owned connected instances; empty for non_removable categories.",
                            "type": "array",
                            "items": {
                              "additionalProperties": false,
                              "type": "object",
                              "required": [
                                "label",
                                "handle"
                              ],
                              "properties": {
                                "label": {
                                  "type": "string"
                                },
                                "handle": {
                                  "description": "Opaque handle identifying one removable connected resource (returned by the selector).",
                                  "anyOf": [
                                    {
                                      "additionalProperties": false,
                                      "type": "object",
                                      "required": [
                                        "kind",
                                        "sheet_id",
                                        "business_id",
                                        "ad_account_id"
                                      ],
                                      "properties": {
                                        "kind": {
                                          "type": "string",
                                          "enum": [
                                            "meta_ad_account"
                                          ]
                                        },
                                        "sheet_id": {
                                          "type": "string"
                                        },
                                        "business_id": {
                                          "type": "string"
                                        },
                                        "ad_account_id": {
                                          "type": "string"
                                        }
                                      }
                                    },
                                    {
                                      "additionalProperties": false,
                                      "type": "object",
                                      "required": [
                                        "kind",
                                        "sheet_id",
                                        "business_id",
                                        "fan_page_id"
                                      ],
                                      "properties": {
                                        "kind": {
                                          "type": "string",
                                          "enum": [
                                            "meta_fan_page"
                                          ]
                                        },
                                        "sheet_id": {
                                          "type": "string"
                                        },
                                        "business_id": {
                                          "type": "string"
                                        },
                                        "fan_page_id": {
                                          "type": "string"
                                        }
                                      }
                                    },
                                    {
                                      "additionalProperties": false,
                                      "type": "object",
                                      "required": [
                                        "kind",
                                        "platform",
                                        "connection_id"
                                      ],
                                      "properties": {
                                        "kind": {
                                          "type": "string",
                                          "enum": [
                                            "platform_ad_account"
                                          ]
                                        },
                                        "platform": {
                                          "maxLength": 10,
                                          "type": "string"
                                        },
                                        "connection_id": {
                                          "format": "uuid",
                                          "type": "string"
                                        }
                                      }
                                    }
                                  ]
                                }
                              }
                            }
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "Service unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/billing/disconnect-resource": {
      "post": {
        "operationId": "postApiV1BillingDisconnectResource",
        "summary": "Disconnect one owner-chosen resource and re-run the downgrade preflight",
        "tags": [
          "billing"
        ],
        "description": "Disconnects the single resource identified by `handle` (re-scoped to the caller's team via the platform's existing first-class disconnect path), then returns a fresh downgrade preflight for `plan_id`. Non-transactional by design: there is no rollback — the re-preflight is the authoritative post-state after every disconnect, so the client should always trust it over the boolean. A stale/foreign handle disconnects nothing (`disconnected:false`) and still returns a fresh preflight. WARNING: disconnecting has real downstream effects (OAuth tokens, sync history, active rules, CAPI dedup) the caller must surface.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "plan_id",
                  "handle"
                ],
                "properties": {
                  "plan_id": {
                    "format": "uuid",
                    "description": "Target (lower) plan being downgraded to.",
                    "type": "string"
                  },
                  "handle": {
                    "description": "Opaque handle identifying one removable connected resource (returned by the selector).",
                    "anyOf": [
                      {
                        "additionalProperties": false,
                        "type": "object",
                        "required": [
                          "kind",
                          "sheet_id",
                          "business_id",
                          "ad_account_id"
                        ],
                        "properties": {
                          "kind": {
                            "type": "string",
                            "enum": [
                              "meta_ad_account"
                            ]
                          },
                          "sheet_id": {
                            "type": "string"
                          },
                          "business_id": {
                            "type": "string"
                          },
                          "ad_account_id": {
                            "type": "string"
                          }
                        }
                      },
                      {
                        "additionalProperties": false,
                        "type": "object",
                        "required": [
                          "kind",
                          "sheet_id",
                          "business_id",
                          "fan_page_id"
                        ],
                        "properties": {
                          "kind": {
                            "type": "string",
                            "enum": [
                              "meta_fan_page"
                            ]
                          },
                          "sheet_id": {
                            "type": "string"
                          },
                          "business_id": {
                            "type": "string"
                          },
                          "fan_page_id": {
                            "type": "string"
                          }
                        }
                      },
                      {
                        "additionalProperties": false,
                        "type": "object",
                        "required": [
                          "kind",
                          "platform",
                          "connection_id"
                        ],
                        "properties": {
                          "kind": {
                            "type": "string",
                            "enum": [
                              "platform_ad_account"
                            ]
                          },
                          "platform": {
                            "maxLength": 10,
                            "type": "string"
                          },
                          "connection_id": {
                            "format": "uuid",
                            "type": "string"
                          }
                        }
                      }
                    ]
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "disconnected",
                    "preflight"
                  ],
                  "properties": {
                    "disconnected": {
                      "description": "True when a team-owned connected resource was actually disconnected (false = stale/foreign handle).",
                      "type": "boolean"
                    },
                    "preflight": {
                      "additionalProperties": false,
                      "type": "object",
                      "required": [
                        "can_downgrade",
                        "violations"
                      ],
                      "properties": {
                        "can_downgrade": {
                          "description": "True when no connected-resource or seat count exceeds the target plan caps.",
                          "type": "boolean"
                        },
                        "violations": {
                          "type": "array",
                          "items": {
                            "additionalProperties": false,
                            "type": "object",
                            "required": [
                              "resource",
                              "current",
                              "limit",
                              "excess"
                            ],
                            "properties": {
                              "resource": {
                                "description": "Category over the cap: \"ad accounts\" | \"fan pages\" | \"pixels\" | \"catalogs\" | \"team members\".",
                                "type": "string"
                              },
                              "current": {
                                "description": "Currently connected/used count for the team.",
                                "type": "number"
                              },
                              "limit": {
                                "description": "Maximum the target plan allows.",
                                "type": "number"
                              },
                              "excess": {
                                "description": "How many must be removed before the downgrade is allowed (current - limit).",
                                "type": "number"
                              }
                            }
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "Service unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/billing/portal": {
      "post": {
        "operationId": "postApiV1BillingPortal",
        "summary": "Create Stripe Customer Portal session",
        "tags": [
          "billing"
        ],
        "description": "Creates a Stripe Customer Portal session for managing billing. Returns the portal URL.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "url"
                  ],
                  "properties": {
                    "url": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "Service unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/billing/payment-methods": {
      "get": {
        "operationId": "billingListPaymentMethods",
        "summary": "List saved payment methods",
        "tags": [
          "billing"
        ],
        "description": "Returns the saved cards for the authenticated owner's Stripe customer (live from Stripe), each flagged with its default state and a validity status (valid/expired/expiring_soon).",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "payment_methods",
                    "has_active_subscription"
                  ],
                  "properties": {
                    "payment_methods": {
                      "type": "array",
                      "items": {
                        "additionalProperties": false,
                        "type": "object",
                        "required": [
                          "id",
                          "brand",
                          "last4",
                          "exp_month",
                          "exp_year",
                          "is_default",
                          "status"
                        ],
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "brand": {
                            "type": "string"
                          },
                          "last4": {
                            "type": "string"
                          },
                          "exp_month": {
                            "type": "integer"
                          },
                          "exp_year": {
                            "type": "integer"
                          },
                          "is_default": {
                            "type": "boolean"
                          },
                          "status": {
                            "anyOf": [
                              {
                                "type": "string",
                                "enum": [
                                  "valid"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "expired"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "expiring_soon"
                                ]
                              }
                            ]
                          }
                        }
                      }
                    },
                    "has_active_subscription": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "Service unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/billing/payment-methods/setup-intent": {
      "post": {
        "operationId": "billingCreatePaymentMethodSetupIntent",
        "summary": "Create a SetupIntent to add a card",
        "tags": [
          "billing"
        ],
        "description": "Creates an off-session SetupIntent. The frontend confirms it with Stripe.js to collect and save a new card; the card attaches to the customer automatically on confirm.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "client_secret"
                  ],
                  "properties": {
                    "client_secret": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "Service unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/billing/payment-methods/{id}": {
      "delete": {
        "operationId": "billingRemovePaymentMethod",
        "summary": "Remove a saved card",
        "tags": [
          "billing"
        ],
        "description": "Detaches a saved card. Refuses with 409 last_card if it is the only card, or 409 default_in_use if it is the default while a subscription is active. Ownership is verified before any write.",
        "parameters": [
          {
            "schema": {
              "pattern": "^pm_[A-Za-z0-9]+$",
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "ok"
                  ],
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "Conflict - resource state prevents the operation",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message",
                    "code"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "anyOf": [
                        {
                          "type": "string",
                          "enum": [
                            "last_card"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "default_in_use"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "expired_card"
                          ]
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "Service unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/billing/payment-methods/{id}/default": {
      "post": {
        "operationId": "billingSetDefaultPaymentMethod",
        "summary": "Set a card as default",
        "tags": [
          "billing"
        ],
        "description": "Sets the card as the customer's default payment method and, when a subscription is active, also as the subscription's default so renewals and off-session charges use it. Ownership is verified before any write.",
        "parameters": [
          {
            "schema": {
              "pattern": "^pm_[A-Za-z0-9]+$",
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "ok"
                  ],
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "Conflict - resource state prevents the operation",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message",
                    "code"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "anyOf": [
                        {
                          "type": "string",
                          "enum": [
                            "last_card"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "default_in_use"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "expired_card"
                          ]
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "Service unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/billing/subscription": {
      "get": {
        "operationId": "getApiV1BillingSubscription",
        "summary": "Get current subscription",
        "tags": [
          "billing"
        ],
        "description": "Returns the current subscription with plan details and usage for the authenticated user's team.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "anyOf": [
                    {
                      "type": "object",
                      "required": [
                        "id",
                        "organization_id",
                        "plan_id",
                        "status",
                        "billing_interval",
                        "current_period_start",
                        "current_period_end",
                        "trial_start",
                        "trial_end",
                        "trial_eligible",
                        "cancel_at_period_end",
                        "extra_user_slots",
                        "is_read_only",
                        "is_unlimited",
                        "has_billing_subscription",
                        "read_only_reason",
                        "billing_currency",
                        "scheduled_plan_id",
                        "scheduled_change_at",
                        "bank_transfer",
                        "plan"
                      ],
                      "properties": {
                        "id": {
                          "format": "uuid",
                          "type": "string"
                        },
                        "organization_id": {
                          "format": "uuid",
                          "type": "string"
                        },
                        "plan_id": {
                          "format": "uuid",
                          "type": "string"
                        },
                        "status": {
                          "type": "string"
                        },
                        "billing_interval": {
                          "type": "string"
                        },
                        "current_period_start": {
                          "anyOf": [
                            {
                              "format": "date-time",
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "current_period_end": {
                          "anyOf": [
                            {
                              "format": "date-time",
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "trial_start": {
                          "anyOf": [
                            {
                              "format": "date-time",
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "trial_end": {
                          "anyOf": [
                            {
                              "format": "date-time",
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "trial_eligible": {
                          "type": "boolean"
                        },
                        "cancel_at_period_end": {
                          "type": "boolean"
                        },
                        "extra_user_slots": {
                          "type": "number"
                        },
                        "is_read_only": {
                          "type": "boolean"
                        },
                        "is_unlimited": {
                          "type": "boolean"
                        },
                        "has_billing_subscription": {
                          "type": "boolean"
                        },
                        "read_only_reason": {
                          "anyOf": [
                            {
                              "type": "string",
                              "enum": [
                                "spend_exceeded"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "payment_failed"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "subscription_expired"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "demo_expired"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "canceled"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "account_deleted"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "past_due"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "unpaid"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "paused"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "incomplete"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "incomplete_expired"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "admin_suspended"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "bank_transfer_unpaid"
                              ]
                            },
                            {
                              "maxLength": 50,
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "billing_currency": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "scheduled_plan_id": {
                          "anyOf": [
                            {
                              "format": "uuid",
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "scheduled_change_at": {
                          "anyOf": [
                            {
                              "format": "date-time",
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "bank_transfer": {
                          "additionalProperties": false,
                          "type": "object",
                          "required": [
                            "eligible",
                            "pending_until"
                          ],
                          "properties": {
                            "eligible": {
                              "description": "True when the annual plan can be paid now by SEPA bank transfer: feature flag ON, a payable state (status trialing, or no live Stripe subscription / canceled for a re-subscribe), and the billing country resolves to EUR.",
                              "type": "boolean"
                            },
                            "pending_until": {
                              "description": "End of the bank-transfer trust window (access granted while funds are in transit); null when no transfer is pending.",
                              "anyOf": [
                                {
                                  "format": "date-time",
                                  "type": "string"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            }
                          }
                        },
                        "plan": {
                          "type": "object",
                          "required": [
                            "id",
                            "name",
                            "display_name",
                            "monthly_price_cents",
                            "annual_price_cents",
                            "max_users",
                            "extra_user_price_cents",
                            "max_ad_accounts",
                            "max_fan_pages",
                            "max_pixels",
                            "max_catalogs",
                            "max_ad_spend_cents",
                            "sort_order",
                            "is_published",
                            "display_currency",
                            "display_monthly_price_cents",
                            "display_annual_price_cents",
                            "data_retention_days",
                            "sync_interval_minutes",
                            "max_free_campaigns",
                            "max_workspaces",
                            "max_teams",
                            "allow_white_label",
                            "allow_multi_workspace",
                            "allow_cross_platform",
                            "allow_api_access",
                            "ai_models_tier",
                            "has_trial",
                            "trial_days"
                          ],
                          "properties": {
                            "id": {
                              "format": "uuid",
                              "type": "string"
                            },
                            "name": {
                              "type": "string"
                            },
                            "display_name": {
                              "type": "string"
                            },
                            "monthly_price_cents": {
                              "description": "Monthly price in integer minor units of currency (cents for USD/EUR).",
                              "type": "integer"
                            },
                            "annual_price_cents": {
                              "description": "Annual price in integer minor units of currency (cents for USD/EUR).",
                              "type": "integer"
                            },
                            "max_users": {
                              "description": "null = unlimited seats.",
                              "anyOf": [
                                {
                                  "type": "number"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "extra_user_price_cents": {
                              "description": "Extra user slot price in integer minor units of currency (cents for USD/EUR).",
                              "type": "integer"
                            },
                            "max_ad_accounts": {
                              "anyOf": [
                                {
                                  "type": "number"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "max_fan_pages": {
                              "anyOf": [
                                {
                                  "type": "number"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "max_pixels": {
                              "anyOf": [
                                {
                                  "type": "number"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "max_catalogs": {
                              "anyOf": [
                                {
                                  "type": "number"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "max_ad_spend_cents": {
                              "description": "Max 30-day ad spend quota in integer minor units of currency (cents for USD/EUR). Stored as Prisma Decimal and cast to integer.",
                              "anyOf": [
                                {
                                  "type": "integer"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "sort_order": {
                              "type": "number"
                            },
                            "is_published": {
                              "type": "boolean"
                            },
                            "display_currency": {
                              "type": "string"
                            },
                            "display_monthly_price_cents": {
                              "type": "integer"
                            },
                            "display_annual_price_cents": {
                              "type": "integer"
                            },
                            "data_retention_days": {
                              "anyOf": [
                                {
                                  "type": "number"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "sync_interval_minutes": {
                              "anyOf": [
                                {
                                  "type": "number"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "max_free_campaigns": {
                              "anyOf": [
                                {
                                  "type": "number"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "max_workspaces": {
                              "anyOf": [
                                {
                                  "type": "number"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "max_teams": {
                              "anyOf": [
                                {
                                  "type": "number"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "allow_white_label": {
                              "type": "boolean"
                            },
                            "allow_multi_workspace": {
                              "type": "boolean"
                            },
                            "allow_cross_platform": {
                              "type": "boolean"
                            },
                            "allow_api_access": {
                              "type": "boolean"
                            },
                            "ai_models_tier": {
                              "type": "string"
                            },
                            "has_trial": {
                              "type": "boolean"
                            },
                            "trial_days": {
                              "type": "number"
                            },
                            "max_api_keys": {
                              "anyOf": [
                                {
                                  "type": "number"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "max_scheduled_reports": {
                              "anyOf": [
                                {
                                  "type": "number"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "max_bulk_launch_size": {
                              "anyOf": [
                                {
                                  "type": "number"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "max_competitor_watchlists": {
                              "anyOf": [
                                {
                                  "type": "number"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "max_rule_ad_accounts": {
                              "anyOf": [
                                {
                                  "type": "number"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            }
                          }
                        }
                      }
                    },
                    {
                      "type": "null"
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/billing/plans": {
      "get": {
        "operationId": "getApiV1BillingPlans",
        "summary": "List available plans",
        "tags": [
          "billing"
        ],
        "description": "Returns all active plans sorted by sort_order.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "currency",
                    "items"
                  ],
                  "properties": {
                    "currency": {
                      "description": "The currency resolved for this user (drives the display_* fields).",
                      "type": "string"
                    },
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "id",
                          "name",
                          "display_name",
                          "monthly_price_cents",
                          "annual_price_cents",
                          "max_users",
                          "extra_user_price_cents",
                          "max_ad_accounts",
                          "max_fan_pages",
                          "max_pixels",
                          "max_catalogs",
                          "max_ad_spend_cents",
                          "sort_order",
                          "is_published",
                          "display_currency",
                          "display_monthly_price_cents",
                          "display_annual_price_cents",
                          "data_retention_days",
                          "sync_interval_minutes",
                          "max_free_campaigns",
                          "max_workspaces",
                          "max_teams",
                          "allow_white_label",
                          "allow_multi_workspace",
                          "allow_cross_platform",
                          "allow_api_access",
                          "ai_models_tier",
                          "has_trial",
                          "trial_days"
                        ],
                        "properties": {
                          "id": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "name": {
                            "type": "string"
                          },
                          "display_name": {
                            "type": "string"
                          },
                          "monthly_price_cents": {
                            "description": "Monthly price in integer minor units of currency (cents for USD/EUR).",
                            "type": "integer"
                          },
                          "annual_price_cents": {
                            "description": "Annual price in integer minor units of currency (cents for USD/EUR).",
                            "type": "integer"
                          },
                          "max_users": {
                            "description": "null = unlimited seats.",
                            "anyOf": [
                              {
                                "type": "number"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "extra_user_price_cents": {
                            "description": "Extra user slot price in integer minor units of currency (cents for USD/EUR).",
                            "type": "integer"
                          },
                          "max_ad_accounts": {
                            "anyOf": [
                              {
                                "type": "number"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "max_fan_pages": {
                            "anyOf": [
                              {
                                "type": "number"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "max_pixels": {
                            "anyOf": [
                              {
                                "type": "number"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "max_catalogs": {
                            "anyOf": [
                              {
                                "type": "number"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "max_ad_spend_cents": {
                            "description": "Max 30-day ad spend quota in integer minor units of currency (cents for USD/EUR). Stored as Prisma Decimal and cast to integer.",
                            "anyOf": [
                              {
                                "type": "integer"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "sort_order": {
                            "type": "number"
                          },
                          "is_published": {
                            "type": "boolean"
                          },
                          "display_currency": {
                            "type": "string"
                          },
                          "display_monthly_price_cents": {
                            "type": "integer"
                          },
                          "display_annual_price_cents": {
                            "type": "integer"
                          },
                          "data_retention_days": {
                            "anyOf": [
                              {
                                "type": "number"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "sync_interval_minutes": {
                            "anyOf": [
                              {
                                "type": "number"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "max_free_campaigns": {
                            "anyOf": [
                              {
                                "type": "number"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "max_workspaces": {
                            "anyOf": [
                              {
                                "type": "number"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "max_teams": {
                            "anyOf": [
                              {
                                "type": "number"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "allow_white_label": {
                            "type": "boolean"
                          },
                          "allow_multi_workspace": {
                            "type": "boolean"
                          },
                          "allow_cross_platform": {
                            "type": "boolean"
                          },
                          "allow_api_access": {
                            "type": "boolean"
                          },
                          "ai_models_tier": {
                            "type": "string"
                          },
                          "has_trial": {
                            "type": "boolean"
                          },
                          "trial_days": {
                            "type": "number"
                          },
                          "max_api_keys": {
                            "anyOf": [
                              {
                                "type": "number"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "max_scheduled_reports": {
                            "anyOf": [
                              {
                                "type": "number"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "max_bulk_launch_size": {
                            "anyOf": [
                              {
                                "type": "number"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "max_competitor_watchlists": {
                            "anyOf": [
                              {
                                "type": "number"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "max_rule_ad_accounts": {
                            "anyOf": [
                              {
                                "type": "number"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/billing/upgrade-from-demo": {
      "post": {
        "operationId": "postApiV1BillingUpgradeFromDemo",
        "summary": "Upgrade from demo plan",
        "tags": [
          "billing"
        ],
        "description": "Deletes the demo subscription record so the user can subscribe to a paid plan.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "success"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/billing/payments": {
      "get": {
        "operationId": "getApiV1BillingPayments",
        "summary": "List payment history",
        "tags": [
          "billing"
        ],
        "description": "Returns the payment history for the authenticated user's subscription.",
        "parameters": [
          {
            "schema": {
              "minimum": 1,
              "maximum": 100,
              "type": "integer"
            },
            "in": "query",
            "name": "limit",
            "required": false
          }
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "items"
                  ],
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "id",
                          "amount_cents",
                          "currency",
                          "status",
                          "description",
                          "invoice_pdf_url",
                          "period_start",
                          "period_end",
                          "created_at"
                        ],
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "amount_cents": {
                            "description": "Amount paid in integer minor units of currency (cents for USD/EUR). Sourced from Stripe amount_paid.",
                            "type": "integer"
                          },
                          "currency": {
                            "description": "ISO 4217 currency code (uppercase), free-text passthrough. Sourced from the Stripe invoice currency (uppercased) or, on DB fallback, payment_history.currency (VarChar(3), uppercased-on-write). Runtime accepts any 3-letter code.",
                            "type": "string"
                          },
                          "status": {
                            "description": "Invoice/payment status. 'draft'|'open'|'paid'|'void'|'uncollectible' mirror Stripe invoice.status; 'partially_refunded'|'refunded'|'disputed' are derived from persisted net-revenue reversal rows since Stripe keeps invoice.status='paid' after a refund/dispute.",
                            "anyOf": [
                              {
                                "type": "string",
                                "enum": [
                                  "draft"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "open"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "paid"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "void"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "uncollectible"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "partially_refunded"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "refunded"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "disputed"
                                ]
                              },
                              {
                                "maxLength": 30,
                                "type": "string"
                              }
                            ]
                          },
                          "amount_refunded": {
                            "minimum": 0,
                            "description": "Amount refunded/disputed back in integer minor units, derived from the net-revenue reversal row keyed by stripe_invoice_id. Absent/0 when no reversal applies.",
                            "type": "integer"
                          },
                          "description": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "invoice_pdf_url": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "period_start": {
                            "anyOf": [
                              {
                                "format": "date-time",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "period_end": {
                            "anyOf": [
                              {
                                "format": "date-time",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "created_at": {
                            "format": "date-time",
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/billing/usage": {
      "get": {
        "operationId": "getApiV1BillingUsage",
        "summary": "Get usage snapshot",
        "tags": [
          "billing"
        ],
        "description": "Returns the usage snapshot for the authenticated user's team.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "anyOf": [
                    {
                      "type": "object",
                      "required": [
                        "id",
                        "organization_id",
                        "connected_ad_accounts",
                        "connected_fan_pages",
                        "connected_pixels",
                        "connected_catalogs",
                        "workspace_count",
                        "team_member_count",
                        "rolling_30d_spend_cents",
                        "spend_currency",
                        "spend_percentage",
                        "computed_at"
                      ],
                      "properties": {
                        "id": {
                          "format": "uuid",
                          "type": "string"
                        },
                        "organization_id": {
                          "format": "uuid",
                          "type": "string"
                        },
                        "connected_ad_accounts": {
                          "type": "number"
                        },
                        "connected_fan_pages": {
                          "type": "number"
                        },
                        "connected_pixels": {
                          "type": "number"
                        },
                        "connected_catalogs": {
                          "type": "number"
                        },
                        "workspace_count": {
                          "type": "number"
                        },
                        "team_member_count": {
                          "type": "number"
                        },
                        "scheduled_report_count": {
                          "type": "number"
                        },
                        "competitor_watchlist_count": {
                          "type": "number"
                        },
                        "rolling_30d_spend_cents": {
                          "description": "Rolling 30-day ad spend in integer minor units of currency (cents for USD/EUR). Stored as Prisma Decimal and cast to integer.",
                          "type": "integer"
                        },
                        "spend_currency": {
                          "description": "ISO 4217 currency code of ad spend, free-text passthrough from the connected ad account (any currency). Runtime accepts any 3-letter code.",
                          "type": "string"
                        },
                        "spend_percentage": {
                          "description": "Percentage of plan quota consumed (0-100+), two decimals.",
                          "type": "number"
                        },
                        "computed_at": {
                          "format": "date-time",
                          "type": "string"
                        }
                      }
                    },
                    {
                      "type": "null"
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/billing/organization-info": {
      "get": {
        "operationId": "billingGetOrganizationInfo",
        "summary": "Get organization billing profile",
        "tags": [
          "billing"
        ],
        "description": "Returns the billing owner's organization billing/fiscal profile (legal name, VAT, billing email and address) used on invoices.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "anyOf": [
                    {
                      "additionalProperties": false,
                      "type": "object",
                      "required": [
                        "legal_name",
                        "vat_number",
                        "billing_email",
                        "billing_address",
                        "billing_city",
                        "billing_zip",
                        "billing_country"
                      ],
                      "properties": {
                        "legal_name": {
                          "description": "Legal/company name (ragione sociale).",
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "vat_number": {
                          "description": "VAT / Tax ID / registration number.",
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "billing_email": {
                          "description": "Invoice recipient email.",
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "billing_address": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "billing_city": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "billing_zip": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "billing_country": {
                          "description": "ISO 3166-1 alpha-2 country code.",
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        }
                      }
                    },
                    {
                      "type": "null"
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      },
      "patch": {
        "operationId": "billingUpdateOrganizationInfo",
        "summary": "Update organization billing profile",
        "tags": [
          "billing"
        ],
        "description": "Updates the billing/fiscal profile on the billing owner organization. Accepts any subset of fields; each is nullable to clear it. Values are trimmed and the country code is uppercased.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "properties": {
                  "legal_name": {
                    "anyOf": [
                      {
                        "maxLength": 255,
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "vat_number": {
                    "anyOf": [
                      {
                        "maxLength": 100,
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "billing_email": {
                    "anyOf": [
                      {
                        "maxLength": 255,
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "billing_address": {
                    "anyOf": [
                      {
                        "maxLength": 500,
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "billing_city": {
                    "anyOf": [
                      {
                        "maxLength": 255,
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "billing_zip": {
                    "anyOf": [
                      {
                        "maxLength": 20,
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "billing_country": {
                    "anyOf": [
                      {
                        "maxLength": 100,
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "legal_name",
                    "vat_number",
                    "billing_email",
                    "billing_address",
                    "billing_city",
                    "billing_zip",
                    "billing_country"
                  ],
                  "properties": {
                    "legal_name": {
                      "description": "Legal/company name (ragione sociale).",
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "vat_number": {
                      "description": "VAT / Tax ID / registration number.",
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "billing_email": {
                      "description": "Invoice recipient email.",
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "billing_address": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "billing_city": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "billing_zip": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "billing_country": {
                      "description": "ISO 3166-1 alpha-2 country code.",
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/billing/extra-users": {
      "post": {
        "operationId": "postApiV1BillingExtraUsers",
        "summary": "Purchase extra user slots",
        "tags": [
          "billing"
        ],
        "description": "Adds extra user slots to the current subscription via Stripe.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "quantity"
                ],
                "properties": {
                  "quantity": {
                    "minimum": 1,
                    "maximum": 25,
                    "type": "integer"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "message"
                  ],
                  "properties": {
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "409": {
            "description": "Conflict - resource state prevents the operation",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "Too many requests - rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "502": {
            "description": "Bad gateway - upstream provider failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "Service unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      },
      "delete": {
        "operationId": "deleteApiV1BillingExtraUsers",
        "summary": "Remove extra user slots",
        "tags": [
          "billing"
        ],
        "description": "Removes extra user slots from the current subscription.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "quantity"
                ],
                "properties": {
                  "quantity": {
                    "minimum": 1,
                    "maximum": 25,
                    "type": "integer"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "message"
                  ],
                  "properties": {
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "409": {
            "description": "Conflict - resource state prevents the operation",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "Service unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/briefings/{briefingId}/brief": {
      "get": {
        "operationId": "getApiV1BriefingsByBriefingIdBrief",
        "summary": "Get active brief for a briefing",
        "tags": [
          "campaign-by-context"
        ],
        "description": "Returns the active brief read model for a briefing workspace after validating ownership of the underlying chat project.",
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "briefingId",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "id",
                    "project_id",
                    "project_name",
                    "status",
                    "version",
                    "schema_version",
                    "brief",
                    "coverage_score",
                    "coverage_threshold",
                    "dialog_stage",
                    "missing_fields",
                    "tool_scope",
                    "section_statuses",
                    "evidence_summary",
                    "review_ready",
                    "scope_context",
                    "scope_type",
                    "scope_brand_name",
                    "resource_selections",
                    "created_at",
                    "updated_at",
                    "completed_at"
                  ],
                  "properties": {
                    "id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "project_id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "project_name": {
                      "type": "string"
                    },
                    "status": {
                      "type": "string"
                    },
                    "version": {
                      "minimum": 1,
                      "type": "integer"
                    },
                    "schema_version": {
                      "type": "string"
                    },
                    "brief": {
                      "description": "JSON object with nested arrays and objects.",
                      "type": "object",
                      "additionalProperties": {
                        "$comment": "json-value",
                        "description": "Arbitrary JSON value with nested arrays and objects."
                      }
                    },
                    "coverage_score": {
                      "type": "number"
                    },
                    "coverage_threshold": {
                      "type": "number"
                    },
                    "dialog_stage": {
                      "type": "string"
                    },
                    "missing_fields": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "tool_scope": {
                      "anyOf": [
                        {
                          "type": "array",
                          "items": {
                            "type": "string"
                          }
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "section_statuses": {
                      "type": "object",
                      "additionalProperties": {
                        "type": "string"
                      }
                    },
                    "evidence_summary": {
                      "description": "JSON object with nested arrays and objects.",
                      "type": "object",
                      "additionalProperties": {
                        "$comment": "json-value",
                        "description": "Arbitrary JSON value with nested arrays and objects."
                      }
                    },
                    "review_ready": {
                      "type": "boolean"
                    },
                    "scope_context": {
                      "description": "JSON object with nested arrays and objects.",
                      "type": "object",
                      "additionalProperties": {
                        "$comment": "json-value",
                        "description": "Arbitrary JSON value with nested arrays and objects."
                      }
                    },
                    "scope_type": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "scope_brand_name": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "resource_selections": {
                      "description": "JSON object with nested arrays and objects.",
                      "type": "object",
                      "additionalProperties": {
                        "$comment": "json-value",
                        "description": "Arbitrary JSON value with nested arrays and objects."
                      }
                    },
                    "created_at": {
                      "format": "date-time",
                      "type": "string"
                    },
                    "updated_at": {
                      "format": "date-time",
                      "type": "string"
                    },
                    "completed_at": {
                      "anyOf": [
                        {
                          "format": "date-time",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "Conflict - resource state prevents the operation",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "postApiV1BriefingsByBriefingIdBrief",
        "summary": "Create or get active brief for a briefing",
        "tags": [
          "campaign-by-context"
        ],
        "description": "Initializes the active Campaign by Context brief for a briefing workspace, or returns the existing read model when it already exists.",
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "briefingId",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "id",
                    "project_id",
                    "project_name",
                    "status",
                    "version",
                    "schema_version",
                    "brief",
                    "coverage_score",
                    "coverage_threshold",
                    "dialog_stage",
                    "missing_fields",
                    "tool_scope",
                    "section_statuses",
                    "evidence_summary",
                    "review_ready",
                    "scope_context",
                    "scope_type",
                    "scope_brand_name",
                    "resource_selections",
                    "created_at",
                    "updated_at",
                    "completed_at"
                  ],
                  "properties": {
                    "id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "project_id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "project_name": {
                      "type": "string"
                    },
                    "status": {
                      "type": "string"
                    },
                    "version": {
                      "minimum": 1,
                      "type": "integer"
                    },
                    "schema_version": {
                      "type": "string"
                    },
                    "brief": {
                      "description": "JSON object with nested arrays and objects.",
                      "type": "object",
                      "additionalProperties": {
                        "$comment": "json-value",
                        "description": "Arbitrary JSON value with nested arrays and objects."
                      }
                    },
                    "coverage_score": {
                      "type": "number"
                    },
                    "coverage_threshold": {
                      "type": "number"
                    },
                    "dialog_stage": {
                      "type": "string"
                    },
                    "missing_fields": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "tool_scope": {
                      "anyOf": [
                        {
                          "type": "array",
                          "items": {
                            "type": "string"
                          }
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "section_statuses": {
                      "type": "object",
                      "additionalProperties": {
                        "type": "string"
                      }
                    },
                    "evidence_summary": {
                      "description": "JSON object with nested arrays and objects.",
                      "type": "object",
                      "additionalProperties": {
                        "$comment": "json-value",
                        "description": "Arbitrary JSON value with nested arrays and objects."
                      }
                    },
                    "review_ready": {
                      "type": "boolean"
                    },
                    "scope_context": {
                      "description": "JSON object with nested arrays and objects.",
                      "type": "object",
                      "additionalProperties": {
                        "$comment": "json-value",
                        "description": "Arbitrary JSON value with nested arrays and objects."
                      }
                    },
                    "scope_type": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "scope_brand_name": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "resource_selections": {
                      "description": "JSON object with nested arrays and objects.",
                      "type": "object",
                      "additionalProperties": {
                        "$comment": "json-value",
                        "description": "Arbitrary JSON value with nested arrays and objects."
                      }
                    },
                    "created_at": {
                      "format": "date-time",
                      "type": "string"
                    },
                    "updated_at": {
                      "format": "date-time",
                      "type": "string"
                    },
                    "completed_at": {
                      "anyOf": [
                        {
                          "format": "date-time",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "Conflict - resource state prevents the operation",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      },
      "patch": {
        "operationId": "patchApiV1BriefingsByBriefingIdBrief",
        "summary": "Update brief sections via patch model",
        "tags": [
          "campaign-by-context"
        ],
        "description": "Applies an optimistic-locking section patch to the canonical brief JSON and returns the updated read model.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "expected_version",
                  "section",
                  "payload"
                ],
                "properties": {
                  "expected_version": {
                    "minimum": 1,
                    "type": "integer"
                  },
                  "section": {
                    "type": "string"
                  },
                  "payload": {
                    "type": "object",
                    "additionalProperties": {
                      "$comment": "json-value",
                      "description": "Arbitrary JSON value with nested arrays and objects."
                    }
                  },
                  "source_type": {
                    "anyOf": [
                      {
                        "type": "string",
                        "enum": [
                          "user_declared"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "document_grounded"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "ai_inferred"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "manual_edit"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "tracker_data"
                        ]
                      }
                    ]
                  },
                  "source_refs": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  },
                  "confidence": {
                    "minimum": 0,
                    "maximum": 1,
                    "type": "number"
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "briefingId",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "id",
                    "project_id",
                    "project_name",
                    "status",
                    "version",
                    "schema_version",
                    "brief",
                    "coverage_score",
                    "coverage_threshold",
                    "dialog_stage",
                    "missing_fields",
                    "tool_scope",
                    "section_statuses",
                    "evidence_summary",
                    "review_ready",
                    "scope_context",
                    "scope_type",
                    "scope_brand_name",
                    "resource_selections",
                    "created_at",
                    "updated_at",
                    "completed_at"
                  ],
                  "properties": {
                    "id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "project_id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "project_name": {
                      "type": "string"
                    },
                    "status": {
                      "type": "string"
                    },
                    "version": {
                      "minimum": 1,
                      "type": "integer"
                    },
                    "schema_version": {
                      "type": "string"
                    },
                    "brief": {
                      "description": "JSON object with nested arrays and objects.",
                      "type": "object",
                      "additionalProperties": {
                        "$comment": "json-value",
                        "description": "Arbitrary JSON value with nested arrays and objects."
                      }
                    },
                    "coverage_score": {
                      "type": "number"
                    },
                    "coverage_threshold": {
                      "type": "number"
                    },
                    "dialog_stage": {
                      "type": "string"
                    },
                    "missing_fields": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "tool_scope": {
                      "anyOf": [
                        {
                          "type": "array",
                          "items": {
                            "type": "string"
                          }
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "section_statuses": {
                      "type": "object",
                      "additionalProperties": {
                        "type": "string"
                      }
                    },
                    "evidence_summary": {
                      "description": "JSON object with nested arrays and objects.",
                      "type": "object",
                      "additionalProperties": {
                        "$comment": "json-value",
                        "description": "Arbitrary JSON value with nested arrays and objects."
                      }
                    },
                    "review_ready": {
                      "type": "boolean"
                    },
                    "scope_context": {
                      "description": "JSON object with nested arrays and objects.",
                      "type": "object",
                      "additionalProperties": {
                        "$comment": "json-value",
                        "description": "Arbitrary JSON value with nested arrays and objects."
                      }
                    },
                    "scope_type": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "scope_brand_name": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "resource_selections": {
                      "description": "JSON object with nested arrays and objects.",
                      "type": "object",
                      "additionalProperties": {
                        "$comment": "json-value",
                        "description": "Arbitrary JSON value with nested arrays and objects."
                      }
                    },
                    "created_at": {
                      "format": "date-time",
                      "type": "string"
                    },
                    "updated_at": {
                      "format": "date-time",
                      "type": "string"
                    },
                    "completed_at": {
                      "anyOf": [
                        {
                          "format": "date-time",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "Conflict - resource state prevents the operation",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/briefings/{briefingId}/brief/tool-scope": {
      "patch": {
        "operationId": "patchApiV1BriefingsByBriefingIdBriefToolScope",
        "summary": "Update enabled Campaign by Context context tool scopes",
        "tags": [
          "campaign-by-context"
        ],
        "description": "Replaces the allowed tool scope for the brief workspace and returns the updated brief read model.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "tool_scope"
                ],
                "properties": {
                  "tool_scope": {
                    "maxItems": 20,
                    "type": "array",
                    "items": {
                      "maxLength": 64,
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "briefingId",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "id",
                    "project_id",
                    "project_name",
                    "status",
                    "version",
                    "schema_version",
                    "brief",
                    "coverage_score",
                    "coverage_threshold",
                    "dialog_stage",
                    "missing_fields",
                    "tool_scope",
                    "section_statuses",
                    "evidence_summary",
                    "review_ready",
                    "scope_context",
                    "scope_type",
                    "scope_brand_name",
                    "resource_selections",
                    "created_at",
                    "updated_at",
                    "completed_at"
                  ],
                  "properties": {
                    "id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "project_id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "project_name": {
                      "type": "string"
                    },
                    "status": {
                      "type": "string"
                    },
                    "version": {
                      "minimum": 1,
                      "type": "integer"
                    },
                    "schema_version": {
                      "type": "string"
                    },
                    "brief": {
                      "description": "JSON object with nested arrays and objects.",
                      "type": "object",
                      "additionalProperties": {
                        "$comment": "json-value",
                        "description": "Arbitrary JSON value with nested arrays and objects."
                      }
                    },
                    "coverage_score": {
                      "type": "number"
                    },
                    "coverage_threshold": {
                      "type": "number"
                    },
                    "dialog_stage": {
                      "type": "string"
                    },
                    "missing_fields": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "tool_scope": {
                      "anyOf": [
                        {
                          "type": "array",
                          "items": {
                            "type": "string"
                          }
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "section_statuses": {
                      "type": "object",
                      "additionalProperties": {
                        "type": "string"
                      }
                    },
                    "evidence_summary": {
                      "description": "JSON object with nested arrays and objects.",
                      "type": "object",
                      "additionalProperties": {
                        "$comment": "json-value",
                        "description": "Arbitrary JSON value with nested arrays and objects."
                      }
                    },
                    "review_ready": {
                      "type": "boolean"
                    },
                    "scope_context": {
                      "description": "JSON object with nested arrays and objects.",
                      "type": "object",
                      "additionalProperties": {
                        "$comment": "json-value",
                        "description": "Arbitrary JSON value with nested arrays and objects."
                      }
                    },
                    "scope_type": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "scope_brand_name": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "resource_selections": {
                      "description": "JSON object with nested arrays and objects.",
                      "type": "object",
                      "additionalProperties": {
                        "$comment": "json-value",
                        "description": "Arbitrary JSON value with nested arrays and objects."
                      }
                    },
                    "created_at": {
                      "format": "date-time",
                      "type": "string"
                    },
                    "updated_at": {
                      "format": "date-time",
                      "type": "string"
                    },
                    "completed_at": {
                      "anyOf": [
                        {
                          "format": "date-time",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "Conflict - resource state prevents the operation",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/briefings/{briefingId}/brief/resource-selections": {
      "patch": {
        "operationId": "patchApiV1BriefingsByBriefingIdBriefResourceSelections",
        "summary": "Replace the brief context resource selections (connected platforms, assets, catalogs)",
        "tags": [
          "campaign-by-context"
        ],
        "description": "Stores the selected connected resources for the brief context and returns the updated brief read model.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "resource_selections"
                ],
                "properties": {
                  "resource_selections": {
                    "description": "JSON object with nested arrays and objects.",
                    "type": "object",
                    "additionalProperties": {
                      "$comment": "json-value",
                      "description": "Arbitrary JSON value with nested arrays and objects."
                    }
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "briefingId",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "id",
                    "project_id",
                    "project_name",
                    "status",
                    "version",
                    "schema_version",
                    "brief",
                    "coverage_score",
                    "coverage_threshold",
                    "dialog_stage",
                    "missing_fields",
                    "tool_scope",
                    "section_statuses",
                    "evidence_summary",
                    "review_ready",
                    "scope_context",
                    "scope_type",
                    "scope_brand_name",
                    "resource_selections",
                    "created_at",
                    "updated_at",
                    "completed_at"
                  ],
                  "properties": {
                    "id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "project_id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "project_name": {
                      "type": "string"
                    },
                    "status": {
                      "type": "string"
                    },
                    "version": {
                      "minimum": 1,
                      "type": "integer"
                    },
                    "schema_version": {
                      "type": "string"
                    },
                    "brief": {
                      "description": "JSON object with nested arrays and objects.",
                      "type": "object",
                      "additionalProperties": {
                        "$comment": "json-value",
                        "description": "Arbitrary JSON value with nested arrays and objects."
                      }
                    },
                    "coverage_score": {
                      "type": "number"
                    },
                    "coverage_threshold": {
                      "type": "number"
                    },
                    "dialog_stage": {
                      "type": "string"
                    },
                    "missing_fields": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "tool_scope": {
                      "anyOf": [
                        {
                          "type": "array",
                          "items": {
                            "type": "string"
                          }
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "section_statuses": {
                      "type": "object",
                      "additionalProperties": {
                        "type": "string"
                      }
                    },
                    "evidence_summary": {
                      "description": "JSON object with nested arrays and objects.",
                      "type": "object",
                      "additionalProperties": {
                        "$comment": "json-value",
                        "description": "Arbitrary JSON value with nested arrays and objects."
                      }
                    },
                    "review_ready": {
                      "type": "boolean"
                    },
                    "scope_context": {
                      "description": "JSON object with nested arrays and objects.",
                      "type": "object",
                      "additionalProperties": {
                        "$comment": "json-value",
                        "description": "Arbitrary JSON value with nested arrays and objects."
                      }
                    },
                    "scope_type": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "scope_brand_name": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "resource_selections": {
                      "description": "JSON object with nested arrays and objects.",
                      "type": "object",
                      "additionalProperties": {
                        "$comment": "json-value",
                        "description": "Arbitrary JSON value with nested arrays and objects."
                      }
                    },
                    "created_at": {
                      "format": "date-time",
                      "type": "string"
                    },
                    "updated_at": {
                      "format": "date-time",
                      "type": "string"
                    },
                    "completed_at": {
                      "anyOf": [
                        {
                          "format": "date-time",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "Conflict - resource state prevents the operation",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/briefings/{briefingId}/brief/recalculate-coverage": {
      "post": {
        "operationId": "postApiV1BriefingsByBriefingIdBriefRecalculateCoverage",
        "summary": "Recalculate brief coverage score",
        "tags": [
          "campaign-by-context"
        ],
        "description": "Recomputes coverage and missing-field metadata from the current canonical brief JSON and returns the updated read model.",
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "briefingId",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "id",
                    "project_id",
                    "project_name",
                    "status",
                    "version",
                    "schema_version",
                    "brief",
                    "coverage_score",
                    "coverage_threshold",
                    "dialog_stage",
                    "missing_fields",
                    "tool_scope",
                    "section_statuses",
                    "evidence_summary",
                    "review_ready",
                    "scope_context",
                    "scope_type",
                    "scope_brand_name",
                    "resource_selections",
                    "created_at",
                    "updated_at",
                    "completed_at"
                  ],
                  "properties": {
                    "id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "project_id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "project_name": {
                      "type": "string"
                    },
                    "status": {
                      "type": "string"
                    },
                    "version": {
                      "minimum": 1,
                      "type": "integer"
                    },
                    "schema_version": {
                      "type": "string"
                    },
                    "brief": {
                      "description": "JSON object with nested arrays and objects.",
                      "type": "object",
                      "additionalProperties": {
                        "$comment": "json-value",
                        "description": "Arbitrary JSON value with nested arrays and objects."
                      }
                    },
                    "coverage_score": {
                      "type": "number"
                    },
                    "coverage_threshold": {
                      "type": "number"
                    },
                    "dialog_stage": {
                      "type": "string"
                    },
                    "missing_fields": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "tool_scope": {
                      "anyOf": [
                        {
                          "type": "array",
                          "items": {
                            "type": "string"
                          }
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "section_statuses": {
                      "type": "object",
                      "additionalProperties": {
                        "type": "string"
                      }
                    },
                    "evidence_summary": {
                      "description": "JSON object with nested arrays and objects.",
                      "type": "object",
                      "additionalProperties": {
                        "$comment": "json-value",
                        "description": "Arbitrary JSON value with nested arrays and objects."
                      }
                    },
                    "review_ready": {
                      "type": "boolean"
                    },
                    "scope_context": {
                      "description": "JSON object with nested arrays and objects.",
                      "type": "object",
                      "additionalProperties": {
                        "$comment": "json-value",
                        "description": "Arbitrary JSON value with nested arrays and objects."
                      }
                    },
                    "scope_type": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "scope_brand_name": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "resource_selections": {
                      "description": "JSON object with nested arrays and objects.",
                      "type": "object",
                      "additionalProperties": {
                        "$comment": "json-value",
                        "description": "Arbitrary JSON value with nested arrays and objects."
                      }
                    },
                    "created_at": {
                      "format": "date-time",
                      "type": "string"
                    },
                    "updated_at": {
                      "format": "date-time",
                      "type": "string"
                    },
                    "completed_at": {
                      "anyOf": [
                        {
                          "format": "date-time",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "Conflict - resource state prevents the operation",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/briefings/{briefingId}/brief/complete": {
      "post": {
        "operationId": "postApiV1BriefingsByBriefingIdBriefComplete",
        "summary": "Complete brief (from DRAFT) and generate signed handoff artifact",
        "tags": [
          "campaign-by-context"
        ],
        "description": "Transitions a draft brief to completed when coverage gates pass, generates the signed handoff artifact, and returns the completed read model.",
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "briefingId",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "id",
                    "project_id",
                    "project_name",
                    "status",
                    "version",
                    "schema_version",
                    "brief",
                    "coverage_score",
                    "coverage_threshold",
                    "dialog_stage",
                    "missing_fields",
                    "tool_scope",
                    "section_statuses",
                    "evidence_summary",
                    "review_ready",
                    "scope_context",
                    "scope_type",
                    "scope_brand_name",
                    "resource_selections",
                    "created_at",
                    "updated_at",
                    "completed_at"
                  ],
                  "properties": {
                    "id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "project_id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "project_name": {
                      "type": "string"
                    },
                    "status": {
                      "type": "string"
                    },
                    "version": {
                      "minimum": 1,
                      "type": "integer"
                    },
                    "schema_version": {
                      "type": "string"
                    },
                    "brief": {
                      "description": "JSON object with nested arrays and objects.",
                      "type": "object",
                      "additionalProperties": {
                        "$comment": "json-value",
                        "description": "Arbitrary JSON value with nested arrays and objects."
                      }
                    },
                    "coverage_score": {
                      "type": "number"
                    },
                    "coverage_threshold": {
                      "type": "number"
                    },
                    "dialog_stage": {
                      "type": "string"
                    },
                    "missing_fields": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "tool_scope": {
                      "anyOf": [
                        {
                          "type": "array",
                          "items": {
                            "type": "string"
                          }
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "section_statuses": {
                      "type": "object",
                      "additionalProperties": {
                        "type": "string"
                      }
                    },
                    "evidence_summary": {
                      "description": "JSON object with nested arrays and objects.",
                      "type": "object",
                      "additionalProperties": {
                        "$comment": "json-value",
                        "description": "Arbitrary JSON value with nested arrays and objects."
                      }
                    },
                    "review_ready": {
                      "type": "boolean"
                    },
                    "scope_context": {
                      "description": "JSON object with nested arrays and objects.",
                      "type": "object",
                      "additionalProperties": {
                        "$comment": "json-value",
                        "description": "Arbitrary JSON value with nested arrays and objects."
                      }
                    },
                    "scope_type": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "scope_brand_name": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "resource_selections": {
                      "description": "JSON object with nested arrays and objects.",
                      "type": "object",
                      "additionalProperties": {
                        "$comment": "json-value",
                        "description": "Arbitrary JSON value with nested arrays and objects."
                      }
                    },
                    "created_at": {
                      "format": "date-time",
                      "type": "string"
                    },
                    "updated_at": {
                      "format": "date-time",
                      "type": "string"
                    },
                    "completed_at": {
                      "anyOf": [
                        {
                          "format": "date-time",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "Conflict - resource state prevents the operation",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/briefings/{briefingId}/brief/assemble-campaign": {
      "post": {
        "operationId": "postApiV1BriefingsByBriefingIdBriefAssembleCampaign",
        "summary": "Assemble a campaign draft from the brief",
        "tags": [
          "campaign-by-context"
        ],
        "description": "Builds a canonical Meta campaign from the brief (one ad set per audience segment, one ad per creative concept), saves it as a PAUSED draft in the campaign editor, and reports whatever still blocks publishing. Never publishes.",
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "briefingId",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "draft_id",
                    "ad_set_count",
                    "ad_count",
                    "ready_to_publish",
                    "blocking_issues"
                  ],
                  "properties": {
                    "draft_id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "ad_set_count": {
                      "minimum": 0,
                      "type": "integer"
                    },
                    "ad_count": {
                      "minimum": 0,
                      "type": "integer"
                    },
                    "ready_to_publish": {
                      "type": "boolean"
                    },
                    "blocking_issues": {
                      "type": "array",
                      "items": {
                        "additionalProperties": true,
                        "type": "object",
                        "required": [
                          "code",
                          "fieldPath",
                          "message",
                          "severity"
                        ],
                        "properties": {
                          "code": {
                            "type": "string"
                          },
                          "fieldPath": {
                            "type": "string"
                          },
                          "message": {
                            "type": "string"
                          },
                          "severity": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/briefings/{briefingId}/brief/reopen": {
      "post": {
        "operationId": "postApiV1BriefingsByBriefingIdBriefReopen",
        "summary": "Reopen completed brief to DRAFT for further editing",
        "tags": [
          "campaign-by-context"
        ],
        "description": "Reopens a completed brief for editing, restores its documents if needed, and returns the draft read model.",
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "briefingId",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "id",
                    "project_id",
                    "project_name",
                    "status",
                    "version",
                    "schema_version",
                    "brief",
                    "coverage_score",
                    "coverage_threshold",
                    "dialog_stage",
                    "missing_fields",
                    "tool_scope",
                    "section_statuses",
                    "evidence_summary",
                    "review_ready",
                    "scope_context",
                    "scope_type",
                    "scope_brand_name",
                    "resource_selections",
                    "created_at",
                    "updated_at",
                    "completed_at"
                  ],
                  "properties": {
                    "id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "project_id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "project_name": {
                      "type": "string"
                    },
                    "status": {
                      "type": "string"
                    },
                    "version": {
                      "minimum": 1,
                      "type": "integer"
                    },
                    "schema_version": {
                      "type": "string"
                    },
                    "brief": {
                      "description": "JSON object with nested arrays and objects.",
                      "type": "object",
                      "additionalProperties": {
                        "$comment": "json-value",
                        "description": "Arbitrary JSON value with nested arrays and objects."
                      }
                    },
                    "coverage_score": {
                      "type": "number"
                    },
                    "coverage_threshold": {
                      "type": "number"
                    },
                    "dialog_stage": {
                      "type": "string"
                    },
                    "missing_fields": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "tool_scope": {
                      "anyOf": [
                        {
                          "type": "array",
                          "items": {
                            "type": "string"
                          }
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "section_statuses": {
                      "type": "object",
                      "additionalProperties": {
                        "type": "string"
                      }
                    },
                    "evidence_summary": {
                      "description": "JSON object with nested arrays and objects.",
                      "type": "object",
                      "additionalProperties": {
                        "$comment": "json-value",
                        "description": "Arbitrary JSON value with nested arrays and objects."
                      }
                    },
                    "review_ready": {
                      "type": "boolean"
                    },
                    "scope_context": {
                      "description": "JSON object with nested arrays and objects.",
                      "type": "object",
                      "additionalProperties": {
                        "$comment": "json-value",
                        "description": "Arbitrary JSON value with nested arrays and objects."
                      }
                    },
                    "scope_type": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "scope_brand_name": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "resource_selections": {
                      "description": "JSON object with nested arrays and objects.",
                      "type": "object",
                      "additionalProperties": {
                        "$comment": "json-value",
                        "description": "Arbitrary JSON value with nested arrays and objects."
                      }
                    },
                    "created_at": {
                      "format": "date-time",
                      "type": "string"
                    },
                    "updated_at": {
                      "format": "date-time",
                      "type": "string"
                    },
                    "completed_at": {
                      "anyOf": [
                        {
                          "format": "date-time",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "Conflict - resource state prevents the operation",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/briefings/{briefingId}/confidence/{fieldPath}/tier": {
      "get": {
        "operationId": "getApiV1BriefingsByBriefingIdConfidenceByFieldPathTier",
        "summary": "Get confidence tier for a brief field",
        "tags": [
          "campaign-by-context"
        ],
        "description": "Returns the current confidence tier for one brief field path, or uncertain when no evidence exists.",
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "briefingId",
            "required": true
          },
          {
            "schema": {
              "minLength": 1,
              "maxLength": 200,
              "type": "string"
            },
            "in": "path",
            "name": "fieldPath",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "tier",
                    "evidenceCount"
                  ],
                  "properties": {
                    "tier": {
                      "type": "string"
                    },
                    "evidenceCount": {
                      "minimum": 0,
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/briefings/{briefingId}/confidence/tiers": {
      "get": {
        "operationId": "getApiV1BriefingsByBriefingIdConfidenceTiers",
        "summary": "Get all current field tiers for a brief",
        "tags": [
          "campaign-by-context"
        ],
        "description": "Returns a field-path to confidence-tier map for the current evidence entries of a brief.",
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "briefingId",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "tiers"
                  ],
                  "properties": {
                    "tiers": {
                      "type": "object",
                      "additionalProperties": {
                        "type": "string"
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/briefings/{briefingId}/confidence/conflicts": {
      "get": {
        "operationId": "getApiV1BriefingsByBriefingIdConfidenceConflicts",
        "summary": "List unresolved evidence conflicts on a brief",
        "tags": [
          "campaign-by-context"
        ],
        "description": "Finds current brief fields that have competing evidence candidates and returns the candidates for manual resolution.",
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "briefingId",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "conflicts"
                  ],
                  "properties": {
                    "conflicts": {
                      "type": "array",
                      "items": {
                        "additionalProperties": false,
                        "type": "object",
                        "required": [
                          "field_path",
                          "candidates"
                        ],
                        "properties": {
                          "field_path": {
                            "type": "string"
                          },
                          "candidates": {
                            "type": "array",
                            "items": {
                              "additionalProperties": false,
                              "type": "object",
                              "required": [
                                "entry_id",
                                "value",
                                "source_type",
                                "observed_at",
                                "confidence_tier"
                              ],
                              "properties": {
                                "entry_id": {
                                  "format": "uuid",
                                  "type": "string"
                                },
                                "value": {
                                  "$comment": "json-value",
                                  "description": "Arbitrary JSON value with nested arrays and objects."
                                },
                                "source_type": {
                                  "type": "string"
                                },
                                "observed_at": {
                                  "format": "date-time",
                                  "type": "string"
                                },
                                "confidence_tier": {
                                  "type": "string"
                                }
                              }
                            }
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/briefings/{briefingId}/confidence/resolve": {
      "post": {
        "operationId": "postApiV1BriefingsByBriefingIdConfidenceResolve",
        "summary": "Resolve an evidence conflict on a brief by picking a winner",
        "tags": [
          "campaign-by-context"
        ],
        "description": "Supersedes the current evidence value for a field with the selected winner entry and marks the new value as confirmed.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "field_path",
                  "winner_entry_id"
                ],
                "properties": {
                  "field_path": {
                    "minLength": 1,
                    "maxLength": 200,
                    "type": "string"
                  },
                  "winner_entry_id": {
                    "format": "uuid",
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "briefingId",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "ok",
                    "new_entry_id"
                  ],
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    },
                    "new_entry_id": {
                      "format": "uuid",
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/briefings/{briefingId}/confidence/{fieldPath}/evidence": {
      "get": {
        "operationId": "getApiV1BriefingsByBriefingIdConfidenceByFieldPathEvidence",
        "summary": "Get evidence trail for a brief field",
        "tags": [
          "campaign-by-context"
        ],
        "description": "Returns the full evidence history for one brief field path, including superseded entries and validity windows.",
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "briefingId",
            "required": true
          },
          {
            "schema": {
              "minLength": 1,
              "maxLength": 200,
              "type": "string"
            },
            "in": "path",
            "name": "fieldPath",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "items"
                  ],
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "additionalProperties": false,
                        "type": "object",
                        "required": [
                          "id",
                          "field_path",
                          "field_value_json",
                          "source_type",
                          "source_refs",
                          "confidence_score",
                          "confidence_tier",
                          "depth",
                          "observed_at",
                          "valid_from",
                          "valid_to",
                          "created_by"
                        ],
                        "properties": {
                          "id": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "field_path": {
                            "type": "string"
                          },
                          "field_value_json": {
                            "$comment": "json-value",
                            "description": "Arbitrary JSON value with nested arrays and objects."
                          },
                          "source_type": {
                            "type": "string"
                          },
                          "source_refs": {
                            "$comment": "json-value",
                            "description": "Arbitrary JSON value with nested arrays and objects."
                          },
                          "confidence_score": {
                            "anyOf": [
                              {
                                "type": "number"
                              },
                              {
                                "type": "string"
                              }
                            ]
                          },
                          "confidence_tier": {
                            "type": "string"
                          },
                          "depth": {
                            "type": "string"
                          },
                          "observed_at": {
                            "format": "date-time",
                            "type": "string"
                          },
                          "valid_from": {
                            "format": "date-time",
                            "type": "string"
                          },
                          "valid_to": {
                            "anyOf": [
                              {
                                "format": "date-time",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "created_by": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/briefings/{briefingId}/documents/upload": {
      "post": {
        "operationId": "postApiV1BriefingsByBriefingIdDocumentsUpload",
        "summary": "Upload a document file to a briefing (multipart, single file)",
        "tags": [
          "campaign-by-context"
        ],
        "description": "Accepts one multipart file up to 25 MB, stores it, finalizes the upload, and queues parsing for brief population.",
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "briefingId",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "201": {
            "description": "Resource created",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "id",
                    "original_name",
                    "mime_type",
                    "size_bytes",
                    "upload_status",
                    "parse_status"
                  ],
                  "properties": {
                    "id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "original_name": {
                      "type": "string"
                    },
                    "mime_type": {
                      "type": "string"
                    },
                    "size_bytes": {
                      "minimum": 0,
                      "type": "integer"
                    },
                    "upload_status": {
                      "type": "string"
                    },
                    "parse_status": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/briefings/{briefingId}/documents/init": {
      "post": {
        "operationId": "postApiV1BriefingsByBriefingIdDocumentsInit",
        "summary": "Initialize document upload for a briefing",
        "tags": [
          "campaign-by-context"
        ],
        "description": "Creates the upload artifact and brief document join row before bytes are uploaded through a lower-level flow.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "original_name",
                  "mime_type",
                  "size_bytes"
                ],
                "properties": {
                  "original_name": {
                    "minLength": 1,
                    "maxLength": 500,
                    "type": "string"
                  },
                  "mime_type": {
                    "minLength": 1,
                    "type": "string"
                  },
                  "size_bytes": {
                    "minimum": 1,
                    "type": "integer"
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "briefingId",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "201": {
            "description": "Resource created",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "id",
                    "storage_key",
                    "upload_status",
                    "created_at"
                  ],
                  "properties": {
                    "id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "storage_key": {
                      "type": "string"
                    },
                    "upload_status": {
                      "type": "string"
                    },
                    "created_at": {
                      "format": "date-time",
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/briefings/{briefingId}/documents/{id}/finalize": {
      "post": {
        "operationId": "postApiV1BriefingsByBriefingIdDocumentsByIdFinalize",
        "summary": "Finalize document upload and trigger parsing",
        "tags": [
          "campaign-by-context"
        ],
        "description": "Marks an initialized document upload as uploaded and queues the asynchronous brief population parser.",
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "briefingId",
            "required": true
          },
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "id",
                    "upload_status",
                    "parse_status"
                  ],
                  "properties": {
                    "id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "upload_status": {
                      "type": "string"
                    },
                    "parse_status": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/briefings/{briefingId}/documents": {
      "get": {
        "operationId": "getApiV1BriefingsByBriefingIdDocuments",
        "summary": "List documents for a briefing",
        "tags": [
          "campaign-by-context"
        ],
        "description": "Lists uploaded documents attached to the active brief in a briefing workspace.",
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "briefingId",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "items"
                  ],
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "additionalProperties": false,
                        "type": "object",
                        "required": [
                          "id",
                          "original_name",
                          "mime_type",
                          "size_bytes",
                          "upload_status",
                          "parse_status",
                          "error_code",
                          "created_at",
                          "updated_at"
                        ],
                        "properties": {
                          "id": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "original_name": {
                            "type": "string"
                          },
                          "mime_type": {
                            "type": "string"
                          },
                          "size_bytes": {
                            "minimum": 0,
                            "type": "integer"
                          },
                          "upload_status": {
                            "type": "string"
                          },
                          "parse_status": {
                            "type": "string"
                          },
                          "error_code": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "created_at": {
                            "format": "date-time",
                            "type": "string"
                          },
                          "updated_at": {
                            "format": "date-time",
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/briefings/{briefingId}/documents/{id}": {
      "get": {
        "operationId": "getApiV1BriefingsByBriefingIdDocumentsById",
        "summary": "Get document details",
        "tags": [
          "campaign-by-context"
        ],
        "description": "Returns upload and parsing metadata for one briefing document.",
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "briefingId",
            "required": true
          },
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "id",
                    "original_name",
                    "mime_type",
                    "size_bytes",
                    "upload_status",
                    "parse_status",
                    "error_code",
                    "created_at",
                    "updated_at",
                    "extracted_text_ref"
                  ],
                  "properties": {
                    "id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "original_name": {
                      "type": "string"
                    },
                    "mime_type": {
                      "type": "string"
                    },
                    "size_bytes": {
                      "minimum": 0,
                      "type": "integer"
                    },
                    "upload_status": {
                      "type": "string"
                    },
                    "parse_status": {
                      "type": "string"
                    },
                    "error_code": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "created_at": {
                      "format": "date-time",
                      "type": "string"
                    },
                    "updated_at": {
                      "format": "date-time",
                      "type": "string"
                    },
                    "extracted_text_ref": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      },
      "delete": {
        "operationId": "deleteApiV1BriefingsByBriefingIdDocumentsById",
        "summary": "Delete a document from a briefing",
        "tags": [
          "campaign-by-context"
        ],
        "description": "Soft-deletes a briefing document and its upload artifact, then attempts best-effort physical storage cleanup.",
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "briefingId",
            "required": true
          },
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "204": {
            "description": "No content"
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/briefings/{briefingId}/documents/{id}/retry-parse": {
      "post": {
        "operationId": "postApiV1BriefingsByBriefingIdDocumentsByIdRetryParse",
        "summary": "Retry document parsing",
        "tags": [
          "campaign-by-context"
        ],
        "description": "Resets a previously uploaded document to pending parse state and queues parsing again.",
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "briefingId",
            "required": true
          },
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "id",
                    "parse_status"
                  ],
                  "properties": {
                    "id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "parse_status": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/briefings/{briefingId}/links": {
      "get": {
        "operationId": "getApiV1BriefingsByBriefingIdLinks",
        "summary": "List context links for a briefing",
        "tags": [
          "campaign-by-context"
        ],
        "description": "Lists context links attached to the active brief in newest-first order.",
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "briefingId",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "items"
                  ],
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "additionalProperties": false,
                        "type": "object",
                        "required": [
                          "id",
                          "brief_intake_id",
                          "url",
                          "title",
                          "created_at"
                        ],
                        "properties": {
                          "id": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "brief_intake_id": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "url": {
                            "type": "string"
                          },
                          "title": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "created_at": {
                            "format": "date-time",
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "postApiV1BriefingsByBriefingIdLinks",
        "summary": "Add a context link/URL to a briefing",
        "tags": [
          "campaign-by-context"
        ],
        "description": "Adds one validated http(s) context URL to the active brief after checking briefing ownership.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "url"
                ],
                "properties": {
                  "url": {
                    "minLength": 1,
                    "maxLength": 2048,
                    "type": "string"
                  },
                  "title": {
                    "maxLength": 300,
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "briefingId",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "201": {
            "description": "Resource created",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "id",
                    "brief_intake_id",
                    "url",
                    "title",
                    "created_at"
                  ],
                  "properties": {
                    "id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "brief_intake_id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "url": {
                      "type": "string"
                    },
                    "title": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "created_at": {
                      "format": "date-time",
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/briefings/{briefingId}/links/{id}": {
      "delete": {
        "operationId": "deleteApiV1BriefingsByBriefingIdLinksById",
        "summary": "Remove a context link from a briefing",
        "tags": [
          "campaign-by-context"
        ],
        "description": "Soft-deletes a context link from the active brief after checking briefing ownership.",
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "briefingId",
            "required": true
          },
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "204": {
            "description": "No content"
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/briefings": {
      "get": {
        "operationId": "getApiV1Briefings",
        "summary": "List briefings (Campaign by Context folders)",
        "tags": [
          "campaign-by-context"
        ],
        "description": "Returns the current user briefings with their latest brief status and recent chat sessions. Supports status, search and offset pagination filters.",
        "parameters": [
          {
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "enum": [
                    "draft"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "completed"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "all"
                  ]
                }
              ]
            },
            "in": "query",
            "name": "status",
            "required": false
          },
          {
            "schema": {
              "maxLength": 200,
              "type": "string"
            },
            "in": "query",
            "name": "q",
            "required": false
          },
          {
            "schema": {
              "minimum": 1,
              "maximum": 100,
              "default": 50,
              "type": "integer"
            },
            "in": "query",
            "name": "limit",
            "required": false
          },
          {
            "schema": {
              "minimum": 0,
              "default": 0,
              "type": "integer"
            },
            "in": "query",
            "name": "offset",
            "required": false
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "items",
                    "total"
                  ],
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "additionalProperties": false,
                        "type": "object",
                        "required": [
                          "briefing_id",
                          "name",
                          "created_at",
                          "updated_at",
                          "brief_id",
                          "brief_status",
                          "coverage_score",
                          "recent_sessions"
                        ],
                        "properties": {
                          "briefing_id": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "name": {
                            "type": "string"
                          },
                          "created_at": {
                            "format": "date-time",
                            "description": "ISO 8601 UTC timestamp.",
                            "type": "string"
                          },
                          "updated_at": {
                            "format": "date-time",
                            "description": "ISO 8601 UTC timestamp.",
                            "type": "string"
                          },
                          "brief_id": {
                            "anyOf": [
                              {
                                "format": "uuid",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "brief_status": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "coverage_score": {
                            "type": "number"
                          },
                          "recent_sessions": {
                            "type": "array",
                            "items": {
                              "additionalProperties": false,
                              "type": "object",
                              "required": [
                                "id",
                                "title",
                                "updated_at"
                              ],
                              "properties": {
                                "id": {
                                  "format": "uuid",
                                  "type": "string"
                                },
                                "title": {
                                  "type": "string"
                                },
                                "updated_at": {
                                  "format": "date-time",
                                  "description": "ISO 8601 UTC timestamp.",
                                  "type": "string"
                                }
                              }
                            }
                          }
                        }
                      }
                    },
                    "total": {
                      "minimum": 0,
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "postApiV1Briefings",
        "summary": "Create a new briefing (Campaign by Context folder)",
        "tags": [
          "campaign-by-context"
        ],
        "description": "Creates a Campaign by Context briefing folder, initializes its draft brief and optionally persists tool scope and resource selections.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "properties": {
                  "name": {
                    "minLength": 1,
                    "maxLength": 200,
                    "type": "string"
                  },
                  "tool_scope": {
                    "maxItems": 20,
                    "type": "array",
                    "items": {
                      "maxLength": 64,
                      "type": "string"
                    }
                  },
                  "resource_selections": {
                    "description": "JSON object with nested arrays and objects.",
                    "type": "object",
                    "additionalProperties": {
                      "$comment": "json-value",
                      "description": "Arbitrary JSON value with nested arrays and objects."
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "201": {
            "description": "Resource created",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "briefing_id",
                    "brief_id",
                    "name",
                    "created_at"
                  ],
                  "properties": {
                    "briefing_id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "brief_id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "name": {
                      "type": "string"
                    },
                    "created_at": {
                      "format": "date-time",
                      "description": "ISO 8601 UTC timestamp.",
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/briefings/{briefingId}": {
      "patch": {
        "operationId": "patchApiV1BriefingsByBriefingId",
        "summary": "Rename a briefing",
        "tags": [
          "campaign-by-context"
        ],
        "description": "Renames a briefing folder owned by the current user.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "name"
                ],
                "properties": {
                  "name": {
                    "minLength": 1,
                    "maxLength": 200,
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "briefingId",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "briefing_id",
                    "name",
                    "updated_at"
                  ],
                  "properties": {
                    "briefing_id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "name": {
                      "type": "string"
                    },
                    "updated_at": {
                      "format": "date-time",
                      "description": "ISO 8601 UTC timestamp.",
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      },
      "delete": {
        "operationId": "deleteApiV1BriefingsByBriefingId",
        "summary": "Soft-delete a briefing with cascade",
        "tags": [
          "campaign-by-context"
        ],
        "description": "Archives a briefing folder owned by the current user and soft-deletes its active brief and documents. Upload artifacts are left untouched.",
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "briefingId",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "204": {
            "description": "No content"
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/budget-pools": {
      "get": {
        "operationId": "getApiV1BudgetPools",
        "summary": "List budget pools",
        "tags": [
          "budget-pools"
        ],
        "description": "Returns budget allocation pools accessible to the authenticated user, including pool members.",
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "items"
                  ],
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "additionalProperties": false,
                        "type": "object",
                        "required": [
                          "id",
                          "team_id",
                          "user_id",
                          "name",
                          "ad_account_id",
                          "currency",
                          "daily_budget_cents",
                          "allocation_frequency_h",
                          "optimization_metric",
                          "scoring_window_days",
                          "min_budget_change_cents",
                          "min_budget_change_pct",
                          "min_member_budget_cents",
                          "max_member_budget_cents",
                          "status",
                          "constraints",
                          "last_allocated_at",
                          "next_allocation_at",
                          "created_at",
                          "updated_at",
                          "deleted_at",
                          "members"
                        ],
                        "properties": {
                          "id": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "team_id": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "user_id": {
                            "anyOf": [
                              {
                                "format": "uuid",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "name": {
                            "type": "string"
                          },
                          "ad_account_id": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "currency": {
                            "type": "string"
                          },
                          "daily_budget_cents": {
                            "type": "integer"
                          },
                          "allocation_frequency_h": {
                            "type": "integer"
                          },
                          "optimization_metric": {
                            "type": "string"
                          },
                          "scoring_window_days": {
                            "type": "integer"
                          },
                          "min_budget_change_cents": {
                            "type": "integer"
                          },
                          "min_budget_change_pct": {
                            "anyOf": [
                              {
                                "type": "number"
                              },
                              {
                                "type": "string"
                              }
                            ]
                          },
                          "min_member_budget_cents": {
                            "type": "integer"
                          },
                          "max_member_budget_cents": {
                            "anyOf": [
                              {
                                "type": "integer"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "status": {
                            "type": "string"
                          },
                          "constraints": {
                            "type": "object",
                            "additionalProperties": {
                              "$comment": "json-value"
                            }
                          },
                          "last_allocated_at": {
                            "anyOf": [
                              {
                                "format": "date-time",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "next_allocation_at": {
                            "anyOf": [
                              {
                                "format": "date-time",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "created_at": {
                            "format": "date-time",
                            "type": "string"
                          },
                          "updated_at": {
                            "format": "date-time",
                            "type": "string"
                          },
                          "deleted_at": {
                            "anyOf": [
                              {
                                "format": "date-time",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "members": {
                            "type": "array",
                            "items": {
                              "additionalProperties": false,
                              "type": "object",
                              "required": [
                                "id",
                                "pool_id",
                                "team_id",
                                "entity_type",
                                "entity_id",
                                "entity_name",
                                "ad_account_id",
                                "min_budget_cents",
                                "max_budget_cents",
                                "weight",
                                "is_active",
                                "created_at",
                                "updated_at"
                              ],
                              "properties": {
                                "id": {
                                  "format": "uuid",
                                  "type": "string"
                                },
                                "pool_id": {
                                  "format": "uuid",
                                  "type": "string"
                                },
                                "team_id": {
                                  "format": "uuid",
                                  "type": "string"
                                },
                                "entity_type": {
                                  "anyOf": [
                                    {
                                      "type": "string",
                                      "enum": [
                                        "campaign"
                                      ]
                                    },
                                    {
                                      "type": "string",
                                      "enum": [
                                        "adset"
                                      ]
                                    },
                                    {
                                      "type": "string"
                                    }
                                  ]
                                },
                                "entity_id": {
                                  "type": "string"
                                },
                                "entity_name": {
                                  "anyOf": [
                                    {
                                      "type": "string"
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "ad_account_id": {
                                  "anyOf": [
                                    {
                                      "type": "string"
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "min_budget_cents": {
                                  "anyOf": [
                                    {
                                      "type": "integer"
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "max_budget_cents": {
                                  "anyOf": [
                                    {
                                      "type": "integer"
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "weight": {
                                  "anyOf": [
                                    {
                                      "type": "number"
                                    },
                                    {
                                      "type": "string"
                                    }
                                  ]
                                },
                                "is_active": {
                                  "type": "boolean"
                                },
                                "created_at": {
                                  "format": "date-time",
                                  "type": "string"
                                },
                                "updated_at": {
                                  "format": "date-time",
                                  "type": "string"
                                }
                              }
                            }
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "postApiV1BudgetPools",
        "summary": "Create budget pool",
        "tags": [
          "budget-pools"
        ],
        "description": "Creates a budget allocation pool and optional initial campaign or ad set members.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "dailyBudgetCents",
                  "name"
                ],
                "properties": {
                  "adAccountId": {
                    "type": "string"
                  },
                  "allocationFrequencyH": {
                    "anyOf": [
                      {
                        "type": "number",
                        "enum": [
                          4
                        ]
                      },
                      {
                        "type": "number",
                        "enum": [
                          8
                        ]
                      },
                      {
                        "type": "number",
                        "enum": [
                          12
                        ]
                      },
                      {
                        "type": "number",
                        "enum": [
                          24
                        ]
                      }
                    ]
                  },
                  "constraints": {
                    "type": "object",
                    "additionalProperties": {
                      "$comment": "json-value"
                    }
                  },
                  "currency": {
                    "maxLength": 10,
                    "type": "string"
                  },
                  "dailyBudgetCents": {
                    "minimum": 1,
                    "type": "integer"
                  },
                  "maxMemberBudgetCents": {
                    "minimum": 0,
                    "type": "integer"
                  },
                  "members": {
                    "maxItems": 20,
                    "type": "array",
                    "items": {
                      "additionalProperties": false,
                      "type": "object",
                      "required": [
                        "entityId",
                        "entityType"
                      ],
                      "properties": {
                        "adAccountId": {
                          "type": "string"
                        },
                        "entityId": {
                          "type": "string"
                        },
                        "entityName": {
                          "type": "string"
                        },
                        "entityType": {
                          "anyOf": [
                            {
                              "type": "string",
                              "enum": [
                                "campaign"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "adset"
                              ]
                            }
                          ]
                        },
                        "isActive": {
                          "type": "boolean"
                        },
                        "maxBudgetCents": {
                          "minimum": 0,
                          "type": "integer"
                        },
                        "minBudgetCents": {
                          "minimum": 0,
                          "type": "integer"
                        },
                        "weight": {
                          "minimum": 0,
                          "type": "number"
                        }
                      }
                    }
                  },
                  "minBudgetChangeCents": {
                    "minimum": 0,
                    "type": "integer"
                  },
                  "minBudgetChangePct": {
                    "minimum": 0,
                    "type": "number"
                  },
                  "minMemberBudgetCents": {
                    "minimum": 0,
                    "type": "integer"
                  },
                  "name": {
                    "maxLength": 255,
                    "type": "string"
                  },
                  "optimizationMetric": {
                    "maxLength": 50,
                    "type": "string"
                  },
                  "scoringWindowDays": {
                    "minimum": 1,
                    "maximum": 30,
                    "type": "integer"
                  },
                  "status": {
                    "anyOf": [
                      {
                        "type": "string",
                        "enum": [
                          "active"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "paused"
                        ]
                      }
                    ]
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "anyOf": [
                    {
                      "additionalProperties": false,
                      "type": "object",
                      "required": [
                        "id",
                        "team_id",
                        "user_id",
                        "name",
                        "ad_account_id",
                        "currency",
                        "daily_budget_cents",
                        "allocation_frequency_h",
                        "optimization_metric",
                        "scoring_window_days",
                        "min_budget_change_cents",
                        "min_budget_change_pct",
                        "min_member_budget_cents",
                        "max_member_budget_cents",
                        "status",
                        "constraints",
                        "last_allocated_at",
                        "next_allocation_at",
                        "created_at",
                        "updated_at",
                        "deleted_at",
                        "members"
                      ],
                      "properties": {
                        "id": {
                          "format": "uuid",
                          "type": "string"
                        },
                        "team_id": {
                          "format": "uuid",
                          "type": "string"
                        },
                        "user_id": {
                          "anyOf": [
                            {
                              "format": "uuid",
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "name": {
                          "type": "string"
                        },
                        "ad_account_id": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "currency": {
                          "type": "string"
                        },
                        "daily_budget_cents": {
                          "type": "integer"
                        },
                        "allocation_frequency_h": {
                          "type": "integer"
                        },
                        "optimization_metric": {
                          "type": "string"
                        },
                        "scoring_window_days": {
                          "type": "integer"
                        },
                        "min_budget_change_cents": {
                          "type": "integer"
                        },
                        "min_budget_change_pct": {
                          "anyOf": [
                            {
                              "type": "number"
                            },
                            {
                              "type": "string"
                            }
                          ]
                        },
                        "min_member_budget_cents": {
                          "type": "integer"
                        },
                        "max_member_budget_cents": {
                          "anyOf": [
                            {
                              "type": "integer"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "status": {
                          "type": "string"
                        },
                        "constraints": {
                          "type": "object",
                          "additionalProperties": {
                            "$comment": "json-value"
                          }
                        },
                        "last_allocated_at": {
                          "anyOf": [
                            {
                              "format": "date-time",
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "next_allocation_at": {
                          "anyOf": [
                            {
                              "format": "date-time",
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "created_at": {
                          "format": "date-time",
                          "type": "string"
                        },
                        "updated_at": {
                          "format": "date-time",
                          "type": "string"
                        },
                        "deleted_at": {
                          "anyOf": [
                            {
                              "format": "date-time",
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "members": {
                          "type": "array",
                          "items": {
                            "additionalProperties": false,
                            "type": "object",
                            "required": [
                              "id",
                              "pool_id",
                              "team_id",
                              "entity_type",
                              "entity_id",
                              "entity_name",
                              "ad_account_id",
                              "min_budget_cents",
                              "max_budget_cents",
                              "weight",
                              "is_active",
                              "created_at",
                              "updated_at"
                            ],
                            "properties": {
                              "id": {
                                "format": "uuid",
                                "type": "string"
                              },
                              "pool_id": {
                                "format": "uuid",
                                "type": "string"
                              },
                              "team_id": {
                                "format": "uuid",
                                "type": "string"
                              },
                              "entity_type": {
                                "anyOf": [
                                  {
                                    "type": "string",
                                    "enum": [
                                      "campaign"
                                    ]
                                  },
                                  {
                                    "type": "string",
                                    "enum": [
                                      "adset"
                                    ]
                                  },
                                  {
                                    "type": "string"
                                  }
                                ]
                              },
                              "entity_id": {
                                "type": "string"
                              },
                              "entity_name": {
                                "anyOf": [
                                  {
                                    "type": "string"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "ad_account_id": {
                                "anyOf": [
                                  {
                                    "type": "string"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "min_budget_cents": {
                                "anyOf": [
                                  {
                                    "type": "integer"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "max_budget_cents": {
                                "anyOf": [
                                  {
                                    "type": "integer"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "weight": {
                                "anyOf": [
                                  {
                                    "type": "number"
                                  },
                                  {
                                    "type": "string"
                                  }
                                ]
                              },
                              "is_active": {
                                "type": "boolean"
                              },
                              "created_at": {
                                "format": "date-time",
                                "type": "string"
                              },
                              "updated_at": {
                                "format": "date-time",
                                "type": "string"
                              }
                            }
                          }
                        }
                      }
                    },
                    {
                      "type": "null"
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/budget-pools/{id}": {
      "get": {
        "operationId": "getApiV1BudgetPoolsById",
        "summary": "Get budget pool",
        "tags": [
          "budget-pools"
        ],
        "description": "Returns one budget allocation pool with its members when it belongs to an accessible team.",
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "id",
                    "team_id",
                    "user_id",
                    "name",
                    "ad_account_id",
                    "currency",
                    "daily_budget_cents",
                    "allocation_frequency_h",
                    "optimization_metric",
                    "scoring_window_days",
                    "min_budget_change_cents",
                    "min_budget_change_pct",
                    "min_member_budget_cents",
                    "max_member_budget_cents",
                    "status",
                    "constraints",
                    "last_allocated_at",
                    "next_allocation_at",
                    "created_at",
                    "updated_at",
                    "deleted_at",
                    "members"
                  ],
                  "properties": {
                    "id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "team_id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "user_id": {
                      "anyOf": [
                        {
                          "format": "uuid",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "name": {
                      "type": "string"
                    },
                    "ad_account_id": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "currency": {
                      "type": "string"
                    },
                    "daily_budget_cents": {
                      "type": "integer"
                    },
                    "allocation_frequency_h": {
                      "type": "integer"
                    },
                    "optimization_metric": {
                      "type": "string"
                    },
                    "scoring_window_days": {
                      "type": "integer"
                    },
                    "min_budget_change_cents": {
                      "type": "integer"
                    },
                    "min_budget_change_pct": {
                      "anyOf": [
                        {
                          "type": "number"
                        },
                        {
                          "type": "string"
                        }
                      ]
                    },
                    "min_member_budget_cents": {
                      "type": "integer"
                    },
                    "max_member_budget_cents": {
                      "anyOf": [
                        {
                          "type": "integer"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "status": {
                      "type": "string"
                    },
                    "constraints": {
                      "type": "object",
                      "additionalProperties": {
                        "$comment": "json-value"
                      }
                    },
                    "last_allocated_at": {
                      "anyOf": [
                        {
                          "format": "date-time",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "next_allocation_at": {
                      "anyOf": [
                        {
                          "format": "date-time",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "created_at": {
                      "format": "date-time",
                      "type": "string"
                    },
                    "updated_at": {
                      "format": "date-time",
                      "type": "string"
                    },
                    "deleted_at": {
                      "anyOf": [
                        {
                          "format": "date-time",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "members": {
                      "type": "array",
                      "items": {
                        "additionalProperties": false,
                        "type": "object",
                        "required": [
                          "id",
                          "pool_id",
                          "team_id",
                          "entity_type",
                          "entity_id",
                          "entity_name",
                          "ad_account_id",
                          "min_budget_cents",
                          "max_budget_cents",
                          "weight",
                          "is_active",
                          "created_at",
                          "updated_at"
                        ],
                        "properties": {
                          "id": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "pool_id": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "team_id": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "entity_type": {
                            "anyOf": [
                              {
                                "type": "string",
                                "enum": [
                                  "campaign"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "adset"
                                ]
                              },
                              {
                                "type": "string"
                              }
                            ]
                          },
                          "entity_id": {
                            "type": "string"
                          },
                          "entity_name": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "ad_account_id": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "min_budget_cents": {
                            "anyOf": [
                              {
                                "type": "integer"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "max_budget_cents": {
                            "anyOf": [
                              {
                                "type": "integer"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "weight": {
                            "anyOf": [
                              {
                                "type": "number"
                              },
                              {
                                "type": "string"
                              }
                            ]
                          },
                          "is_active": {
                            "type": "boolean"
                          },
                          "created_at": {
                            "format": "date-time",
                            "type": "string"
                          },
                          "updated_at": {
                            "format": "date-time",
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      },
      "patch": {
        "operationId": "patchApiV1BudgetPoolsById",
        "summary": "Update budget pool",
        "tags": [
          "budget-pools"
        ],
        "description": "Updates mutable settings for a budget allocation pool without changing its runtime allocation logic.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "properties": {
                  "adAccountId": {
                    "type": "string"
                  },
                  "allocationFrequencyH": {
                    "anyOf": [
                      {
                        "type": "number",
                        "enum": [
                          4
                        ]
                      },
                      {
                        "type": "number",
                        "enum": [
                          8
                        ]
                      },
                      {
                        "type": "number",
                        "enum": [
                          12
                        ]
                      },
                      {
                        "type": "number",
                        "enum": [
                          24
                        ]
                      }
                    ]
                  },
                  "constraints": {
                    "type": "object",
                    "additionalProperties": {
                      "$comment": "json-value"
                    }
                  },
                  "currency": {
                    "maxLength": 10,
                    "type": "string"
                  },
                  "dailyBudgetCents": {
                    "minimum": 1,
                    "type": "integer"
                  },
                  "maxMemberBudgetCents": {
                    "minimum": 0,
                    "type": "integer"
                  },
                  "minBudgetChangeCents": {
                    "minimum": 0,
                    "type": "integer"
                  },
                  "minBudgetChangePct": {
                    "minimum": 0,
                    "type": "number"
                  },
                  "minMemberBudgetCents": {
                    "minimum": 0,
                    "type": "integer"
                  },
                  "name": {
                    "maxLength": 255,
                    "type": "string"
                  },
                  "optimizationMetric": {
                    "maxLength": 50,
                    "type": "string"
                  },
                  "scoringWindowDays": {
                    "minimum": 1,
                    "maximum": 30,
                    "type": "integer"
                  },
                  "status": {
                    "anyOf": [
                      {
                        "type": "string",
                        "enum": [
                          "active"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "paused"
                        ]
                      }
                    ]
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "id",
                    "team_id",
                    "user_id",
                    "name",
                    "ad_account_id",
                    "currency",
                    "daily_budget_cents",
                    "allocation_frequency_h",
                    "optimization_metric",
                    "scoring_window_days",
                    "min_budget_change_cents",
                    "min_budget_change_pct",
                    "min_member_budget_cents",
                    "max_member_budget_cents",
                    "status",
                    "constraints",
                    "last_allocated_at",
                    "next_allocation_at",
                    "created_at",
                    "updated_at",
                    "deleted_at",
                    "members"
                  ],
                  "properties": {
                    "id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "team_id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "user_id": {
                      "anyOf": [
                        {
                          "format": "uuid",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "name": {
                      "type": "string"
                    },
                    "ad_account_id": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "currency": {
                      "type": "string"
                    },
                    "daily_budget_cents": {
                      "type": "integer"
                    },
                    "allocation_frequency_h": {
                      "type": "integer"
                    },
                    "optimization_metric": {
                      "type": "string"
                    },
                    "scoring_window_days": {
                      "type": "integer"
                    },
                    "min_budget_change_cents": {
                      "type": "integer"
                    },
                    "min_budget_change_pct": {
                      "anyOf": [
                        {
                          "type": "number"
                        },
                        {
                          "type": "string"
                        }
                      ]
                    },
                    "min_member_budget_cents": {
                      "type": "integer"
                    },
                    "max_member_budget_cents": {
                      "anyOf": [
                        {
                          "type": "integer"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "status": {
                      "type": "string"
                    },
                    "constraints": {
                      "type": "object",
                      "additionalProperties": {
                        "$comment": "json-value"
                      }
                    },
                    "last_allocated_at": {
                      "anyOf": [
                        {
                          "format": "date-time",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "next_allocation_at": {
                      "anyOf": [
                        {
                          "format": "date-time",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "created_at": {
                      "format": "date-time",
                      "type": "string"
                    },
                    "updated_at": {
                      "format": "date-time",
                      "type": "string"
                    },
                    "deleted_at": {
                      "anyOf": [
                        {
                          "format": "date-time",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "members": {
                      "type": "array",
                      "items": {
                        "additionalProperties": false,
                        "type": "object",
                        "required": [
                          "id",
                          "pool_id",
                          "team_id",
                          "entity_type",
                          "entity_id",
                          "entity_name",
                          "ad_account_id",
                          "min_budget_cents",
                          "max_budget_cents",
                          "weight",
                          "is_active",
                          "created_at",
                          "updated_at"
                        ],
                        "properties": {
                          "id": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "pool_id": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "team_id": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "entity_type": {
                            "anyOf": [
                              {
                                "type": "string",
                                "enum": [
                                  "campaign"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "adset"
                                ]
                              },
                              {
                                "type": "string"
                              }
                            ]
                          },
                          "entity_id": {
                            "type": "string"
                          },
                          "entity_name": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "ad_account_id": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "min_budget_cents": {
                            "anyOf": [
                              {
                                "type": "integer"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "max_budget_cents": {
                            "anyOf": [
                              {
                                "type": "integer"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "weight": {
                            "anyOf": [
                              {
                                "type": "number"
                              },
                              {
                                "type": "string"
                              }
                            ]
                          },
                          "is_active": {
                            "type": "boolean"
                          },
                          "created_at": {
                            "format": "date-time",
                            "type": "string"
                          },
                          "updated_at": {
                            "format": "date-time",
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      },
      "delete": {
        "operationId": "deleteApiV1BudgetPoolsById",
        "summary": "Delete budget pool",
        "tags": [
          "budget-pools"
        ],
        "description": "Soft-deletes a budget allocation pool and deactivates its members.",
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "deleted"
                  ],
                  "properties": {
                    "deleted": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/budget-pools/{id}/members": {
      "post": {
        "operationId": "postApiV1BudgetPoolsByIdMembers",
        "summary": "Add budget pool member",
        "tags": [
          "budget-pools"
        ],
        "description": "Adds or reactivates a campaign or ad set member in a budget allocation pool.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "entityId",
                  "entityType"
                ],
                "properties": {
                  "adAccountId": {
                    "type": "string"
                  },
                  "entityId": {
                    "type": "string"
                  },
                  "entityName": {
                    "type": "string"
                  },
                  "entityType": {
                    "anyOf": [
                      {
                        "type": "string",
                        "enum": [
                          "campaign"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "adset"
                        ]
                      }
                    ]
                  },
                  "isActive": {
                    "type": "boolean"
                  },
                  "maxBudgetCents": {
                    "minimum": 0,
                    "type": "integer"
                  },
                  "minBudgetCents": {
                    "minimum": 0,
                    "type": "integer"
                  },
                  "weight": {
                    "minimum": 0,
                    "type": "number"
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "id",
                    "pool_id",
                    "team_id",
                    "entity_type",
                    "entity_id",
                    "entity_name",
                    "ad_account_id",
                    "min_budget_cents",
                    "max_budget_cents",
                    "weight",
                    "is_active",
                    "created_at",
                    "updated_at"
                  ],
                  "properties": {
                    "id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "pool_id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "team_id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "entity_type": {
                      "anyOf": [
                        {
                          "type": "string",
                          "enum": [
                            "campaign"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "adset"
                          ]
                        },
                        {
                          "type": "string"
                        }
                      ]
                    },
                    "entity_id": {
                      "type": "string"
                    },
                    "entity_name": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "ad_account_id": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "min_budget_cents": {
                      "anyOf": [
                        {
                          "type": "integer"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "max_budget_cents": {
                      "anyOf": [
                        {
                          "type": "integer"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "weight": {
                      "anyOf": [
                        {
                          "type": "number"
                        },
                        {
                          "type": "string"
                        }
                      ]
                    },
                    "is_active": {
                      "type": "boolean"
                    },
                    "created_at": {
                      "format": "date-time",
                      "type": "string"
                    },
                    "updated_at": {
                      "format": "date-time",
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "Conflict - resource state prevents the operation",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/budget-pools/{id}/members/{memberId}": {
      "delete": {
        "operationId": "deleteApiV1BudgetPoolsByIdMembersByMemberId",
        "summary": "Remove budget pool member",
        "tags": [
          "budget-pools"
        ],
        "description": "Deactivates a member in a budget allocation pool.",
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          },
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "memberId",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "removed"
                  ],
                  "properties": {
                    "removed": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/budget-pools/{id}/simulate": {
      "post": {
        "operationId": "postApiV1BudgetPoolsByIdSimulate",
        "summary": "Simulate budget allocation",
        "tags": [
          "budget-pools"
        ],
        "description": "Calculates a what-if budget allocation for the pool and stores a simulation log entry.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "properties": {
                  "from_date": {
                    "format": "date",
                    "type": "string"
                  },
                  "to_date": {
                    "format": "date",
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "allocation",
                    "dateRange",
                    "diminishingReturns",
                    "sourceConfidence"
                  ],
                  "properties": {
                    "allocation": {
                      "type": "array",
                      "items": {
                        "additionalProperties": false,
                        "type": "object",
                        "required": [
                          "currentBudgetCents",
                          "entityId",
                          "entityType",
                          "currentSpendCents",
                          "proposedBudgetCents",
                          "score",
                          "reason"
                        ],
                        "properties": {
                          "currentBudgetCents": {
                            "anyOf": [
                              {
                                "type": "integer"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "entityId": {
                            "type": "string"
                          },
                          "entityName": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "entityType": {
                            "type": "string"
                          },
                          "currentSpendCents": {
                            "type": "integer"
                          },
                          "proposedBudgetCents": {
                            "type": "integer"
                          },
                          "score": {
                            "type": "number"
                          },
                          "reason": {
                            "type": "string"
                          }
                        }
                      }
                    },
                    "dateRange": {
                      "additionalProperties": false,
                      "type": "object",
                      "required": [
                        "fromDate",
                        "toDate",
                        "wasClamped"
                      ],
                      "properties": {
                        "fromDate": {
                          "format": "date",
                          "type": "string"
                        },
                        "toDate": {
                          "format": "date",
                          "type": "string"
                        },
                        "wasClamped": {
                          "type": "boolean"
                        }
                      }
                    },
                    "diminishingReturns": {
                      "type": "object",
                      "additionalProperties": {
                        "additionalProperties": false,
                        "type": "object",
                        "required": [
                          "campaign_id",
                          "dr_detected",
                          "dr_score",
                          "dr_threshold_eur",
                          "recent_roas",
                          "recent_spend",
                          "previous_roas",
                          "previous_spend"
                        ],
                        "properties": {
                          "campaign_id": {
                            "type": "string"
                          },
                          "dr_detected": {
                            "type": "boolean"
                          },
                          "dr_score": {
                            "type": "integer"
                          },
                          "dr_threshold_eur": {
                            "anyOf": [
                              {
                                "type": "number"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "recent_roas": {
                            "type": "number"
                          },
                          "recent_spend": {
                            "type": "number"
                          },
                          "previous_roas": {
                            "type": "number"
                          },
                          "previous_spend": {
                            "type": "number"
                          }
                        }
                      }
                    },
                    "sourceConfidence": {
                      "additionalProperties": false,
                      "type": "object",
                      "required": [
                        "platform_performance",
                        "tracker"
                      ],
                      "properties": {
                        "platform_performance": {
                          "type": "number"
                        },
                        "tracker": {
                          "type": "number"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/budget-pools/{id}/allocate": {
      "post": {
        "operationId": "postApiV1BudgetPoolsByIdAllocate",
        "summary": "Execute budget allocation",
        "tags": [
          "budget-pools"
        ],
        "description": "Queues or synchronously executes budget changes for a pool after WAVO guardrail checks.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "properties": {
                  "async": {
                    "default": true,
                    "type": "boolean"
                  },
                  "from_date": {
                    "format": "date",
                    "type": "string"
                  },
                  "to_date": {
                    "format": "date",
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "anyOf": [
                    {
                      "additionalProperties": false,
                      "type": "object",
                      "required": [
                        "status"
                      ],
                      "properties": {
                        "status": {
                          "type": "string",
                          "enum": [
                            "queued"
                          ]
                        }
                      }
                    },
                    {
                      "type": "object",
                      "allOf": [
                        {
                          "additionalProperties": false,
                          "type": "object",
                          "required": [
                            "allocation",
                            "dateRange",
                            "diminishingReturns",
                            "sourceConfidence"
                          ],
                          "properties": {
                            "allocation": {
                              "type": "array",
                              "items": {
                                "additionalProperties": false,
                                "type": "object",
                                "required": [
                                  "currentBudgetCents",
                                  "entityId",
                                  "entityType",
                                  "currentSpendCents",
                                  "proposedBudgetCents",
                                  "score",
                                  "reason"
                                ],
                                "properties": {
                                  "currentBudgetCents": {
                                    "anyOf": [
                                      {
                                        "type": "integer"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "entityId": {
                                    "type": "string"
                                  },
                                  "entityName": {
                                    "anyOf": [
                                      {
                                        "type": "string"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "entityType": {
                                    "type": "string"
                                  },
                                  "currentSpendCents": {
                                    "type": "integer"
                                  },
                                  "proposedBudgetCents": {
                                    "type": "integer"
                                  },
                                  "score": {
                                    "type": "number"
                                  },
                                  "reason": {
                                    "type": "string"
                                  }
                                }
                              }
                            },
                            "dateRange": {
                              "additionalProperties": false,
                              "type": "object",
                              "required": [
                                "fromDate",
                                "toDate",
                                "wasClamped"
                              ],
                              "properties": {
                                "fromDate": {
                                  "format": "date",
                                  "type": "string"
                                },
                                "toDate": {
                                  "format": "date",
                                  "type": "string"
                                },
                                "wasClamped": {
                                  "type": "boolean"
                                }
                              }
                            },
                            "diminishingReturns": {
                              "type": "object",
                              "additionalProperties": {
                                "additionalProperties": false,
                                "type": "object",
                                "required": [
                                  "campaign_id",
                                  "dr_detected",
                                  "dr_score",
                                  "dr_threshold_eur",
                                  "recent_roas",
                                  "recent_spend",
                                  "previous_roas",
                                  "previous_spend"
                                ],
                                "properties": {
                                  "campaign_id": {
                                    "type": "string"
                                  },
                                  "dr_detected": {
                                    "type": "boolean"
                                  },
                                  "dr_score": {
                                    "type": "integer"
                                  },
                                  "dr_threshold_eur": {
                                    "anyOf": [
                                      {
                                        "type": "number"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "recent_roas": {
                                    "type": "number"
                                  },
                                  "recent_spend": {
                                    "type": "number"
                                  },
                                  "previous_roas": {
                                    "type": "number"
                                  },
                                  "previous_spend": {
                                    "type": "number"
                                  }
                                }
                              }
                            },
                            "sourceConfidence": {
                              "additionalProperties": false,
                              "type": "object",
                              "required": [
                                "platform_performance",
                                "tracker"
                              ],
                              "properties": {
                                "platform_performance": {
                                  "type": "number"
                                },
                                "tracker": {
                                  "type": "number"
                                }
                              }
                            }
                          }
                        },
                        {
                          "additionalProperties": false,
                          "type": "object",
                          "required": [
                            "applied",
                            "status"
                          ],
                          "properties": {
                            "applied": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "allOf": [
                                  {
                                    "additionalProperties": false,
                                    "type": "object",
                                    "required": [
                                      "currentBudgetCents",
                                      "entityId",
                                      "entityType",
                                      "currentSpendCents",
                                      "proposedBudgetCents",
                                      "score",
                                      "reason"
                                    ],
                                    "properties": {
                                      "currentBudgetCents": {
                                        "anyOf": [
                                          {
                                            "type": "integer"
                                          },
                                          {
                                            "type": "null"
                                          }
                                        ]
                                      },
                                      "entityId": {
                                        "type": "string"
                                      },
                                      "entityName": {
                                        "anyOf": [
                                          {
                                            "type": "string"
                                          },
                                          {
                                            "type": "null"
                                          }
                                        ]
                                      },
                                      "entityType": {
                                        "type": "string"
                                      },
                                      "currentSpendCents": {
                                        "type": "integer"
                                      },
                                      "proposedBudgetCents": {
                                        "type": "integer"
                                      },
                                      "score": {
                                        "type": "number"
                                      },
                                      "reason": {
                                        "type": "string"
                                      }
                                    }
                                  },
                                  {
                                    "additionalProperties": false,
                                    "type": "object",
                                    "required": [
                                      "status"
                                    ],
                                    "properties": {
                                      "accountId": {
                                        "type": "string"
                                      },
                                      "error": {
                                        "type": "string"
                                      },
                                      "platform": {
                                        "type": "string"
                                      },
                                      "proposedBudget": {
                                        "type": "number"
                                      },
                                      "status": {
                                        "anyOf": [
                                          {
                                            "type": "string",
                                            "enum": [
                                              "applied"
                                            ]
                                          },
                                          {
                                            "type": "string",
                                            "enum": [
                                              "failed"
                                            ]
                                          },
                                          {
                                            "type": "string",
                                            "enum": [
                                              "skipped"
                                            ]
                                          }
                                        ]
                                      }
                                    }
                                  }
                                ]
                              }
                            },
                            "status": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "enum": [
                                    "completed"
                                  ]
                                },
                                {
                                  "type": "string",
                                  "enum": [
                                    "failed"
                                  ]
                                }
                              ]
                            }
                          }
                        }
                      ]
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "423": {
            "description": "Response 423",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number",
                      "enum": [
                        423
                      ]
                    },
                    "error": {
                      "type": "string",
                      "enum": [
                        "Locked"
                      ]
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "Too many requests - rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/budget-pools/{id}/allocations": {
      "get": {
        "operationId": "getApiV1BudgetPoolsByIdAllocations",
        "summary": "List budget allocation logs",
        "tags": [
          "budget-pools"
        ],
        "description": "Returns recent simulation and execution logs for a budget allocation pool.",
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "items"
                  ],
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "additionalProperties": false,
                        "type": "object",
                        "required": [
                          "id",
                          "pool_id",
                          "team_id",
                          "user_id",
                          "action_log_id",
                          "mode",
                          "status",
                          "input_snapshot",
                          "allocation_result",
                          "idempotency_key",
                          "campaign_id",
                          "campaign_name",
                          "old_budget_cents",
                          "new_budget_cents",
                          "score",
                          "score_breakdown",
                          "reason",
                          "error_message",
                          "created_at",
                          "executed_at",
                          "allocated_at"
                        ],
                        "properties": {
                          "id": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "pool_id": {
                            "anyOf": [
                              {
                                "format": "uuid",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "team_id": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "user_id": {
                            "anyOf": [
                              {
                                "format": "uuid",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "action_log_id": {
                            "anyOf": [
                              {
                                "format": "uuid",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "mode": {
                            "type": "string"
                          },
                          "status": {
                            "type": "string"
                          },
                          "input_snapshot": {
                            "$comment": "json-value"
                          },
                          "allocation_result": {
                            "$comment": "json-value"
                          },
                          "idempotency_key": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "campaign_id": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "campaign_name": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "old_budget_cents": {
                            "anyOf": [
                              {
                                "type": "integer"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "new_budget_cents": {
                            "anyOf": [
                              {
                                "type": "integer"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "score": {
                            "anyOf": [
                              {
                                "type": "integer"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "score_breakdown": {
                            "$comment": "json-value"
                          },
                          "reason": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "error_message": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "created_at": {
                            "format": "date-time",
                            "type": "string"
                          },
                          "executed_at": {
                            "anyOf": [
                              {
                                "format": "date-time",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "allocated_at": {
                            "anyOf": [
                              {
                                "format": "date-time",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/budget-pools/{id}/diminishing-returns": {
      "get": {
        "operationId": "getApiV1BudgetPoolsByIdDiminishingReturns",
        "summary": "Detect diminishing returns",
        "tags": [
          "budget-pools"
        ],
        "description": "Analyzes active campaign members in the pool for recent spend growth without ROAS improvement.",
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "items"
                  ],
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "additionalProperties": false,
                        "type": "object",
                        "required": [
                          "campaign_id",
                          "dr_detected",
                          "dr_score",
                          "dr_threshold_eur",
                          "recent_roas",
                          "recent_spend",
                          "previous_roas",
                          "previous_spend"
                        ],
                        "properties": {
                          "campaign_id": {
                            "type": "string"
                          },
                          "dr_detected": {
                            "type": "boolean"
                          },
                          "dr_score": {
                            "type": "integer"
                          },
                          "dr_threshold_eur": {
                            "anyOf": [
                              {
                                "type": "number"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "recent_roas": {
                            "type": "number"
                          },
                          "recent_spend": {
                            "type": "number"
                          },
                          "previous_roas": {
                            "type": "number"
                          },
                          "previous_spend": {
                            "type": "number"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/campaigns/bulk-toggle": {
      "post": {
        "operationId": "bulkTogglecampaign",
        "summary": "Bulk toggle campaign statuses",
        "tags": [
          "campaigns"
        ],
        "description": "Enqueues a background worker run that sets up to 100 Meta campaign ids to ACTIVE or PAUSED for the specified ad account.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "account_id",
                  "action",
                  "ids"
                ],
                "properties": {
                  "account_id": {
                    "minLength": 1,
                    "type": "string"
                  },
                  "action": {
                    "anyOf": [
                      {
                        "type": "string",
                        "enum": [
                          "ACTIVE"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "PAUSED"
                        ]
                      }
                    ]
                  },
                  "ids": {
                    "minItems": 1,
                    "maxItems": 100,
                    "type": "array",
                    "items": {
                      "minLength": 1,
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "202": {
            "description": "Accepted - processing asynchronously",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "worker_run_id",
                    "total"
                  ],
                  "properties": {
                    "worker_run_id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "total": {
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "422": {
            "description": "Unprocessable entity - semantic validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/adsets/bulk-toggle": {
      "post": {
        "operationId": "bulkToggleadset",
        "summary": "Bulk toggle adset statuses",
        "tags": [
          "campaigns"
        ],
        "description": "Enqueues a background worker run that sets up to 100 Meta adset ids to ACTIVE or PAUSED for the specified ad account.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "account_id",
                  "action",
                  "ids"
                ],
                "properties": {
                  "account_id": {
                    "minLength": 1,
                    "type": "string"
                  },
                  "action": {
                    "anyOf": [
                      {
                        "type": "string",
                        "enum": [
                          "ACTIVE"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "PAUSED"
                        ]
                      }
                    ]
                  },
                  "ids": {
                    "minItems": 1,
                    "maxItems": 100,
                    "type": "array",
                    "items": {
                      "minLength": 1,
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "202": {
            "description": "Accepted - processing asynchronously",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "worker_run_id",
                    "total"
                  ],
                  "properties": {
                    "worker_run_id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "total": {
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "422": {
            "description": "Unprocessable entity - semantic validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/ads/bulk-toggle": {
      "post": {
        "operationId": "bulkTogglead",
        "summary": "Bulk toggle ad statuses",
        "tags": [
          "campaigns"
        ],
        "description": "Enqueues a background worker run that sets up to 100 Meta ad ids to ACTIVE or PAUSED for the specified ad account.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "account_id",
                  "action",
                  "ids"
                ],
                "properties": {
                  "account_id": {
                    "minLength": 1,
                    "type": "string"
                  },
                  "action": {
                    "anyOf": [
                      {
                        "type": "string",
                        "enum": [
                          "ACTIVE"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "PAUSED"
                        ]
                      }
                    ]
                  },
                  "ids": {
                    "minItems": 1,
                    "maxItems": 100,
                    "type": "array",
                    "items": {
                      "minLength": 1,
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "202": {
            "description": "Accepted - processing asynchronously",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "worker_run_id",
                    "total"
                  ],
                  "properties": {
                    "worker_run_id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "total": {
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "422": {
            "description": "Unprocessable entity - semantic validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/campaign-context/gather": {
      "post": {
        "operationId": "postApiV1CampaignContextGather",
        "summary": "Gather an AI-native campaign context snapshot",
        "tags": [
          "campaign-context"
        ],
        "description": "Collects platform, tracker, commerce, business, competitor, market, and landing-page context into a draft snapshot.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "properties": {
                  "ad_account_id": {
                    "maxLength": 100,
                    "type": "string"
                  },
                  "brief_input": {
                    "type": "object",
                    "additionalProperties": {
                      "$comment": "json-value"
                    }
                  },
                  "from_date": {
                    "format": "date",
                    "type": "string"
                  },
                  "project_id": {
                    "format": "uuid",
                    "type": "string"
                  },
                  "to_date": {
                    "format": "date",
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "anyOf": [
                    {
                      "additionalProperties": false,
                      "type": "object",
                      "required": [
                        "id",
                        "team_id",
                        "user_id",
                        "brief_id",
                        "project_id",
                        "ad_account_id",
                        "brief_input",
                        "status",
                        "platform_performance",
                        "tracker_attribution",
                        "ecommerce_data",
                        "business_context",
                        "competitor_intelligence",
                        "market_research",
                        "landing_page_analysis",
                        "sources_used",
                        "sources_missing",
                        "brief_gaps",
                        "confidence_score",
                        "gathering_duration_ms",
                        "approved_at",
                        "approved_by",
                        "created_at",
                        "updated_at"
                      ],
                      "properties": {
                        "id": {
                          "format": "uuid",
                          "type": "string"
                        },
                        "team_id": {
                          "format": "uuid",
                          "type": "string"
                        },
                        "user_id": {
                          "anyOf": [
                            {
                              "format": "uuid",
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "brief_id": {
                          "anyOf": [
                            {
                              "format": "uuid",
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "project_id": {
                          "anyOf": [
                            {
                              "format": "uuid",
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "ad_account_id": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "brief_input": {
                          "$comment": "json-value"
                        },
                        "status": {
                          "anyOf": [
                            {
                              "type": "string",
                              "enum": [
                                "gathering"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "draft"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "approved"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "failed"
                              ]
                            }
                          ]
                        },
                        "platform_performance": {
                          "$comment": "json-value"
                        },
                        "tracker_attribution": {
                          "$comment": "json-value"
                        },
                        "ecommerce_data": {
                          "$comment": "json-value"
                        },
                        "business_context": {
                          "$comment": "json-value"
                        },
                        "competitor_intelligence": {
                          "$comment": "json-value"
                        },
                        "market_research": {
                          "$comment": "json-value"
                        },
                        "landing_page_analysis": {
                          "$comment": "json-value"
                        },
                        "sources_used": {
                          "type": "array",
                          "items": {
                            "$comment": "json-value"
                          }
                        },
                        "sources_missing": {
                          "type": "array",
                          "items": {
                            "$comment": "json-value"
                          }
                        },
                        "brief_gaps": {
                          "type": "array",
                          "items": {
                            "$comment": "json-value"
                          }
                        },
                        "confidence_score": {
                          "anyOf": [
                            {
                              "type": "number"
                            },
                            {
                              "type": "string"
                            }
                          ]
                        },
                        "gathering_duration_ms": {
                          "type": "integer"
                        },
                        "approved_at": {
                          "anyOf": [
                            {
                              "format": "date-time",
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "approved_by": {
                          "anyOf": [
                            {
                              "format": "uuid",
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "created_at": {
                          "format": "date-time",
                          "type": "string"
                        },
                        "updated_at": {
                          "format": "date-time",
                          "type": "string"
                        },
                        "edited_before_approval": {
                          "type": "boolean"
                        }
                      }
                    },
                    {
                      "type": "null"
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/campaign-context/{briefId}/gather-context": {
      "post": {
        "operationId": "postApiV1CampaignContextByBriefIdGatherContext",
        "summary": "Gather a campaign context snapshot for a completed brief",
        "tags": [
          "campaign-context"
        ],
        "description": "Builds campaign context from a completed briefing canvas and optional request overrides.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "properties": {
                  "ad_account_id": {
                    "maxLength": 100,
                    "type": "string"
                  },
                  "brief_input": {
                    "type": "object",
                    "additionalProperties": {
                      "$comment": "json-value"
                    }
                  },
                  "from_date": {
                    "format": "date",
                    "type": "string"
                  },
                  "project_id": {
                    "format": "uuid",
                    "type": "string"
                  },
                  "to_date": {
                    "format": "date",
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "briefId",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "anyOf": [
                    {
                      "additionalProperties": false,
                      "type": "object",
                      "required": [
                        "id",
                        "team_id",
                        "user_id",
                        "brief_id",
                        "project_id",
                        "ad_account_id",
                        "brief_input",
                        "status",
                        "platform_performance",
                        "tracker_attribution",
                        "ecommerce_data",
                        "business_context",
                        "competitor_intelligence",
                        "market_research",
                        "landing_page_analysis",
                        "sources_used",
                        "sources_missing",
                        "brief_gaps",
                        "confidence_score",
                        "gathering_duration_ms",
                        "approved_at",
                        "approved_by",
                        "created_at",
                        "updated_at"
                      ],
                      "properties": {
                        "id": {
                          "format": "uuid",
                          "type": "string"
                        },
                        "team_id": {
                          "format": "uuid",
                          "type": "string"
                        },
                        "user_id": {
                          "anyOf": [
                            {
                              "format": "uuid",
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "brief_id": {
                          "anyOf": [
                            {
                              "format": "uuid",
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "project_id": {
                          "anyOf": [
                            {
                              "format": "uuid",
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "ad_account_id": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "brief_input": {
                          "$comment": "json-value"
                        },
                        "status": {
                          "anyOf": [
                            {
                              "type": "string",
                              "enum": [
                                "gathering"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "draft"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "approved"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "failed"
                              ]
                            }
                          ]
                        },
                        "platform_performance": {
                          "$comment": "json-value"
                        },
                        "tracker_attribution": {
                          "$comment": "json-value"
                        },
                        "ecommerce_data": {
                          "$comment": "json-value"
                        },
                        "business_context": {
                          "$comment": "json-value"
                        },
                        "competitor_intelligence": {
                          "$comment": "json-value"
                        },
                        "market_research": {
                          "$comment": "json-value"
                        },
                        "landing_page_analysis": {
                          "$comment": "json-value"
                        },
                        "sources_used": {
                          "type": "array",
                          "items": {
                            "$comment": "json-value"
                          }
                        },
                        "sources_missing": {
                          "type": "array",
                          "items": {
                            "$comment": "json-value"
                          }
                        },
                        "brief_gaps": {
                          "type": "array",
                          "items": {
                            "$comment": "json-value"
                          }
                        },
                        "confidence_score": {
                          "anyOf": [
                            {
                              "type": "number"
                            },
                            {
                              "type": "string"
                            }
                          ]
                        },
                        "gathering_duration_ms": {
                          "type": "integer"
                        },
                        "approved_at": {
                          "anyOf": [
                            {
                              "format": "date-time",
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "approved_by": {
                          "anyOf": [
                            {
                              "format": "uuid",
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "created_at": {
                          "format": "date-time",
                          "type": "string"
                        },
                        "updated_at": {
                          "format": "date-time",
                          "type": "string"
                        },
                        "edited_before_approval": {
                          "type": "boolean"
                        }
                      }
                    },
                    {
                      "type": "null"
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/campaign-context/{briefId}/snapshot": {
      "get": {
        "operationId": "getApiV1CampaignContextByBriefIdSnapshot",
        "summary": "Get latest campaign context snapshot for a brief",
        "tags": [
          "campaign-context"
        ],
        "description": "Returns the most recent campaign context snapshot associated with a completed brief.",
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "briefId",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "id",
                    "team_id",
                    "user_id",
                    "brief_id",
                    "project_id",
                    "ad_account_id",
                    "brief_input",
                    "status",
                    "platform_performance",
                    "tracker_attribution",
                    "ecommerce_data",
                    "business_context",
                    "competitor_intelligence",
                    "market_research",
                    "landing_page_analysis",
                    "sources_used",
                    "sources_missing",
                    "brief_gaps",
                    "confidence_score",
                    "gathering_duration_ms",
                    "approved_at",
                    "approved_by",
                    "created_at",
                    "updated_at"
                  ],
                  "properties": {
                    "id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "team_id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "user_id": {
                      "anyOf": [
                        {
                          "format": "uuid",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "brief_id": {
                      "anyOf": [
                        {
                          "format": "uuid",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "project_id": {
                      "anyOf": [
                        {
                          "format": "uuid",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "ad_account_id": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "brief_input": {
                      "$comment": "json-value"
                    },
                    "status": {
                      "anyOf": [
                        {
                          "type": "string",
                          "enum": [
                            "gathering"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "draft"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "approved"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "failed"
                          ]
                        }
                      ]
                    },
                    "platform_performance": {
                      "$comment": "json-value"
                    },
                    "tracker_attribution": {
                      "$comment": "json-value"
                    },
                    "ecommerce_data": {
                      "$comment": "json-value"
                    },
                    "business_context": {
                      "$comment": "json-value"
                    },
                    "competitor_intelligence": {
                      "$comment": "json-value"
                    },
                    "market_research": {
                      "$comment": "json-value"
                    },
                    "landing_page_analysis": {
                      "$comment": "json-value"
                    },
                    "sources_used": {
                      "type": "array",
                      "items": {
                        "$comment": "json-value"
                      }
                    },
                    "sources_missing": {
                      "type": "array",
                      "items": {
                        "$comment": "json-value"
                      }
                    },
                    "brief_gaps": {
                      "type": "array",
                      "items": {
                        "$comment": "json-value"
                      }
                    },
                    "confidence_score": {
                      "anyOf": [
                        {
                          "type": "number"
                        },
                        {
                          "type": "string"
                        }
                      ]
                    },
                    "gathering_duration_ms": {
                      "type": "integer"
                    },
                    "approved_at": {
                      "anyOf": [
                        {
                          "format": "date-time",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "approved_by": {
                      "anyOf": [
                        {
                          "format": "uuid",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "created_at": {
                      "format": "date-time",
                      "type": "string"
                    },
                    "updated_at": {
                      "format": "date-time",
                      "type": "string"
                    },
                    "edited_before_approval": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "Conflict - resource state prevents the operation",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/campaign-context/{briefId}/snapshot/sources": {
      "get": {
        "operationId": "getApiV1CampaignContextByBriefIdSnapshotSources",
        "summary": "Get source status for the latest campaign context snapshot",
        "tags": [
          "campaign-context"
        ],
        "description": "Returns source coverage, missing-source reasons, brief gaps, and confidence for the latest brief snapshot.",
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "briefId",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "id",
                    "status",
                    "confidence_score",
                    "sources_used",
                    "sources_missing",
                    "brief_gaps"
                  ],
                  "properties": {
                    "id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "status": {
                      "type": "string"
                    },
                    "confidence_score": {
                      "anyOf": [
                        {
                          "type": "number"
                        },
                        {
                          "type": "string"
                        }
                      ]
                    },
                    "sources_used": {
                      "type": "array",
                      "items": {
                        "$comment": "json-value"
                      }
                    },
                    "sources_missing": {
                      "type": "array",
                      "items": {
                        "$comment": "json-value"
                      }
                    },
                    "brief_gaps": {
                      "type": "array",
                      "items": {
                        "$comment": "json-value"
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/campaign-context/{briefId}/snapshot/approve": {
      "patch": {
        "operationId": "patchApiV1CampaignContextByBriefIdSnapshotApprove",
        "summary": "Approve latest context snapshot for a completed brief",
        "tags": [
          "campaign-context"
        ],
        "description": "Approves the latest draft snapshot for a completed brief and mirrors it into approved AI context.",
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "briefId",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "id",
                    "team_id",
                    "user_id",
                    "brief_id",
                    "project_id",
                    "ad_account_id",
                    "brief_input",
                    "status",
                    "platform_performance",
                    "tracker_attribution",
                    "ecommerce_data",
                    "business_context",
                    "competitor_intelligence",
                    "market_research",
                    "landing_page_analysis",
                    "sources_used",
                    "sources_missing",
                    "brief_gaps",
                    "confidence_score",
                    "gathering_duration_ms",
                    "approved_at",
                    "approved_by",
                    "created_at",
                    "updated_at"
                  ],
                  "properties": {
                    "id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "team_id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "user_id": {
                      "anyOf": [
                        {
                          "format": "uuid",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "brief_id": {
                      "anyOf": [
                        {
                          "format": "uuid",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "project_id": {
                      "anyOf": [
                        {
                          "format": "uuid",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "ad_account_id": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "brief_input": {
                      "$comment": "json-value"
                    },
                    "status": {
                      "anyOf": [
                        {
                          "type": "string",
                          "enum": [
                            "gathering"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "draft"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "approved"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "failed"
                          ]
                        }
                      ]
                    },
                    "platform_performance": {
                      "$comment": "json-value"
                    },
                    "tracker_attribution": {
                      "$comment": "json-value"
                    },
                    "ecommerce_data": {
                      "$comment": "json-value"
                    },
                    "business_context": {
                      "$comment": "json-value"
                    },
                    "competitor_intelligence": {
                      "$comment": "json-value"
                    },
                    "market_research": {
                      "$comment": "json-value"
                    },
                    "landing_page_analysis": {
                      "$comment": "json-value"
                    },
                    "sources_used": {
                      "type": "array",
                      "items": {
                        "$comment": "json-value"
                      }
                    },
                    "sources_missing": {
                      "type": "array",
                      "items": {
                        "$comment": "json-value"
                      }
                    },
                    "brief_gaps": {
                      "type": "array",
                      "items": {
                        "$comment": "json-value"
                      }
                    },
                    "confidence_score": {
                      "anyOf": [
                        {
                          "type": "number"
                        },
                        {
                          "type": "string"
                        }
                      ]
                    },
                    "gathering_duration_ms": {
                      "type": "integer"
                    },
                    "approved_at": {
                      "anyOf": [
                        {
                          "format": "date-time",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "approved_by": {
                      "anyOf": [
                        {
                          "format": "uuid",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "created_at": {
                      "format": "date-time",
                      "type": "string"
                    },
                    "updated_at": {
                      "format": "date-time",
                      "type": "string"
                    },
                    "edited_before_approval": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "Conflict - resource state prevents the operation",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/campaign-context/snapshots/{id}": {
      "get": {
        "operationId": "getApiV1CampaignContextSnapshotsById",
        "summary": "Get campaign context snapshot",
        "tags": [
          "campaign-context"
        ],
        "description": "Returns a campaign context snapshot by id within the accessible team scope.",
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "id",
                    "team_id",
                    "user_id",
                    "brief_id",
                    "project_id",
                    "ad_account_id",
                    "brief_input",
                    "status",
                    "platform_performance",
                    "tracker_attribution",
                    "ecommerce_data",
                    "business_context",
                    "competitor_intelligence",
                    "market_research",
                    "landing_page_analysis",
                    "sources_used",
                    "sources_missing",
                    "brief_gaps",
                    "confidence_score",
                    "gathering_duration_ms",
                    "approved_at",
                    "approved_by",
                    "created_at",
                    "updated_at"
                  ],
                  "properties": {
                    "id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "team_id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "user_id": {
                      "anyOf": [
                        {
                          "format": "uuid",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "brief_id": {
                      "anyOf": [
                        {
                          "format": "uuid",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "project_id": {
                      "anyOf": [
                        {
                          "format": "uuid",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "ad_account_id": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "brief_input": {
                      "$comment": "json-value"
                    },
                    "status": {
                      "anyOf": [
                        {
                          "type": "string",
                          "enum": [
                            "gathering"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "draft"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "approved"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "failed"
                          ]
                        }
                      ]
                    },
                    "platform_performance": {
                      "$comment": "json-value"
                    },
                    "tracker_attribution": {
                      "$comment": "json-value"
                    },
                    "ecommerce_data": {
                      "$comment": "json-value"
                    },
                    "business_context": {
                      "$comment": "json-value"
                    },
                    "competitor_intelligence": {
                      "$comment": "json-value"
                    },
                    "market_research": {
                      "$comment": "json-value"
                    },
                    "landing_page_analysis": {
                      "$comment": "json-value"
                    },
                    "sources_used": {
                      "type": "array",
                      "items": {
                        "$comment": "json-value"
                      }
                    },
                    "sources_missing": {
                      "type": "array",
                      "items": {
                        "$comment": "json-value"
                      }
                    },
                    "brief_gaps": {
                      "type": "array",
                      "items": {
                        "$comment": "json-value"
                      }
                    },
                    "confidence_score": {
                      "anyOf": [
                        {
                          "type": "number"
                        },
                        {
                          "type": "string"
                        }
                      ]
                    },
                    "gathering_duration_ms": {
                      "type": "integer"
                    },
                    "approved_at": {
                      "anyOf": [
                        {
                          "format": "date-time",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "approved_by": {
                      "anyOf": [
                        {
                          "format": "uuid",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "created_at": {
                      "format": "date-time",
                      "type": "string"
                    },
                    "updated_at": {
                      "format": "date-time",
                      "type": "string"
                    },
                    "edited_before_approval": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      },
      "patch": {
        "operationId": "patchApiV1CampaignContextSnapshotsById",
        "summary": "Patch editable context snapshot fields before approval",
        "tags": [
          "campaign-context"
        ],
        "description": "Updates editable JSON sections on a draft campaign context snapshot before approval.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "properties": {
                  "brief_input": {
                    "type": "object",
                    "additionalProperties": {
                      "$comment": "json-value"
                    }
                  },
                  "business_context": {
                    "$comment": "json-value"
                  },
                  "competitor_intelligence": {
                    "$comment": "json-value"
                  },
                  "ecommerce_data": {
                    "$comment": "json-value"
                  },
                  "landing_page_analysis": {
                    "$comment": "json-value"
                  },
                  "market_research": {
                    "$comment": "json-value"
                  },
                  "platform_performance": {
                    "$comment": "json-value"
                  },
                  "sources_missing": {
                    "type": "array",
                    "items": {
                      "$comment": "json-value"
                    }
                  },
                  "tracker_attribution": {
                    "$comment": "json-value"
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "id",
                    "team_id",
                    "user_id",
                    "brief_id",
                    "project_id",
                    "ad_account_id",
                    "brief_input",
                    "status",
                    "platform_performance",
                    "tracker_attribution",
                    "ecommerce_data",
                    "business_context",
                    "competitor_intelligence",
                    "market_research",
                    "landing_page_analysis",
                    "sources_used",
                    "sources_missing",
                    "brief_gaps",
                    "confidence_score",
                    "gathering_duration_ms",
                    "approved_at",
                    "approved_by",
                    "created_at",
                    "updated_at"
                  ],
                  "properties": {
                    "id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "team_id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "user_id": {
                      "anyOf": [
                        {
                          "format": "uuid",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "brief_id": {
                      "anyOf": [
                        {
                          "format": "uuid",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "project_id": {
                      "anyOf": [
                        {
                          "format": "uuid",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "ad_account_id": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "brief_input": {
                      "$comment": "json-value"
                    },
                    "status": {
                      "anyOf": [
                        {
                          "type": "string",
                          "enum": [
                            "gathering"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "draft"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "approved"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "failed"
                          ]
                        }
                      ]
                    },
                    "platform_performance": {
                      "$comment": "json-value"
                    },
                    "tracker_attribution": {
                      "$comment": "json-value"
                    },
                    "ecommerce_data": {
                      "$comment": "json-value"
                    },
                    "business_context": {
                      "$comment": "json-value"
                    },
                    "competitor_intelligence": {
                      "$comment": "json-value"
                    },
                    "market_research": {
                      "$comment": "json-value"
                    },
                    "landing_page_analysis": {
                      "$comment": "json-value"
                    },
                    "sources_used": {
                      "type": "array",
                      "items": {
                        "$comment": "json-value"
                      }
                    },
                    "sources_missing": {
                      "type": "array",
                      "items": {
                        "$comment": "json-value"
                      }
                    },
                    "brief_gaps": {
                      "type": "array",
                      "items": {
                        "$comment": "json-value"
                      }
                    },
                    "confidence_score": {
                      "anyOf": [
                        {
                          "type": "number"
                        },
                        {
                          "type": "string"
                        }
                      ]
                    },
                    "gathering_duration_ms": {
                      "type": "integer"
                    },
                    "approved_at": {
                      "anyOf": [
                        {
                          "format": "date-time",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "approved_by": {
                      "anyOf": [
                        {
                          "format": "uuid",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "created_at": {
                      "format": "date-time",
                      "type": "string"
                    },
                    "updated_at": {
                      "format": "date-time",
                      "type": "string"
                    },
                    "edited_before_approval": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "Conflict - resource state prevents the operation",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/campaign-context/snapshots/{id}/approve": {
      "post": {
        "operationId": "postApiV1CampaignContextSnapshotsByIdApprove",
        "summary": "Approve a context snapshot and freeze it for downstream AI modules",
        "tags": [
          "campaign-context"
        ],
        "description": "Marks a campaign context snapshot as approved and mirrors it into downstream AI context.",
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "id",
                    "team_id",
                    "user_id",
                    "brief_id",
                    "project_id",
                    "ad_account_id",
                    "brief_input",
                    "status",
                    "platform_performance",
                    "tracker_attribution",
                    "ecommerce_data",
                    "business_context",
                    "competitor_intelligence",
                    "market_research",
                    "landing_page_analysis",
                    "sources_used",
                    "sources_missing",
                    "brief_gaps",
                    "confidence_score",
                    "gathering_duration_ms",
                    "approved_at",
                    "approved_by",
                    "created_at",
                    "updated_at"
                  ],
                  "properties": {
                    "id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "team_id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "user_id": {
                      "anyOf": [
                        {
                          "format": "uuid",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "brief_id": {
                      "anyOf": [
                        {
                          "format": "uuid",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "project_id": {
                      "anyOf": [
                        {
                          "format": "uuid",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "ad_account_id": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "brief_input": {
                      "$comment": "json-value"
                    },
                    "status": {
                      "anyOf": [
                        {
                          "type": "string",
                          "enum": [
                            "gathering"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "draft"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "approved"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "failed"
                          ]
                        }
                      ]
                    },
                    "platform_performance": {
                      "$comment": "json-value"
                    },
                    "tracker_attribution": {
                      "$comment": "json-value"
                    },
                    "ecommerce_data": {
                      "$comment": "json-value"
                    },
                    "business_context": {
                      "$comment": "json-value"
                    },
                    "competitor_intelligence": {
                      "$comment": "json-value"
                    },
                    "market_research": {
                      "$comment": "json-value"
                    },
                    "landing_page_analysis": {
                      "$comment": "json-value"
                    },
                    "sources_used": {
                      "type": "array",
                      "items": {
                        "$comment": "json-value"
                      }
                    },
                    "sources_missing": {
                      "type": "array",
                      "items": {
                        "$comment": "json-value"
                      }
                    },
                    "brief_gaps": {
                      "type": "array",
                      "items": {
                        "$comment": "json-value"
                      }
                    },
                    "confidence_score": {
                      "anyOf": [
                        {
                          "type": "number"
                        },
                        {
                          "type": "string"
                        }
                      ]
                    },
                    "gathering_duration_ms": {
                      "type": "integer"
                    },
                    "approved_at": {
                      "anyOf": [
                        {
                          "format": "date-time",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "approved_by": {
                      "anyOf": [
                        {
                          "format": "uuid",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "created_at": {
                      "format": "date-time",
                      "type": "string"
                    },
                    "updated_at": {
                      "format": "date-time",
                      "type": "string"
                    },
                    "edited_before_approval": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/campaign-drafts": {
      "get": {
        "operationId": "listCampaignDrafts",
        "summary": "List campaign drafts",
        "tags": [
          "campaigns"
        ],
        "description": "Returns a paginated list of campaign drafts for the authenticated user, with optional status filtering.",
        "parameters": [
          {
            "schema": {
              "minimum": 1,
              "maximum": 100,
              "default": 20,
              "type": "integer"
            },
            "in": "query",
            "name": "limit",
            "required": false
          },
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "query",
            "name": "cursor",
            "required": false
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "status",
            "required": false
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "items",
                    "nextCursor"
                  ],
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "additionalProperties": false,
                        "type": "object",
                        "required": [
                          "id",
                          "account_id",
                          "name",
                          "source",
                          "status",
                          "platform",
                          "current_step",
                          "canonical_campaign",
                          "created_at",
                          "updated_at"
                        ],
                        "properties": {
                          "id": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "account_id": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "name": {
                            "type": "string"
                          },
                          "source": {
                            "type": "string"
                          },
                          "status": {
                            "type": "string"
                          },
                          "platform": {
                            "type": "string"
                          },
                          "current_step": {
                            "type": "integer"
                          },
                          "canonical_campaign": {
                            "$comment": "json-value",
                            "description": "Arbitrary JSON value with nested arrays and objects."
                          },
                          "created_at": {
                            "format": "date-time",
                            "type": "string"
                          },
                          "updated_at": {
                            "anyOf": [
                              {
                                "format": "date-time",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          }
                        },
                        "title": "PublicCampaignDraftResponse"
                      }
                    },
                    "nextCursor": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "error_code": {
                      "type": "string"
                    },
                    "detail": {}
                  }
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "createCampaignDraft",
        "summary": "Create a campaign draft",
        "tags": [
          "campaigns"
        ],
        "description": "Creates a new campaign draft with the given name, ad account, and canonical campaign structure.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "name"
                ],
                "properties": {
                  "name": {
                    "minLength": 1,
                    "maxLength": 500,
                    "type": "string"
                  },
                  "account_id": {
                    "type": "string"
                  },
                  "canonical_campaign": {
                    "additionalProperties": false,
                    "description": "Canonical campaign JSONB shape used by campaign drafts. Fields are optional because drafts are auto-saved while incomplete.",
                    "type": "object",
                    "properties": {
                      "accountId": {
                        "anyOf": [
                          {
                            "type": "string"
                          },
                          {
                            "type": "null"
                          }
                        ]
                      },
                      "adSets": {
                        "anyOf": [
                          {
                            "type": "array",
                            "items": {
                              "additionalProperties": false,
                              "type": "object",
                              "properties": {
                                "ads": {
                                  "anyOf": [
                                    {
                                      "type": "array",
                                      "items": {
                                        "additionalProperties": false,
                                        "type": "object",
                                        "properties": {
                                          "advantageCreative": {
                                            "anyOf": [
                                              {
                                                "type": "boolean"
                                              },
                                              {
                                                "type": "null"
                                              }
                                            ]
                                          },
                                          "callToAction": {
                                            "anyOf": [
                                              {
                                                "type": "string"
                                              },
                                              {
                                                "type": "null"
                                              }
                                            ]
                                          },
                                          "creativeFormat": {
                                            "anyOf": [
                                              {
                                                "anyOf": [
                                                  {
                                                    "type": "string",
                                                    "enum": [
                                                      "SINGLE_IMAGE"
                                                    ]
                                                  },
                                                  {
                                                    "type": "string",
                                                    "enum": [
                                                      "SINGLE_VIDEO"
                                                    ]
                                                  },
                                                  {
                                                    "type": "string",
                                                    "enum": [
                                                      "CAROUSEL"
                                                    ]
                                                  },
                                                  {
                                                    "type": "string",
                                                    "enum": [
                                                      "EXISTING_POST"
                                                    ]
                                                  },
                                                  {
                                                    "type": "string",
                                                    "enum": [
                                                      "CATALOG"
                                                    ]
                                                  },
                                                  {
                                                    "type": "string",
                                                    "enum": [
                                                      "FLEXIBLE"
                                                    ]
                                                  }
                                                ]
                                              },
                                              {
                                                "type": "null"
                                              }
                                            ]
                                          },
                                          "description": {
                                            "anyOf": [
                                              {
                                                "type": "string"
                                              },
                                              {
                                                "type": "null"
                                              }
                                            ]
                                          },
                                          "descriptionVariations": {
                                            "anyOf": [
                                              {
                                                "type": "array",
                                                "items": {
                                                  "type": "string"
                                                }
                                              },
                                              {
                                                "type": "null"
                                              }
                                            ]
                                          },
                                          "dynamicCreative": {
                                            "anyOf": [
                                              {
                                                "type": "boolean"
                                              },
                                              {
                                                "type": "null"
                                              }
                                            ]
                                          },
                                          "existingPostId": {
                                            "anyOf": [
                                              {
                                                "type": "string"
                                              },
                                              {
                                                "type": "null"
                                              }
                                            ]
                                          },
                                          "existingPostPreview": {
                                            "anyOf": [
                                              {
                                                "additionalProperties": false,
                                                "type": "object",
                                                "properties": {
                                                  "imageUrl": {
                                                    "anyOf": [
                                                      {
                                                        "type": "string"
                                                      },
                                                      {
                                                        "type": "null"
                                                      }
                                                    ]
                                                  },
                                                  "message": {
                                                    "anyOf": [
                                                      {
                                                        "type": "string"
                                                      },
                                                      {
                                                        "type": "null"
                                                      }
                                                    ]
                                                  }
                                                }
                                              },
                                              {
                                                "type": "null"
                                              }
                                            ]
                                          },
                                          "googleDescriptions": {
                                            "anyOf": [
                                              {
                                                "type": "array",
                                                "items": {
                                                  "type": "string"
                                                }
                                              },
                                              {
                                                "type": "null"
                                              }
                                            ]
                                          },
                                          "googleDisplayPath1": {
                                            "anyOf": [
                                              {
                                                "type": "string"
                                              },
                                              {
                                                "type": "null"
                                              }
                                            ]
                                          },
                                          "googleDisplayPath2": {
                                            "anyOf": [
                                              {
                                                "type": "string"
                                              },
                                              {
                                                "type": "null"
                                              }
                                            ]
                                          },
                                          "googleHeadlines": {
                                            "anyOf": [
                                              {
                                                "type": "array",
                                                "items": {
                                                  "type": "string"
                                                }
                                              },
                                              {
                                                "type": "null"
                                              }
                                            ]
                                          },
                                          "googleLogoAsset": {
                                            "anyOf": [
                                              {
                                                "additionalProperties": false,
                                                "type": "object",
                                                "properties": {
                                                  "aiGenerated": {
                                                    "anyOf": [
                                                      {
                                                        "type": "boolean"
                                                      },
                                                      {
                                                        "type": "null"
                                                      }
                                                    ]
                                                  },
                                                  "cardDescription": {
                                                    "anyOf": [
                                                      {
                                                        "type": "string"
                                                      },
                                                      {
                                                        "type": "null"
                                                      }
                                                    ]
                                                  },
                                                  "cardHeadline": {
                                                    "anyOf": [
                                                      {
                                                        "type": "string"
                                                      },
                                                      {
                                                        "type": "null"
                                                      }
                                                    ]
                                                  },
                                                  "crops": {
                                                    "anyOf": [
                                                      {
                                                        "additionalProperties": false,
                                                        "type": "object",
                                                        "properties": {
                                                          "100x100": {
                                                            "anyOf": [
                                                              {
                                                                "minItems": 2,
                                                                "maxItems": 2,
                                                                "type": "array",
                                                                "items": {
                                                                  "minItems": 2,
                                                                  "maxItems": 2,
                                                                  "type": "array",
                                                                  "items": {
                                                                    "type": "number"
                                                                  }
                                                                }
                                                              },
                                                              {
                                                                "type": "null"
                                                              }
                                                            ]
                                                          },
                                                          "191x100": {
                                                            "anyOf": [
                                                              {
                                                                "minItems": 2,
                                                                "maxItems": 2,
                                                                "type": "array",
                                                                "items": {
                                                                  "minItems": 2,
                                                                  "maxItems": 2,
                                                                  "type": "array",
                                                                  "items": {
                                                                    "type": "number"
                                                                  }
                                                                }
                                                              },
                                                              {
                                                                "type": "null"
                                                              }
                                                            ]
                                                          },
                                                          "400x500": {
                                                            "anyOf": [
                                                              {
                                                                "minItems": 2,
                                                                "maxItems": 2,
                                                                "type": "array",
                                                                "items": {
                                                                  "minItems": 2,
                                                                  "maxItems": 2,
                                                                  "type": "array",
                                                                  "items": {
                                                                    "type": "number"
                                                                  }
                                                                }
                                                              },
                                                              {
                                                                "type": "null"
                                                              }
                                                            ]
                                                          }
                                                        }
                                                      },
                                                      {
                                                        "type": "null"
                                                      }
                                                    ]
                                                  },
                                                  "duration": {
                                                    "anyOf": [
                                                      {
                                                        "type": "number"
                                                      },
                                                      {
                                                        "type": "null"
                                                      }
                                                    ]
                                                  },
                                                  "fileSizeBytes": {
                                                    "anyOf": [
                                                      {
                                                        "type": "number"
                                                      },
                                                      {
                                                        "type": "null"
                                                      }
                                                    ]
                                                  },
                                                  "height": {
                                                    "anyOf": [
                                                      {
                                                        "type": "number"
                                                      },
                                                      {
                                                        "type": "null"
                                                      }
                                                    ]
                                                  },
                                                  "metaHash": {
                                                    "anyOf": [
                                                      {
                                                        "type": "string"
                                                      },
                                                      {
                                                        "type": "null"
                                                      }
                                                    ]
                                                  },
                                                  "metaVideoId": {
                                                    "anyOf": [
                                                      {
                                                        "type": "string"
                                                      },
                                                      {
                                                        "type": "null"
                                                      }
                                                    ]
                                                  },
                                                  "snapchatMediaId": {
                                                    "anyOf": [
                                                      {
                                                        "type": "string"
                                                      },
                                                      {
                                                        "type": "null"
                                                      }
                                                    ]
                                                  },
                                                  "sourceUrl": {
                                                    "anyOf": [
                                                      {
                                                        "type": "string"
                                                      },
                                                      {
                                                        "type": "null"
                                                      }
                                                    ]
                                                  },
                                                  "thumbnailUrl": {
                                                    "anyOf": [
                                                      {
                                                        "type": "string"
                                                      },
                                                      {
                                                        "type": "null"
                                                      }
                                                    ]
                                                  },
                                                  "tiktokVideoId": {
                                                    "anyOf": [
                                                      {
                                                        "type": "string"
                                                      },
                                                      {
                                                        "type": "null"
                                                      }
                                                    ]
                                                  },
                                                  "type": {
                                                    "anyOf": [
                                                      {
                                                        "anyOf": [
                                                          {
                                                            "type": "string",
                                                            "enum": [
                                                              "image"
                                                            ]
                                                          },
                                                          {
                                                            "type": "string",
                                                            "enum": [
                                                              "video"
                                                            ]
                                                          }
                                                        ]
                                                      },
                                                      {
                                                        "type": "null"
                                                      }
                                                    ]
                                                  },
                                                  "videoId": {
                                                    "anyOf": [
                                                      {
                                                        "type": "string"
                                                      },
                                                      {
                                                        "type": "null"
                                                      }
                                                    ]
                                                  },
                                                  "width": {
                                                    "anyOf": [
                                                      {
                                                        "type": "number"
                                                      },
                                                      {
                                                        "type": "null"
                                                      }
                                                    ]
                                                  }
                                                }
                                              },
                                              {
                                                "type": "null"
                                              }
                                            ]
                                          },
                                          "googleYoutubeUrl": {
                                            "anyOf": [
                                              {
                                                "type": "string"
                                              },
                                              {
                                                "type": "null"
                                              }
                                            ]
                                          },
                                          "headline": {
                                            "anyOf": [
                                              {
                                                "type": "string"
                                              },
                                              {
                                                "type": "null"
                                              }
                                            ]
                                          },
                                          "headlineVariations": {
                                            "anyOf": [
                                              {
                                                "type": "array",
                                                "items": {
                                                  "type": "string"
                                                }
                                              },
                                              {
                                                "type": "null"
                                              }
                                            ]
                                          },
                                          "id": {
                                            "anyOf": [
                                              {
                                                "type": "string"
                                              },
                                              {
                                                "type": "null"
                                              }
                                            ]
                                          },
                                          "media": {
                                            "anyOf": [
                                              {
                                                "type": "array",
                                                "items": {
                                                  "additionalProperties": false,
                                                  "type": "object",
                                                  "properties": {
                                                    "aiGenerated": {
                                                      "anyOf": [
                                                        {
                                                          "type": "boolean"
                                                        },
                                                        {
                                                          "type": "null"
                                                        }
                                                      ]
                                                    },
                                                    "cardDescription": {
                                                      "anyOf": [
                                                        {
                                                          "type": "string"
                                                        },
                                                        {
                                                          "type": "null"
                                                        }
                                                      ]
                                                    },
                                                    "cardHeadline": {
                                                      "anyOf": [
                                                        {
                                                          "type": "string"
                                                        },
                                                        {
                                                          "type": "null"
                                                        }
                                                      ]
                                                    },
                                                    "crops": {
                                                      "anyOf": [
                                                        {
                                                          "additionalProperties": false,
                                                          "type": "object",
                                                          "properties": {
                                                            "100x100": {
                                                              "anyOf": [
                                                                {
                                                                  "minItems": 2,
                                                                  "maxItems": 2,
                                                                  "type": "array",
                                                                  "items": {
                                                                    "minItems": 2,
                                                                    "maxItems": 2,
                                                                    "type": "array",
                                                                    "items": {
                                                                      "type": "number"
                                                                    }
                                                                  }
                                                                },
                                                                {
                                                                  "type": "null"
                                                                }
                                                              ]
                                                            },
                                                            "191x100": {
                                                              "anyOf": [
                                                                {
                                                                  "minItems": 2,
                                                                  "maxItems": 2,
                                                                  "type": "array",
                                                                  "items": {
                                                                    "minItems": 2,
                                                                    "maxItems": 2,
                                                                    "type": "array",
                                                                    "items": {
                                                                      "type": "number"
                                                                    }
                                                                  }
                                                                },
                                                                {
                                                                  "type": "null"
                                                                }
                                                              ]
                                                            },
                                                            "400x500": {
                                                              "anyOf": [
                                                                {
                                                                  "minItems": 2,
                                                                  "maxItems": 2,
                                                                  "type": "array",
                                                                  "items": {
                                                                    "minItems": 2,
                                                                    "maxItems": 2,
                                                                    "type": "array",
                                                                    "items": {
                                                                      "type": "number"
                                                                    }
                                                                  }
                                                                },
                                                                {
                                                                  "type": "null"
                                                                }
                                                              ]
                                                            }
                                                          }
                                                        },
                                                        {
                                                          "type": "null"
                                                        }
                                                      ]
                                                    },
                                                    "duration": {
                                                      "anyOf": [
                                                        {
                                                          "type": "number"
                                                        },
                                                        {
                                                          "type": "null"
                                                        }
                                                      ]
                                                    },
                                                    "fileSizeBytes": {
                                                      "anyOf": [
                                                        {
                                                          "type": "number"
                                                        },
                                                        {
                                                          "type": "null"
                                                        }
                                                      ]
                                                    },
                                                    "height": {
                                                      "anyOf": [
                                                        {
                                                          "type": "number"
                                                        },
                                                        {
                                                          "type": "null"
                                                        }
                                                      ]
                                                    },
                                                    "metaHash": {
                                                      "anyOf": [
                                                        {
                                                          "type": "string"
                                                        },
                                                        {
                                                          "type": "null"
                                                        }
                                                      ]
                                                    },
                                                    "metaVideoId": {
                                                      "anyOf": [
                                                        {
                                                          "type": "string"
                                                        },
                                                        {
                                                          "type": "null"
                                                        }
                                                      ]
                                                    },
                                                    "snapchatMediaId": {
                                                      "anyOf": [
                                                        {
                                                          "type": "string"
                                                        },
                                                        {
                                                          "type": "null"
                                                        }
                                                      ]
                                                    },
                                                    "sourceUrl": {
                                                      "anyOf": [
                                                        {
                                                          "type": "string"
                                                        },
                                                        {
                                                          "type": "null"
                                                        }
                                                      ]
                                                    },
                                                    "thumbnailUrl": {
                                                      "anyOf": [
                                                        {
                                                          "type": "string"
                                                        },
                                                        {
                                                          "type": "null"
                                                        }
                                                      ]
                                                    },
                                                    "tiktokVideoId": {
                                                      "anyOf": [
                                                        {
                                                          "type": "string"
                                                        },
                                                        {
                                                          "type": "null"
                                                        }
                                                      ]
                                                    },
                                                    "type": {
                                                      "anyOf": [
                                                        {
                                                          "anyOf": [
                                                            {
                                                              "type": "string",
                                                              "enum": [
                                                                "image"
                                                              ]
                                                            },
                                                            {
                                                              "type": "string",
                                                              "enum": [
                                                                "video"
                                                              ]
                                                            }
                                                          ]
                                                        },
                                                        {
                                                          "type": "null"
                                                        }
                                                      ]
                                                    },
                                                    "videoId": {
                                                      "anyOf": [
                                                        {
                                                          "type": "string"
                                                        },
                                                        {
                                                          "type": "null"
                                                        }
                                                      ]
                                                    },
                                                    "width": {
                                                      "anyOf": [
                                                        {
                                                          "type": "number"
                                                        },
                                                        {
                                                          "type": "null"
                                                        }
                                                      ]
                                                    }
                                                  }
                                                }
                                              },
                                              {
                                                "type": "null"
                                              }
                                            ]
                                          },
                                          "multiAdvertiser": {
                                            "anyOf": [
                                              {
                                                "type": "boolean"
                                              },
                                              {
                                                "type": "null"
                                              }
                                            ]
                                          },
                                          "multilanguage": {
                                            "anyOf": [
                                              {
                                                "type": "boolean"
                                              },
                                              {
                                                "type": "null"
                                              }
                                            ]
                                          },
                                          "name": {
                                            "anyOf": [
                                              {
                                                "type": "string"
                                              },
                                              {
                                                "type": "null"
                                              }
                                            ]
                                          },
                                          "pageId": {
                                            "anyOf": [
                                              {
                                                "type": "string"
                                              },
                                              {
                                                "type": "null"
                                              }
                                            ]
                                          },
                                          "placementAssets": {
                                            "anyOf": [
                                              {
                                                "additionalProperties": false,
                                                "type": "object",
                                                "properties": {
                                                  "feed": {
                                                    "anyOf": [
                                                      {
                                                        "additionalProperties": false,
                                                        "type": "object",
                                                        "properties": {
                                                          "aiGenerated": {
                                                            "anyOf": [
                                                              {
                                                                "type": "boolean"
                                                              },
                                                              {
                                                                "type": "null"
                                                              }
                                                            ]
                                                          },
                                                          "cardDescription": {
                                                            "anyOf": [
                                                              {
                                                                "type": "string"
                                                              },
                                                              {
                                                                "type": "null"
                                                              }
                                                            ]
                                                          },
                                                          "cardHeadline": {
                                                            "anyOf": [
                                                              {
                                                                "type": "string"
                                                              },
                                                              {
                                                                "type": "null"
                                                              }
                                                            ]
                                                          },
                                                          "crops": {
                                                            "anyOf": [
                                                              {
                                                                "additionalProperties": false,
                                                                "type": "object",
                                                                "properties": {
                                                                  "100x100": {
                                                                    "anyOf": [
                                                                      {
                                                                        "minItems": 2,
                                                                        "maxItems": 2,
                                                                        "type": "array",
                                                                        "items": {
                                                                          "minItems": 2,
                                                                          "maxItems": 2,
                                                                          "type": "array",
                                                                          "items": {
                                                                            "type": "number"
                                                                          }
                                                                        }
                                                                      },
                                                                      {
                                                                        "type": "null"
                                                                      }
                                                                    ]
                                                                  },
                                                                  "191x100": {
                                                                    "anyOf": [
                                                                      {
                                                                        "minItems": 2,
                                                                        "maxItems": 2,
                                                                        "type": "array",
                                                                        "items": {
                                                                          "minItems": 2,
                                                                          "maxItems": 2,
                                                                          "type": "array",
                                                                          "items": {
                                                                            "type": "number"
                                                                          }
                                                                        }
                                                                      },
                                                                      {
                                                                        "type": "null"
                                                                      }
                                                                    ]
                                                                  },
                                                                  "400x500": {
                                                                    "anyOf": [
                                                                      {
                                                                        "minItems": 2,
                                                                        "maxItems": 2,
                                                                        "type": "array",
                                                                        "items": {
                                                                          "minItems": 2,
                                                                          "maxItems": 2,
                                                                          "type": "array",
                                                                          "items": {
                                                                            "type": "number"
                                                                          }
                                                                        }
                                                                      },
                                                                      {
                                                                        "type": "null"
                                                                      }
                                                                    ]
                                                                  }
                                                                }
                                                              },
                                                              {
                                                                "type": "null"
                                                              }
                                                            ]
                                                          },
                                                          "duration": {
                                                            "anyOf": [
                                                              {
                                                                "type": "number"
                                                              },
                                                              {
                                                                "type": "null"
                                                              }
                                                            ]
                                                          },
                                                          "fileSizeBytes": {
                                                            "anyOf": [
                                                              {
                                                                "type": "number"
                                                              },
                                                              {
                                                                "type": "null"
                                                              }
                                                            ]
                                                          },
                                                          "height": {
                                                            "anyOf": [
                                                              {
                                                                "type": "number"
                                                              },
                                                              {
                                                                "type": "null"
                                                              }
                                                            ]
                                                          },
                                                          "metaHash": {
                                                            "anyOf": [
                                                              {
                                                                "type": "string"
                                                              },
                                                              {
                                                                "type": "null"
                                                              }
                                                            ]
                                                          },
                                                          "metaVideoId": {
                                                            "anyOf": [
                                                              {
                                                                "type": "string"
                                                              },
                                                              {
                                                                "type": "null"
                                                              }
                                                            ]
                                                          },
                                                          "snapchatMediaId": {
                                                            "anyOf": [
                                                              {
                                                                "type": "string"
                                                              },
                                                              {
                                                                "type": "null"
                                                              }
                                                            ]
                                                          },
                                                          "sourceUrl": {
                                                            "anyOf": [
                                                              {
                                                                "type": "string"
                                                              },
                                                              {
                                                                "type": "null"
                                                              }
                                                            ]
                                                          },
                                                          "thumbnailUrl": {
                                                            "anyOf": [
                                                              {
                                                                "type": "string"
                                                              },
                                                              {
                                                                "type": "null"
                                                              }
                                                            ]
                                                          },
                                                          "tiktokVideoId": {
                                                            "anyOf": [
                                                              {
                                                                "type": "string"
                                                              },
                                                              {
                                                                "type": "null"
                                                              }
                                                            ]
                                                          },
                                                          "type": {
                                                            "anyOf": [
                                                              {
                                                                "anyOf": [
                                                                  {
                                                                    "type": "string",
                                                                    "enum": [
                                                                      "image"
                                                                    ]
                                                                  },
                                                                  {
                                                                    "type": "string",
                                                                    "enum": [
                                                                      "video"
                                                                    ]
                                                                  }
                                                                ]
                                                              },
                                                              {
                                                                "type": "null"
                                                              }
                                                            ]
                                                          },
                                                          "videoId": {
                                                            "anyOf": [
                                                              {
                                                                "type": "string"
                                                              },
                                                              {
                                                                "type": "null"
                                                              }
                                                            ]
                                                          },
                                                          "width": {
                                                            "anyOf": [
                                                              {
                                                                "type": "number"
                                                              },
                                                              {
                                                                "type": "null"
                                                              }
                                                            ]
                                                          }
                                                        }
                                                      },
                                                      {
                                                        "type": "null"
                                                      }
                                                    ]
                                                  },
                                                  "story": {
                                                    "anyOf": [
                                                      {
                                                        "additionalProperties": false,
                                                        "type": "object",
                                                        "properties": {
                                                          "aiGenerated": {
                                                            "anyOf": [
                                                              {
                                                                "type": "boolean"
                                                              },
                                                              {
                                                                "type": "null"
                                                              }
                                                            ]
                                                          },
                                                          "cardDescription": {
                                                            "anyOf": [
                                                              {
                                                                "type": "string"
                                                              },
                                                              {
                                                                "type": "null"
                                                              }
                                                            ]
                                                          },
                                                          "cardHeadline": {
                                                            "anyOf": [
                                                              {
                                                                "type": "string"
                                                              },
                                                              {
                                                                "type": "null"
                                                              }
                                                            ]
                                                          },
                                                          "crops": {
                                                            "anyOf": [
                                                              {
                                                                "additionalProperties": false,
                                                                "type": "object",
                                                                "properties": {
                                                                  "100x100": {
                                                                    "anyOf": [
                                                                      {
                                                                        "minItems": 2,
                                                                        "maxItems": 2,
                                                                        "type": "array",
                                                                        "items": {
                                                                          "minItems": 2,
                                                                          "maxItems": 2,
                                                                          "type": "array",
                                                                          "items": {
                                                                            "type": "number"
                                                                          }
                                                                        }
                                                                      },
                                                                      {
                                                                        "type": "null"
                                                                      }
                                                                    ]
                                                                  },
                                                                  "191x100": {
                                                                    "anyOf": [
                                                                      {
                                                                        "minItems": 2,
                                                                        "maxItems": 2,
                                                                        "type": "array",
                                                                        "items": {
                                                                          "minItems": 2,
                                                                          "maxItems": 2,
                                                                          "type": "array",
                                                                          "items": {
                                                                            "type": "number"
                                                                          }
                                                                        }
                                                                      },
                                                                      {
                                                                        "type": "null"
                                                                      }
                                                                    ]
                                                                  },
                                                                  "400x500": {
                                                                    "anyOf": [
                                                                      {
                                                                        "minItems": 2,
                                                                        "maxItems": 2,
                                                                        "type": "array",
                                                                        "items": {
                                                                          "minItems": 2,
                                                                          "maxItems": 2,
                                                                          "type": "array",
                                                                          "items": {
                                                                            "type": "number"
                                                                          }
                                                                        }
                                                                      },
                                                                      {
                                                                        "type": "null"
                                                                      }
                                                                    ]
                                                                  }
                                                                }
                                                              },
                                                              {
                                                                "type": "null"
                                                              }
                                                            ]
                                                          },
                                                          "duration": {
                                                            "anyOf": [
                                                              {
                                                                "type": "number"
                                                              },
                                                              {
                                                                "type": "null"
                                                              }
                                                            ]
                                                          },
                                                          "fileSizeBytes": {
                                                            "anyOf": [
                                                              {
                                                                "type": "number"
                                                              },
                                                              {
                                                                "type": "null"
                                                              }
                                                            ]
                                                          },
                                                          "height": {
                                                            "anyOf": [
                                                              {
                                                                "type": "number"
                                                              },
                                                              {
                                                                "type": "null"
                                                              }
                                                            ]
                                                          },
                                                          "metaHash": {
                                                            "anyOf": [
                                                              {
                                                                "type": "string"
                                                              },
                                                              {
                                                                "type": "null"
                                                              }
                                                            ]
                                                          },
                                                          "metaVideoId": {
                                                            "anyOf": [
                                                              {
                                                                "type": "string"
                                                              },
                                                              {
                                                                "type": "null"
                                                              }
                                                            ]
                                                          },
                                                          "snapchatMediaId": {
                                                            "anyOf": [
                                                              {
                                                                "type": "string"
                                                              },
                                                              {
                                                                "type": "null"
                                                              }
                                                            ]
                                                          },
                                                          "sourceUrl": {
                                                            "anyOf": [
                                                              {
                                                                "type": "string"
                                                              },
                                                              {
                                                                "type": "null"
                                                              }
                                                            ]
                                                          },
                                                          "thumbnailUrl": {
                                                            "anyOf": [
                                                              {
                                                                "type": "string"
                                                              },
                                                              {
                                                                "type": "null"
                                                              }
                                                            ]
                                                          },
                                                          "tiktokVideoId": {
                                                            "anyOf": [
                                                              {
                                                                "type": "string"
                                                              },
                                                              {
                                                                "type": "null"
                                                              }
                                                            ]
                                                          },
                                                          "type": {
                                                            "anyOf": [
                                                              {
                                                                "anyOf": [
                                                                  {
                                                                    "type": "string",
                                                                    "enum": [
                                                                      "image"
                                                                    ]
                                                                  },
                                                                  {
                                                                    "type": "string",
                                                                    "enum": [
                                                                      "video"
                                                                    ]
                                                                  }
                                                                ]
                                                              },
                                                              {
                                                                "type": "null"
                                                              }
                                                            ]
                                                          },
                                                          "videoId": {
                                                            "anyOf": [
                                                              {
                                                                "type": "string"
                                                              },
                                                              {
                                                                "type": "null"
                                                              }
                                                            ]
                                                          },
                                                          "width": {
                                                            "anyOf": [
                                                              {
                                                                "type": "number"
                                                              },
                                                              {
                                                                "type": "null"
                                                              }
                                                            ]
                                                          }
                                                        }
                                                      },
                                                      {
                                                        "type": "null"
                                                      }
                                                    ]
                                                  }
                                                }
                                              },
                                              {
                                                "type": "null"
                                              }
                                            ]
                                          },
                                          "placementCustomization": {
                                            "anyOf": [
                                              {
                                                "type": "boolean"
                                              },
                                              {
                                                "type": "null"
                                              }
                                            ]
                                          },
                                          "platformId": {
                                            "anyOf": [
                                              {
                                                "type": "string"
                                              },
                                              {
                                                "type": "null"
                                              }
                                            ]
                                          },
                                          "primaryText": {
                                            "anyOf": [
                                              {
                                                "type": "string"
                                              },
                                              {
                                                "type": "null"
                                              }
                                            ]
                                          },
                                          "primaryTextVariations": {
                                            "anyOf": [
                                              {
                                                "type": "array",
                                                "items": {
                                                  "type": "string"
                                                }
                                              },
                                              {
                                                "type": "null"
                                              }
                                            ]
                                          },
                                          "secondaryDescription": {
                                            "anyOf": [
                                              {
                                                "type": "string"
                                              },
                                              {
                                                "type": "null"
                                              }
                                            ]
                                          },
                                          "secondaryHeadline": {
                                            "anyOf": [
                                              {
                                                "type": "string"
                                              },
                                              {
                                                "type": "null"
                                              }
                                            ]
                                          },
                                          "secondaryLanguages": {
                                            "anyOf": [
                                              {
                                                "type": "array",
                                                "items": {
                                                  "type": "string"
                                                }
                                              },
                                              {
                                                "type": "null"
                                              }
                                            ]
                                          },
                                          "secondaryMedia": {
                                            "anyOf": [
                                              {
                                                "type": "array",
                                                "items": {
                                                  "additionalProperties": false,
                                                  "type": "object",
                                                  "properties": {
                                                    "aiGenerated": {
                                                      "anyOf": [
                                                        {
                                                          "type": "boolean"
                                                        },
                                                        {
                                                          "type": "null"
                                                        }
                                                      ]
                                                    },
                                                    "cardDescription": {
                                                      "anyOf": [
                                                        {
                                                          "type": "string"
                                                        },
                                                        {
                                                          "type": "null"
                                                        }
                                                      ]
                                                    },
                                                    "cardHeadline": {
                                                      "anyOf": [
                                                        {
                                                          "type": "string"
                                                        },
                                                        {
                                                          "type": "null"
                                                        }
                                                      ]
                                                    },
                                                    "crops": {
                                                      "anyOf": [
                                                        {
                                                          "additionalProperties": false,
                                                          "type": "object",
                                                          "properties": {
                                                            "100x100": {
                                                              "anyOf": [
                                                                {
                                                                  "minItems": 2,
                                                                  "maxItems": 2,
                                                                  "type": "array",
                                                                  "items": {
                                                                    "minItems": 2,
                                                                    "maxItems": 2,
                                                                    "type": "array",
                                                                    "items": {
                                                                      "type": "number"
                                                                    }
                                                                  }
                                                                },
                                                                {
                                                                  "type": "null"
                                                                }
                                                              ]
                                                            },
                                                            "191x100": {
                                                              "anyOf": [
                                                                {
                                                                  "minItems": 2,
                                                                  "maxItems": 2,
                                                                  "type": "array",
                                                                  "items": {
                                                                    "minItems": 2,
                                                                    "maxItems": 2,
                                                                    "type": "array",
                                                                    "items": {
                                                                      "type": "number"
                                                                    }
                                                                  }
                                                                },
                                                                {
                                                                  "type": "null"
                                                                }
                                                              ]
                                                            },
                                                            "400x500": {
                                                              "anyOf": [
                                                                {
                                                                  "minItems": 2,
                                                                  "maxItems": 2,
                                                                  "type": "array",
                                                                  "items": {
                                                                    "minItems": 2,
                                                                    "maxItems": 2,
                                                                    "type": "array",
                                                                    "items": {
                                                                      "type": "number"
                                                                    }
                                                                  }
                                                                },
                                                                {
                                                                  "type": "null"
                                                                }
                                                              ]
                                                            }
                                                          }
                                                        },
                                                        {
                                                          "type": "null"
                                                        }
                                                      ]
                                                    },
                                                    "duration": {
                                                      "anyOf": [
                                                        {
                                                          "type": "number"
                                                        },
                                                        {
                                                          "type": "null"
                                                        }
                                                      ]
                                                    },
                                                    "fileSizeBytes": {
                                                      "anyOf": [
                                                        {
                                                          "type": "number"
                                                        },
                                                        {
                                                          "type": "null"
                                                        }
                                                      ]
                                                    },
                                                    "height": {
                                                      "anyOf": [
                                                        {
                                                          "type": "number"
                                                        },
                                                        {
                                                          "type": "null"
                                                        }
                                                      ]
                                                    },
                                                    "metaHash": {
                                                      "anyOf": [
                                                        {
                                                          "type": "string"
                                                        },
                                                        {
                                                          "type": "null"
                                                        }
                                                      ]
                                                    },
                                                    "metaVideoId": {
                                                      "anyOf": [
                                                        {
                                                          "type": "string"
                                                        },
                                                        {
                                                          "type": "null"
                                                        }
                                                      ]
                                                    },
                                                    "snapchatMediaId": {
                                                      "anyOf": [
                                                        {
                                                          "type": "string"
                                                        },
                                                        {
                                                          "type": "null"
                                                        }
                                                      ]
                                                    },
                                                    "sourceUrl": {
                                                      "anyOf": [
                                                        {
                                                          "type": "string"
                                                        },
                                                        {
                                                          "type": "null"
                                                        }
                                                      ]
                                                    },
                                                    "thumbnailUrl": {
                                                      "anyOf": [
                                                        {
                                                          "type": "string"
                                                        },
                                                        {
                                                          "type": "null"
                                                        }
                                                      ]
                                                    },
                                                    "tiktokVideoId": {
                                                      "anyOf": [
                                                        {
                                                          "type": "string"
                                                        },
                                                        {
                                                          "type": "null"
                                                        }
                                                      ]
                                                    },
                                                    "type": {
                                                      "anyOf": [
                                                        {
                                                          "anyOf": [
                                                            {
                                                              "type": "string",
                                                              "enum": [
                                                                "image"
                                                              ]
                                                            },
                                                            {
                                                              "type": "string",
                                                              "enum": [
                                                                "video"
                                                              ]
                                                            }
                                                          ]
                                                        },
                                                        {
                                                          "type": "null"
                                                        }
                                                      ]
                                                    },
                                                    "videoId": {
                                                      "anyOf": [
                                                        {
                                                          "type": "string"
                                                        },
                                                        {
                                                          "type": "null"
                                                        }
                                                      ]
                                                    },
                                                    "width": {
                                                      "anyOf": [
                                                        {
                                                          "type": "number"
                                                        },
                                                        {
                                                          "type": "null"
                                                        }
                                                      ]
                                                    }
                                                  }
                                                }
                                              },
                                              {
                                                "type": "null"
                                              }
                                            ]
                                          },
                                          "secondaryPrimaryText": {
                                            "anyOf": [
                                              {
                                                "type": "string"
                                              },
                                              {
                                                "type": "null"
                                              }
                                            ]
                                          },
                                          "secondaryUrl": {
                                            "anyOf": [
                                              {
                                                "type": "string"
                                              },
                                              {
                                                "type": "null"
                                              }
                                            ]
                                          },
                                          "snapchatAdDisclaimer": {
                                            "anyOf": [
                                              {
                                                "type": "string"
                                              },
                                              {
                                                "type": "null"
                                              }
                                            ]
                                          },
                                          "snapchatAdFavoriting": {
                                            "anyOf": [
                                              {
                                                "type": "boolean"
                                              },
                                              {
                                                "type": "null"
                                              }
                                            ]
                                          },
                                          "snapchatAdType": {
                                            "anyOf": [
                                              {
                                                "type": "string"
                                              },
                                              {
                                                "type": "null"
                                              }
                                            ]
                                          },
                                          "snapchatAppIconMediaId": {
                                            "anyOf": [
                                              {
                                                "type": "string"
                                              },
                                              {
                                                "type": "null"
                                              }
                                            ]
                                          },
                                          "snapchatBrandName": {
                                            "anyOf": [
                                              {
                                                "type": "string"
                                              },
                                              {
                                                "type": "null"
                                              }
                                            ]
                                          },
                                          "snapchatDeepLinkUri": {
                                            "anyOf": [
                                              {
                                                "type": "string"
                                              },
                                              {
                                                "type": "null"
                                              }
                                            ]
                                          },
                                          "snapchatMessageText": {
                                            "anyOf": [
                                              {
                                                "type": "string"
                                              },
                                              {
                                                "type": "null"
                                              }
                                            ]
                                          },
                                          "snapchatPhoneNumberId": {
                                            "anyOf": [
                                              {
                                                "type": "string"
                                              },
                                              {
                                                "type": "null"
                                              }
                                            ]
                                          },
                                          "snapchatShareable": {
                                            "anyOf": [
                                              {
                                                "type": "boolean"
                                              },
                                              {
                                                "type": "null"
                                              }
                                            ]
                                          },
                                          "snapchatSmartPrefetching": {
                                            "anyOf": [
                                              {
                                                "type": "boolean"
                                              },
                                              {
                                                "type": "null"
                                              }
                                            ]
                                          },
                                          "status": {
                                            "anyOf": [
                                              {
                                                "anyOf": [
                                                  {
                                                    "type": "string",
                                                    "enum": [
                                                      "ACTIVE"
                                                    ]
                                                  },
                                                  {
                                                    "type": "string",
                                                    "enum": [
                                                      "PAUSED"
                                                    ]
                                                  }
                                                ]
                                              },
                                              {
                                                "type": "null"
                                              }
                                            ]
                                          },
                                          "taboolaCta": {
                                            "anyOf": [
                                              {
                                                "type": "string"
                                              },
                                              {
                                                "type": "null"
                                              }
                                            ]
                                          },
                                          "taboolaHeadlines": {
                                            "anyOf": [
                                              {
                                                "type": "array",
                                                "items": {
                                                  "type": "string"
                                                }
                                              },
                                              {
                                                "type": "null"
                                              }
                                            ]
                                          },
                                          "targetLanguage": {
                                            "anyOf": [
                                              {
                                                "type": "string"
                                              },
                                              {
                                                "type": "null"
                                              }
                                            ]
                                          },
                                          "unmatchedAudienceVideo": {
                                            "anyOf": [
                                              {
                                                "anyOf": [
                                                  {
                                                    "type": "string",
                                                    "enum": [
                                                      "safe"
                                                    ]
                                                  },
                                                  {
                                                    "type": "string",
                                                    "enum": [
                                                      "targeted"
                                                    ]
                                                  }
                                                ]
                                              },
                                              {
                                                "type": "null"
                                              }
                                            ]
                                          },
                                          "url": {
                                            "anyOf": [
                                              {
                                                "type": "string"
                                              },
                                              {
                                                "type": "null"
                                              }
                                            ]
                                          },
                                          "urlParameters": {
                                            "anyOf": [
                                              {
                                                "type": "string"
                                              },
                                              {
                                                "type": "null"
                                              }
                                            ]
                                          }
                                        }
                                      }
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "attribution": {
                                  "anyOf": [
                                    {
                                      "additionalProperties": false,
                                      "type": "object",
                                      "properties": {
                                        "clickWindow": {
                                          "anyOf": [
                                            {
                                              "anyOf": [
                                                {
                                                  "type": "number",
                                                  "enum": [
                                                    1
                                                  ]
                                                },
                                                {
                                                  "type": "number",
                                                  "enum": [
                                                    7
                                                  ]
                                                }
                                              ]
                                            },
                                            {
                                              "type": "null"
                                            }
                                          ]
                                        },
                                        "viewWindow": {
                                          "anyOf": [
                                            {
                                              "anyOf": [
                                                {
                                                  "type": "number",
                                                  "enum": [
                                                    0
                                                  ]
                                                },
                                                {
                                                  "type": "number",
                                                  "enum": [
                                                    1
                                                  ]
                                                }
                                              ]
                                            },
                                            {
                                              "type": "null"
                                            }
                                          ]
                                        }
                                      }
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "bidAmount": {
                                  "anyOf": [
                                    {
                                      "type": "number"
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "billingEvent": {
                                  "anyOf": [
                                    {
                                      "type": "string"
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "budget": {
                                  "anyOf": [
                                    {
                                      "type": "number"
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "budgetType": {
                                  "anyOf": [
                                    {
                                      "anyOf": [
                                        {
                                          "type": "string",
                                          "enum": [
                                            "DAILY"
                                          ]
                                        },
                                        {
                                          "type": "string",
                                          "enum": [
                                            "LIFETIME"
                                          ]
                                        }
                                      ]
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "customAudiences": {
                                  "anyOf": [
                                    {
                                      "type": "array",
                                      "items": {
                                        "type": "string"
                                      }
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "destinationType": {
                                  "anyOf": [
                                    {
                                      "type": "string"
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "dsaFields": {
                                  "anyOf": [
                                    {
                                      "additionalProperties": false,
                                      "type": "object",
                                      "properties": {
                                        "beneficiary": {
                                          "anyOf": [
                                            {
                                              "type": "string"
                                            },
                                            {
                                              "type": "null"
                                            }
                                          ]
                                        },
                                        "payer": {
                                          "anyOf": [
                                            {
                                              "type": "string"
                                            },
                                            {
                                              "type": "null"
                                            }
                                          ]
                                        }
                                      }
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "endDate": {
                                  "anyOf": [
                                    {
                                      "type": "string"
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "endTime": {
                                  "anyOf": [
                                    {
                                      "type": "string"
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "excludedAudiences": {
                                  "anyOf": [
                                    {
                                      "type": "array",
                                      "items": {
                                        "type": "string"
                                      }
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "id": {
                                  "anyOf": [
                                    {
                                      "type": "string"
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "keywords": {
                                  "anyOf": [
                                    {
                                      "type": "string"
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "metaLeadFormId": {
                                  "anyOf": [
                                    {
                                      "type": "string"
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "name": {
                                  "anyOf": [
                                    {
                                      "type": "string"
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "optimizationGoal": {
                                  "anyOf": [
                                    {
                                      "type": "string"
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "placements": {
                                  "anyOf": [
                                    {
                                      "additionalProperties": false,
                                      "type": "object",
                                      "properties": {
                                        "audienceNetworkPositions": {
                                          "anyOf": [
                                            {
                                              "type": "array",
                                              "items": {
                                                "type": "string"
                                              }
                                            },
                                            {
                                              "type": "null"
                                            }
                                          ]
                                        },
                                        "automatic": {
                                          "anyOf": [
                                            {
                                              "type": "boolean"
                                            },
                                            {
                                              "type": "null"
                                            }
                                          ]
                                        },
                                        "facebookPositions": {
                                          "anyOf": [
                                            {
                                              "type": "array",
                                              "items": {
                                                "type": "string"
                                              }
                                            },
                                            {
                                              "type": "null"
                                            }
                                          ]
                                        },
                                        "instagramPositions": {
                                          "anyOf": [
                                            {
                                              "type": "array",
                                              "items": {
                                                "type": "string"
                                              }
                                            },
                                            {
                                              "type": "null"
                                            }
                                          ]
                                        },
                                        "messengerPositions": {
                                          "anyOf": [
                                            {
                                              "type": "array",
                                              "items": {
                                                "type": "string"
                                              }
                                            },
                                            {
                                              "type": "null"
                                            }
                                          ]
                                        },
                                        "publisherPlatforms": {
                                          "anyOf": [
                                            {
                                              "type": "array",
                                              "items": {
                                                "anyOf": [
                                                  {
                                                    "type": "string",
                                                    "enum": [
                                                      "facebook"
                                                    ]
                                                  },
                                                  {
                                                    "type": "string",
                                                    "enum": [
                                                      "instagram"
                                                    ]
                                                  },
                                                  {
                                                    "type": "string",
                                                    "enum": [
                                                      "audience_network"
                                                    ]
                                                  },
                                                  {
                                                    "type": "string",
                                                    "enum": [
                                                      "messenger"
                                                    ]
                                                  },
                                                  {
                                                    "type": "string",
                                                    "enum": [
                                                      "threads"
                                                    ]
                                                  }
                                                ]
                                              }
                                            },
                                            {
                                              "type": "null"
                                            }
                                          ]
                                        },
                                        "snapchatBrandSuitability": {
                                          "anyOf": [
                                            {
                                              "type": "string"
                                            },
                                            {
                                              "type": "null"
                                            }
                                          ]
                                        },
                                        "snapchatConfig": {
                                          "anyOf": [
                                            {
                                              "type": "string"
                                            },
                                            {
                                              "type": "null"
                                            }
                                          ]
                                        },
                                        "snapchatCustomType": {
                                          "anyOf": [
                                            {
                                              "type": "string"
                                            },
                                            {
                                              "type": "null"
                                            }
                                          ]
                                        },
                                        "snapchatPositions": {
                                          "anyOf": [
                                            {
                                              "type": "array",
                                              "items": {
                                                "type": "string"
                                              }
                                            },
                                            {
                                              "type": "null"
                                            }
                                          ]
                                        },
                                        "threadsPositions": {
                                          "anyOf": [
                                            {
                                              "type": "array",
                                              "items": {
                                                "type": "string"
                                              }
                                            },
                                            {
                                              "type": "null"
                                            }
                                          ]
                                        }
                                      }
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "platformId": {
                                  "anyOf": [
                                    {
                                      "type": "string"
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "promotedObject": {
                                  "anyOf": [
                                    {
                                      "additionalProperties": false,
                                      "type": "object",
                                      "properties": {
                                        "appId": {
                                          "anyOf": [
                                            {
                                              "type": "string"
                                            },
                                            {
                                              "type": "null"
                                            }
                                          ]
                                        },
                                        "catalogId": {
                                          "anyOf": [
                                            {
                                              "type": "string"
                                            },
                                            {
                                              "type": "null"
                                            }
                                          ]
                                        },
                                        "customEventType": {
                                          "anyOf": [
                                            {
                                              "type": "string"
                                            },
                                            {
                                              "type": "null"
                                            }
                                          ]
                                        },
                                        "objectStoreUrl": {
                                          "anyOf": [
                                            {
                                              "type": "string"
                                            },
                                            {
                                              "type": "null"
                                            }
                                          ]
                                        },
                                        "pageId": {
                                          "anyOf": [
                                            {
                                              "type": "string"
                                            },
                                            {
                                              "type": "null"
                                            }
                                          ]
                                        },
                                        "pixelId": {
                                          "anyOf": [
                                            {
                                              "type": "string"
                                            },
                                            {
                                              "type": "null"
                                            }
                                          ]
                                        },
                                        "productSetId": {
                                          "anyOf": [
                                            {
                                              "type": "string"
                                            },
                                            {
                                              "type": "null"
                                            }
                                          ]
                                        }
                                      }
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "roasFloor": {
                                  "anyOf": [
                                    {
                                      "type": "number"
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "snapchatAppId": {
                                  "anyOf": [
                                    {
                                      "type": "string"
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "snapchatAudienceType": {
                                  "anyOf": [
                                    {
                                      "anyOf": [
                                        {
                                          "type": "string",
                                          "enum": [
                                            "PROSPECTING"
                                          ]
                                        },
                                        {
                                          "type": "string",
                                          "enum": [
                                            "RETARGETING"
                                          ]
                                        }
                                      ]
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "snapchatCatalogId": {
                                  "anyOf": [
                                    {
                                      "type": "string"
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "snapchatConversionLocation": {
                                  "anyOf": [
                                    {
                                      "type": "string"
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "snapchatLeadFormId": {
                                  "anyOf": [
                                    {
                                      "type": "string"
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "snapchatPixelId": {
                                  "anyOf": [
                                    {
                                      "type": "string"
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "snapchatProductSetId": {
                                  "anyOf": [
                                    {
                                      "type": "string"
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "spendPercent": {
                                  "anyOf": [
                                    {
                                      "minimum": 1,
                                      "maximum": 100,
                                      "type": "number"
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "startDate": {
                                  "anyOf": [
                                    {
                                      "type": "string"
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "startTime": {
                                  "anyOf": [
                                    {
                                      "type": "string"
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "status": {
                                  "anyOf": [
                                    {
                                      "anyOf": [
                                        {
                                          "type": "string",
                                          "enum": [
                                            "ACTIVE"
                                          ]
                                        },
                                        {
                                          "type": "string",
                                          "enum": [
                                            "PAUSED"
                                          ]
                                        }
                                      ]
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "targeting": {
                                  "anyOf": [
                                    {
                                      "additionalProperties": false,
                                      "type": "object",
                                      "properties": {
                                        "advantageAge": {
                                          "anyOf": [
                                            {
                                              "type": "boolean"
                                            },
                                            {
                                              "type": "null"
                                            }
                                          ]
                                        },
                                        "advantageAudience": {
                                          "anyOf": [
                                            {
                                              "type": "boolean"
                                            },
                                            {
                                              "type": "null"
                                            }
                                          ]
                                        },
                                        "advantageDetailedTargeting": {
                                          "anyOf": [
                                            {
                                              "type": "boolean"
                                            },
                                            {
                                              "type": "null"
                                            }
                                          ]
                                        },
                                        "advantageGender": {
                                          "anyOf": [
                                            {
                                              "type": "boolean"
                                            },
                                            {
                                              "type": "null"
                                            }
                                          ]
                                        },
                                        "advantageLookalike": {
                                          "anyOf": [
                                            {
                                              "type": "boolean"
                                            },
                                            {
                                              "type": "null"
                                            }
                                          ]
                                        },
                                        "ageMax": {
                                          "anyOf": [
                                            {
                                              "type": "number"
                                            },
                                            {
                                              "type": "null"
                                            }
                                          ]
                                        },
                                        "ageMin": {
                                          "anyOf": [
                                            {
                                              "type": "number"
                                            },
                                            {
                                              "type": "null"
                                            }
                                          ]
                                        },
                                        "countries": {
                                          "anyOf": [
                                            {
                                              "type": "array",
                                              "items": {
                                                "type": "string"
                                              }
                                            },
                                            {
                                              "type": "null"
                                            }
                                          ]
                                        },
                                        "devicePlatforms": {
                                          "anyOf": [
                                            {
                                              "type": "array",
                                              "items": {
                                                "anyOf": [
                                                  {
                                                    "type": "string",
                                                    "enum": [
                                                      "mobile"
                                                    ]
                                                  },
                                                  {
                                                    "type": "string",
                                                    "enum": [
                                                      "desktop"
                                                    ]
                                                  }
                                                ]
                                              }
                                            },
                                            {
                                              "type": "null"
                                            }
                                          ]
                                        },
                                        "genders": {
                                          "anyOf": [
                                            {
                                              "type": "array",
                                              "items": {
                                                "type": "number"
                                              }
                                            },
                                            {
                                              "type": "null"
                                            }
                                          ]
                                        },
                                        "locales": {
                                          "anyOf": [
                                            {
                                              "type": "array",
                                              "items": {
                                                "type": "number"
                                              }
                                            },
                                            {
                                              "type": "null"
                                            }
                                          ]
                                        },
                                        "locations": {
                                          "anyOf": [
                                            {
                                              "type": "array",
                                              "items": {
                                                "additionalProperties": false,
                                                "type": "object",
                                                "required": [
                                                  "countryCode",
                                                  "key",
                                                  "name",
                                                  "type"
                                                ],
                                                "properties": {
                                                  "countryCode": {
                                                    "type": "string"
                                                  },
                                                  "distanceUnit": {
                                                    "anyOf": [
                                                      {
                                                        "type": "string"
                                                      },
                                                      {
                                                        "type": "null"
                                                      }
                                                    ]
                                                  },
                                                  "key": {
                                                    "type": "string"
                                                  },
                                                  "name": {
                                                    "type": "string"
                                                  },
                                                  "radius": {
                                                    "anyOf": [
                                                      {
                                                        "minimum": 10,
                                                        "maximum": 80,
                                                        "type": "number"
                                                      },
                                                      {
                                                        "type": "null"
                                                      }
                                                    ]
                                                  },
                                                  "region": {
                                                    "anyOf": [
                                                      {
                                                        "type": "string"
                                                      },
                                                      {
                                                        "type": "null"
                                                      }
                                                    ]
                                                  },
                                                  "type": {
                                                    "anyOf": [
                                                      {
                                                        "type": "string",
                                                        "enum": [
                                                          "region"
                                                        ]
                                                      },
                                                      {
                                                        "type": "string",
                                                        "enum": [
                                                          "city"
                                                        ]
                                                      }
                                                    ]
                                                  }
                                                }
                                              }
                                            },
                                            {
                                              "type": "null"
                                            }
                                          ]
                                        },
                                        "operatingSystems": {
                                          "anyOf": [
                                            {
                                              "type": "array",
                                              "items": {
                                                "type": "string"
                                              }
                                            },
                                            {
                                              "type": "null"
                                            }
                                          ]
                                        }
                                      }
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                }
                              }
                            }
                          },
                          {
                            "type": "null"
                          }
                        ]
                      },
                      "campaign": {
                        "anyOf": [
                          {
                            "additionalProperties": false,
                            "type": "object",
                            "properties": {
                              "acceleratedDelivery": {
                                "anyOf": [
                                  {
                                    "type": "boolean"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "advantagePlus": {
                                "anyOf": [
                                  {
                                    "type": "boolean"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "bidStrategy": {
                                "anyOf": [
                                  {
                                    "type": "string"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "budget": {
                                "anyOf": [
                                  {
                                    "type": "number"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "budgetLevel": {
                                "anyOf": [
                                  {
                                    "anyOf": [
                                      {
                                        "type": "string",
                                        "enum": [
                                          "CBO"
                                        ]
                                      },
                                      {
                                        "type": "string",
                                        "enum": [
                                          "ABO"
                                        ]
                                      }
                                    ]
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "budgetType": {
                                "anyOf": [
                                  {
                                    "anyOf": [
                                      {
                                        "type": "string",
                                        "enum": [
                                          "DAILY"
                                        ]
                                      },
                                      {
                                        "type": "string",
                                        "enum": [
                                          "LIFETIME"
                                        ]
                                      }
                                    ]
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "buyingType": {
                                "anyOf": [
                                  {
                                    "anyOf": [
                                      {
                                        "type": "string",
                                        "enum": [
                                          "AUCTION"
                                        ]
                                      },
                                      {
                                        "type": "string",
                                        "enum": [
                                          "RESERVED"
                                        ]
                                      }
                                    ]
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "customerAcquisition": {
                                "anyOf": [
                                  {
                                    "type": "boolean"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "googleGoal": {
                                "anyOf": [
                                  {
                                    "anyOf": [
                                      {
                                        "type": "string",
                                        "enum": [
                                          "SALES"
                                        ]
                                      },
                                      {
                                        "type": "string",
                                        "enum": [
                                          "LEADS"
                                        ]
                                      },
                                      {
                                        "type": "string",
                                        "enum": [
                                          "WEBSITE_TRAFFIC"
                                        ]
                                      },
                                      {
                                        "type": "string",
                                        "enum": [
                                          "APP_PROMOTION"
                                        ]
                                      },
                                      {
                                        "type": "string",
                                        "enum": [
                                          "AWARENESS"
                                        ]
                                      },
                                      {
                                        "type": "string",
                                        "enum": [
                                          "LOCAL_STORE"
                                        ]
                                      },
                                      {
                                        "type": "string",
                                        "enum": [
                                          "NO_GOAL"
                                        ]
                                      }
                                    ]
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "googleMerchantId": {
                                "anyOf": [
                                  {
                                    "type": "string"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "metaLeadFormId": {
                                "anyOf": [
                                  {
                                    "type": "string"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "metaTokenId": {
                                "anyOf": [
                                  {
                                    "type": "string"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "name": {
                                "anyOf": [
                                  {
                                    "type": "string"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "objective": {
                                "anyOf": [
                                  {
                                    "type": "string"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "outbrainBudgetPacing": {
                                "anyOf": [
                                  {
                                    "anyOf": [
                                      {
                                        "type": "string",
                                        "enum": [
                                          "DAILY"
                                        ]
                                      },
                                      {
                                        "type": "string",
                                        "enum": [
                                          "MONTHLY"
                                        ]
                                      },
                                      {
                                        "type": "string",
                                        "enum": [
                                          "ENTIRE"
                                        ]
                                      }
                                    ]
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "outbrainConversionGoalId": {
                                "anyOf": [
                                  {
                                    "type": "string"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "outbrainCpcCents": {
                                "anyOf": [
                                  {
                                    "type": "number"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "outbrainCurrency": {
                                "anyOf": [
                                  {
                                    "type": "string"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "outbrainDailyBudgetCents": {
                                "anyOf": [
                                  {
                                    "type": "number"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "outbrainDayparting": {
                                "anyOf": [
                                  {
                                    "additionalProperties": false,
                                    "type": "object",
                                    "properties": {
                                      "FRIDAY": {
                                        "anyOf": [
                                          {
                                            "type": "array",
                                            "items": {
                                              "minimum": 0,
                                              "maximum": 23,
                                              "type": "integer"
                                            }
                                          },
                                          {
                                            "type": "null"
                                          }
                                        ]
                                      },
                                      "MONDAY": {
                                        "anyOf": [
                                          {
                                            "type": "array",
                                            "items": {
                                              "minimum": 0,
                                              "maximum": 23,
                                              "type": "integer"
                                            }
                                          },
                                          {
                                            "type": "null"
                                          }
                                        ]
                                      },
                                      "SATURDAY": {
                                        "anyOf": [
                                          {
                                            "type": "array",
                                            "items": {
                                              "minimum": 0,
                                              "maximum": 23,
                                              "type": "integer"
                                            }
                                          },
                                          {
                                            "type": "null"
                                          }
                                        ]
                                      },
                                      "SUNDAY": {
                                        "anyOf": [
                                          {
                                            "type": "array",
                                            "items": {
                                              "minimum": 0,
                                              "maximum": 23,
                                              "type": "integer"
                                            }
                                          },
                                          {
                                            "type": "null"
                                          }
                                        ]
                                      },
                                      "THURSDAY": {
                                        "anyOf": [
                                          {
                                            "type": "array",
                                            "items": {
                                              "minimum": 0,
                                              "maximum": 23,
                                              "type": "integer"
                                            }
                                          },
                                          {
                                            "type": "null"
                                          }
                                        ]
                                      },
                                      "TUESDAY": {
                                        "anyOf": [
                                          {
                                            "type": "array",
                                            "items": {
                                              "minimum": 0,
                                              "maximum": 23,
                                              "type": "integer"
                                            }
                                          },
                                          {
                                            "type": "null"
                                          }
                                        ]
                                      },
                                      "WEDNESDAY": {
                                        "anyOf": [
                                          {
                                            "type": "array",
                                            "items": {
                                              "minimum": 0,
                                              "maximum": 23,
                                              "type": "integer"
                                            }
                                          },
                                          {
                                            "type": "null"
                                          }
                                        ]
                                      }
                                    }
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "outbrainEndDate": {
                                "anyOf": [
                                  {
                                    "type": "string"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "outbrainStartDate": {
                                "anyOf": [
                                  {
                                    "type": "string"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "outbrainTargeting": {
                                "anyOf": [
                                  {
                                    "additionalProperties": false,
                                    "type": "object",
                                    "properties": {
                                      "browsers": {
                                        "anyOf": [
                                          {
                                            "type": "array",
                                            "items": {
                                              "type": "string"
                                            }
                                          },
                                          {
                                            "type": "null"
                                          }
                                        ]
                                      },
                                      "countries": {
                                        "anyOf": [
                                          {
                                            "type": "array",
                                            "items": {
                                              "type": "string"
                                            }
                                          },
                                          {
                                            "type": "null"
                                          }
                                        ]
                                      },
                                      "custom_audiences": {
                                        "anyOf": [
                                          {
                                            "type": "array",
                                            "items": {
                                              "type": "string"
                                            }
                                          },
                                          {
                                            "type": "null"
                                          }
                                        ]
                                      },
                                      "iab_categories": {
                                        "anyOf": [
                                          {
                                            "type": "array",
                                            "items": {
                                              "type": "string"
                                            }
                                          },
                                          {
                                            "type": "null"
                                          }
                                        ]
                                      },
                                      "languages": {
                                        "anyOf": [
                                          {
                                            "type": "array",
                                            "items": {
                                              "type": "string"
                                            }
                                          },
                                          {
                                            "type": "null"
                                          }
                                        ]
                                      },
                                      "operating_systems": {
                                        "anyOf": [
                                          {
                                            "type": "array",
                                            "items": {
                                              "type": "string"
                                            }
                                          },
                                          {
                                            "type": "null"
                                          }
                                        ]
                                      },
                                      "platforms": {
                                        "anyOf": [
                                          {
                                            "type": "array",
                                            "items": {
                                              "type": "string"
                                            }
                                          },
                                          {
                                            "type": "null"
                                          }
                                        ]
                                      },
                                      "sections": {
                                        "anyOf": [
                                          {
                                            "additionalProperties": false,
                                            "type": "object",
                                            "properties": {
                                              "exclude": {
                                                "anyOf": [
                                                  {
                                                    "type": "array",
                                                    "items": {
                                                      "type": "string"
                                                    }
                                                  },
                                                  {
                                                    "type": "null"
                                                  }
                                                ]
                                              },
                                              "include": {
                                                "anyOf": [
                                                  {
                                                    "type": "array",
                                                    "items": {
                                                      "type": "string"
                                                    }
                                                  },
                                                  {
                                                    "type": "null"
                                                  }
                                                ]
                                              }
                                            }
                                          },
                                          {
                                            "type": "null"
                                          }
                                        ]
                                      }
                                    }
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "reachGoals": {
                                "anyOf": [
                                  {
                                    "additionalProperties": false,
                                    "type": "object",
                                    "properties": {
                                      "phoneCall": {
                                        "anyOf": [
                                          {
                                            "type": "boolean"
                                          },
                                          {
                                            "type": "null"
                                          }
                                        ]
                                      },
                                      "storeVisit": {
                                        "anyOf": [
                                          {
                                            "type": "boolean"
                                          },
                                          {
                                            "type": "null"
                                          }
                                        ]
                                      },
                                      "websiteVisit": {
                                        "anyOf": [
                                          {
                                            "type": "boolean"
                                          },
                                          {
                                            "type": "null"
                                          }
                                        ]
                                      }
                                    }
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "snapchatDynamicAds": {
                                "anyOf": [
                                  {
                                    "type": "boolean"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "snapchatLifetimeSpendCap": {
                                "anyOf": [
                                  {
                                    "type": "number"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "snapchatMobileApp": {
                                "anyOf": [
                                  {
                                    "additionalProperties": false,
                                    "type": "object",
                                    "properties": {
                                      "android_app_url": {
                                        "anyOf": [
                                          {
                                            "type": "string"
                                          },
                                          {
                                            "type": "null"
                                          }
                                        ]
                                      },
                                      "app_name": {
                                        "anyOf": [
                                          {
                                            "type": "string"
                                          },
                                          {
                                            "type": "null"
                                          }
                                        ]
                                      },
                                      "ios_app_id": {
                                        "anyOf": [
                                          {
                                            "type": "string"
                                          },
                                          {
                                            "type": "null"
                                          }
                                        ]
                                      }
                                    }
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "snapchatPromotionType": {
                                "anyOf": [
                                  {
                                    "anyOf": [
                                      {
                                        "type": "string",
                                        "enum": [
                                          "APP_INSTALL"
                                        ]
                                      },
                                      {
                                        "type": "string",
                                        "enum": [
                                          "APP_REENGAGEMENT"
                                        ]
                                      }
                                    ]
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "snapchatPublicProfileId": {
                                "anyOf": [
                                  {
                                    "type": "string"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "specialAdCategories": {
                                "anyOf": [
                                  {
                                    "type": "array",
                                    "items": {
                                      "anyOf": [
                                        {
                                          "type": "string",
                                          "enum": [
                                            "NONE"
                                          ]
                                        },
                                        {
                                          "type": "string",
                                          "enum": [
                                            "HOUSING"
                                          ]
                                        },
                                        {
                                          "type": "string",
                                          "enum": [
                                            "EMPLOYMENT"
                                          ]
                                        },
                                        {
                                          "type": "string",
                                          "enum": [
                                            "CREDIT"
                                          ]
                                        },
                                        {
                                          "type": "string",
                                          "enum": [
                                            "ISSUES_ELECTIONS_POLITICS"
                                          ]
                                        },
                                        {
                                          "type": "string",
                                          "enum": [
                                            "ONLINE_GAMBLING_AND_GAMING"
                                          ]
                                        }
                                      ]
                                    }
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "status": {
                                "anyOf": [
                                  {
                                    "anyOf": [
                                      {
                                        "type": "string",
                                        "enum": [
                                          "ACTIVE"
                                        ]
                                      },
                                      {
                                        "type": "string",
                                        "enum": [
                                          "PAUSED"
                                        ]
                                      }
                                    ]
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "taboolaBidStrategy": {
                                "anyOf": [
                                  {
                                    "anyOf": [
                                      {
                                        "type": "string",
                                        "enum": [
                                          "FIXED"
                                        ]
                                      },
                                      {
                                        "type": "string",
                                        "enum": [
                                          "TARGET_CPA"
                                        ]
                                      }
                                    ]
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "taboolaBrandingText": {
                                "anyOf": [
                                  {
                                    "type": "string"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "taboolaCpaGoal": {
                                "anyOf": [
                                  {
                                    "type": "number"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "taboolaCpc": {
                                "anyOf": [
                                  {
                                    "type": "number"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "taboolaDailyCap": {
                                "anyOf": [
                                  {
                                    "type": "number"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "taboolaPricingModel": {
                                "anyOf": [
                                  {
                                    "type": "string"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "taboolaSpendingLimit": {
                                "anyOf": [
                                  {
                                    "type": "number"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "taboolaSpendingLimitType": {
                                "anyOf": [
                                  {
                                    "anyOf": [
                                      {
                                        "type": "string",
                                        "enum": [
                                          "MONTHLY"
                                        ]
                                      },
                                      {
                                        "type": "string",
                                        "enum": [
                                          "ENTIRE"
                                        ]
                                      }
                                    ]
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "tiktokAppId": {
                                "anyOf": [
                                  {
                                    "type": "string"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "tiktokBidAmount": {
                                "anyOf": [
                                  {
                                    "type": "number"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "tiktokBidType": {
                                "anyOf": [
                                  {
                                    "anyOf": [
                                      {
                                        "type": "string",
                                        "enum": [
                                          "BID_TYPE_CUSTOM"
                                        ]
                                      },
                                      {
                                        "type": "string",
                                        "enum": [
                                          "BID_TYPE_NO_BID"
                                        ]
                                      }
                                    ]
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "tiktokBillingEvent": {
                                "anyOf": [
                                  {
                                    "anyOf": [
                                      {
                                        "type": "string",
                                        "enum": [
                                          "CPM"
                                        ]
                                      },
                                      {
                                        "type": "string",
                                        "enum": [
                                          "OCPM"
                                        ]
                                      },
                                      {
                                        "type": "string",
                                        "enum": [
                                          "CPC"
                                        ]
                                      },
                                      {
                                        "type": "string",
                                        "enum": [
                                          "CPV"
                                        ]
                                      }
                                    ]
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "tiktokCatalogId": {
                                "anyOf": [
                                  {
                                    "type": "string"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "tiktokIdentityId": {
                                "anyOf": [
                                  {
                                    "type": "string"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "tiktokIdentityType": {
                                "anyOf": [
                                  {
                                    "anyOf": [
                                      {
                                        "type": "string",
                                        "enum": [
                                          "TT_USER"
                                        ]
                                      },
                                      {
                                        "type": "string",
                                        "enum": [
                                          "CUSTOMIZED_USER"
                                        ]
                                      },
                                      {
                                        "type": "string",
                                        "enum": [
                                          "BC_AUTH_TT"
                                        ]
                                      }
                                    ]
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "tiktokItemId": {
                                "anyOf": [
                                  {
                                    "type": "string"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "tiktokLeadFormId": {
                                "anyOf": [
                                  {
                                    "type": "string"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "tiktokOptimizeGoal": {
                                "anyOf": [
                                  {
                                    "type": "string"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "tiktokPixelEvent": {
                                "anyOf": [
                                  {
                                    "type": "string"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "tiktokPixelId": {
                                "anyOf": [
                                  {
                                    "type": "string"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "tiktokRoasBid": {
                                "anyOf": [
                                  {
                                    "type": "number"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              }
                            }
                          },
                          {
                            "type": "null"
                          }
                        ]
                      },
                      "currency": {
                        "anyOf": [
                          {
                            "type": "string"
                          },
                          {
                            "type": "null"
                          }
                        ]
                      },
                      "editWarning": {
                        "anyOf": [
                          {
                            "additionalProperties": false,
                            "type": "object",
                            "properties": {
                              "kind": {
                                "anyOf": [
                                  {
                                    "anyOf": [
                                      {
                                        "type": "string",
                                        "enum": [
                                          "none"
                                        ]
                                      },
                                      {
                                        "type": "string",
                                        "enum": [
                                          "learning_reset"
                                        ]
                                      },
                                      {
                                        "type": "string",
                                        "enum": [
                                          "recreate"
                                        ]
                                      },
                                      {
                                        "type": "string",
                                        "enum": [
                                          "re_review"
                                        ]
                                      },
                                      {
                                        "type": "string",
                                        "enum": [
                                          "id_change"
                                        ]
                                      }
                                    ]
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "reason": {
                                "anyOf": [
                                  {
                                    "type": "string"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              }
                            }
                          },
                          {
                            "type": "null"
                          }
                        ]
                      },
                      "id": {
                        "anyOf": [
                          {
                            "type": "string"
                          },
                          {
                            "type": "null"
                          }
                        ]
                      },
                      "platformId": {
                        "anyOf": [
                          {
                            "type": "string"
                          },
                          {
                            "type": "null"
                          }
                        ]
                      },
                      "publishMode": {
                        "anyOf": [
                          {
                            "anyOf": [
                              {
                                "type": "string",
                                "enum": [
                                  "create_all"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "ads_only"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "add_adset"
                                ]
                              }
                            ]
                          },
                          {
                            "type": "null"
                          }
                        ]
                      },
                      "sessionId": {
                        "anyOf": [
                          {
                            "type": "string"
                          },
                          {
                            "type": "null"
                          }
                        ]
                      }
                    }
                  },
                  "current_step": {
                    "minimum": 0,
                    "maximum": 20,
                    "type": "integer"
                  },
                  "platform": {
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "201": {
            "description": "Resource created",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "id",
                    "account_id",
                    "name",
                    "source",
                    "status",
                    "platform",
                    "current_step",
                    "canonical_campaign",
                    "created_at",
                    "updated_at"
                  ],
                  "properties": {
                    "id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "account_id": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "name": {
                      "type": "string"
                    },
                    "source": {
                      "type": "string"
                    },
                    "status": {
                      "type": "string"
                    },
                    "platform": {
                      "type": "string"
                    },
                    "current_step": {
                      "type": "integer"
                    },
                    "canonical_campaign": {
                      "$comment": "json-value",
                      "description": "Arbitrary JSON value with nested arrays and objects."
                    },
                    "created_at": {
                      "format": "date-time",
                      "type": "string"
                    },
                    "updated_at": {
                      "anyOf": [
                        {
                          "format": "date-time",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "error_code": {
                      "type": "string"
                    },
                    "detail": {}
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "error_code": {
                      "type": "string"
                    },
                    "detail": {}
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "error_code": {
                      "type": "string"
                    },
                    "detail": {}
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "error_code": {
                      "type": "string"
                    },
                    "detail": {}
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/campaign-drafts/{id}": {
      "get": {
        "operationId": "getCampaignDraft",
        "summary": "Get campaign draft by ID",
        "tags": [
          "campaigns"
        ],
        "description": "Retrieves a single campaign draft by its UUID.",
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "id",
                    "account_id",
                    "name",
                    "source",
                    "status",
                    "platform",
                    "current_step",
                    "canonical_campaign",
                    "created_at",
                    "updated_at"
                  ],
                  "properties": {
                    "id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "account_id": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "name": {
                      "type": "string"
                    },
                    "source": {
                      "type": "string"
                    },
                    "status": {
                      "type": "string"
                    },
                    "platform": {
                      "type": "string"
                    },
                    "current_step": {
                      "type": "integer"
                    },
                    "canonical_campaign": {
                      "$comment": "json-value",
                      "description": "Arbitrary JSON value with nested arrays and objects."
                    },
                    "created_at": {
                      "format": "date-time",
                      "type": "string"
                    },
                    "updated_at": {
                      "anyOf": [
                        {
                          "format": "date-time",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "error_code": {
                      "type": "string"
                    },
                    "detail": {}
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "error_code": {
                      "type": "string"
                    },
                    "detail": {}
                  }
                }
              }
            }
          }
        }
      },
      "patch": {
        "operationId": "updateCampaignDraft",
        "summary": "Update campaign draft (auto-save with deep merge)",
        "tags": [
          "campaigns"
        ],
        "description": "Partially updates a campaign draft using deep merge, enabling auto-save of individual fields.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "properties": {
                  "name": {
                    "minLength": 1,
                    "maxLength": 500,
                    "type": "string"
                  },
                  "account_id": {
                    "type": "string"
                  },
                  "canonical_campaign": {
                    "additionalProperties": false,
                    "description": "Canonical campaign JSONB shape used by campaign drafts. Fields are optional because drafts are auto-saved while incomplete.",
                    "type": "object",
                    "properties": {
                      "accountId": {
                        "anyOf": [
                          {
                            "type": "string"
                          },
                          {
                            "type": "null"
                          }
                        ]
                      },
                      "adSets": {
                        "anyOf": [
                          {
                            "type": "array",
                            "items": {
                              "additionalProperties": false,
                              "type": "object",
                              "properties": {
                                "ads": {
                                  "anyOf": [
                                    {
                                      "type": "array",
                                      "items": {
                                        "additionalProperties": false,
                                        "type": "object",
                                        "properties": {
                                          "advantageCreative": {
                                            "anyOf": [
                                              {
                                                "type": "boolean"
                                              },
                                              {
                                                "type": "null"
                                              }
                                            ]
                                          },
                                          "callToAction": {
                                            "anyOf": [
                                              {
                                                "type": "string"
                                              },
                                              {
                                                "type": "null"
                                              }
                                            ]
                                          },
                                          "creativeFormat": {
                                            "anyOf": [
                                              {
                                                "anyOf": [
                                                  {
                                                    "type": "string",
                                                    "enum": [
                                                      "SINGLE_IMAGE"
                                                    ]
                                                  },
                                                  {
                                                    "type": "string",
                                                    "enum": [
                                                      "SINGLE_VIDEO"
                                                    ]
                                                  },
                                                  {
                                                    "type": "string",
                                                    "enum": [
                                                      "CAROUSEL"
                                                    ]
                                                  },
                                                  {
                                                    "type": "string",
                                                    "enum": [
                                                      "EXISTING_POST"
                                                    ]
                                                  },
                                                  {
                                                    "type": "string",
                                                    "enum": [
                                                      "CATALOG"
                                                    ]
                                                  },
                                                  {
                                                    "type": "string",
                                                    "enum": [
                                                      "FLEXIBLE"
                                                    ]
                                                  }
                                                ]
                                              },
                                              {
                                                "type": "null"
                                              }
                                            ]
                                          },
                                          "description": {
                                            "anyOf": [
                                              {
                                                "type": "string"
                                              },
                                              {
                                                "type": "null"
                                              }
                                            ]
                                          },
                                          "descriptionVariations": {
                                            "anyOf": [
                                              {
                                                "type": "array",
                                                "items": {
                                                  "type": "string"
                                                }
                                              },
                                              {
                                                "type": "null"
                                              }
                                            ]
                                          },
                                          "dynamicCreative": {
                                            "anyOf": [
                                              {
                                                "type": "boolean"
                                              },
                                              {
                                                "type": "null"
                                              }
                                            ]
                                          },
                                          "existingPostId": {
                                            "anyOf": [
                                              {
                                                "type": "string"
                                              },
                                              {
                                                "type": "null"
                                              }
                                            ]
                                          },
                                          "existingPostPreview": {
                                            "anyOf": [
                                              {
                                                "additionalProperties": false,
                                                "type": "object",
                                                "properties": {
                                                  "imageUrl": {
                                                    "anyOf": [
                                                      {
                                                        "type": "string"
                                                      },
                                                      {
                                                        "type": "null"
                                                      }
                                                    ]
                                                  },
                                                  "message": {
                                                    "anyOf": [
                                                      {
                                                        "type": "string"
                                                      },
                                                      {
                                                        "type": "null"
                                                      }
                                                    ]
                                                  }
                                                }
                                              },
                                              {
                                                "type": "null"
                                              }
                                            ]
                                          },
                                          "googleDescriptions": {
                                            "anyOf": [
                                              {
                                                "type": "array",
                                                "items": {
                                                  "type": "string"
                                                }
                                              },
                                              {
                                                "type": "null"
                                              }
                                            ]
                                          },
                                          "googleDisplayPath1": {
                                            "anyOf": [
                                              {
                                                "type": "string"
                                              },
                                              {
                                                "type": "null"
                                              }
                                            ]
                                          },
                                          "googleDisplayPath2": {
                                            "anyOf": [
                                              {
                                                "type": "string"
                                              },
                                              {
                                                "type": "null"
                                              }
                                            ]
                                          },
                                          "googleHeadlines": {
                                            "anyOf": [
                                              {
                                                "type": "array",
                                                "items": {
                                                  "type": "string"
                                                }
                                              },
                                              {
                                                "type": "null"
                                              }
                                            ]
                                          },
                                          "googleLogoAsset": {
                                            "anyOf": [
                                              {
                                                "additionalProperties": false,
                                                "type": "object",
                                                "properties": {
                                                  "aiGenerated": {
                                                    "anyOf": [
                                                      {
                                                        "type": "boolean"
                                                      },
                                                      {
                                                        "type": "null"
                                                      }
                                                    ]
                                                  },
                                                  "cardDescription": {
                                                    "anyOf": [
                                                      {
                                                        "type": "string"
                                                      },
                                                      {
                                                        "type": "null"
                                                      }
                                                    ]
                                                  },
                                                  "cardHeadline": {
                                                    "anyOf": [
                                                      {
                                                        "type": "string"
                                                      },
                                                      {
                                                        "type": "null"
                                                      }
                                                    ]
                                                  },
                                                  "crops": {
                                                    "anyOf": [
                                                      {
                                                        "additionalProperties": false,
                                                        "type": "object",
                                                        "properties": {
                                                          "100x100": {
                                                            "anyOf": [
                                                              {
                                                                "minItems": 2,
                                                                "maxItems": 2,
                                                                "type": "array",
                                                                "items": {
                                                                  "minItems": 2,
                                                                  "maxItems": 2,
                                                                  "type": "array",
                                                                  "items": {
                                                                    "type": "number"
                                                                  }
                                                                }
                                                              },
                                                              {
                                                                "type": "null"
                                                              }
                                                            ]
                                                          },
                                                          "191x100": {
                                                            "anyOf": [
                                                              {
                                                                "minItems": 2,
                                                                "maxItems": 2,
                                                                "type": "array",
                                                                "items": {
                                                                  "minItems": 2,
                                                                  "maxItems": 2,
                                                                  "type": "array",
                                                                  "items": {
                                                                    "type": "number"
                                                                  }
                                                                }
                                                              },
                                                              {
                                                                "type": "null"
                                                              }
                                                            ]
                                                          },
                                                          "400x500": {
                                                            "anyOf": [
                                                              {
                                                                "minItems": 2,
                                                                "maxItems": 2,
                                                                "type": "array",
                                                                "items": {
                                                                  "minItems": 2,
                                                                  "maxItems": 2,
                                                                  "type": "array",
                                                                  "items": {
                                                                    "type": "number"
                                                                  }
                                                                }
                                                              },
                                                              {
                                                                "type": "null"
                                                              }
                                                            ]
                                                          }
                                                        }
                                                      },
                                                      {
                                                        "type": "null"
                                                      }
                                                    ]
                                                  },
                                                  "duration": {
                                                    "anyOf": [
                                                      {
                                                        "type": "number"
                                                      },
                                                      {
                                                        "type": "null"
                                                      }
                                                    ]
                                                  },
                                                  "fileSizeBytes": {
                                                    "anyOf": [
                                                      {
                                                        "type": "number"
                                                      },
                                                      {
                                                        "type": "null"
                                                      }
                                                    ]
                                                  },
                                                  "height": {
                                                    "anyOf": [
                                                      {
                                                        "type": "number"
                                                      },
                                                      {
                                                        "type": "null"
                                                      }
                                                    ]
                                                  },
                                                  "metaHash": {
                                                    "anyOf": [
                                                      {
                                                        "type": "string"
                                                      },
                                                      {
                                                        "type": "null"
                                                      }
                                                    ]
                                                  },
                                                  "metaVideoId": {
                                                    "anyOf": [
                                                      {
                                                        "type": "string"
                                                      },
                                                      {
                                                        "type": "null"
                                                      }
                                                    ]
                                                  },
                                                  "snapchatMediaId": {
                                                    "anyOf": [
                                                      {
                                                        "type": "string"
                                                      },
                                                      {
                                                        "type": "null"
                                                      }
                                                    ]
                                                  },
                                                  "sourceUrl": {
                                                    "anyOf": [
                                                      {
                                                        "type": "string"
                                                      },
                                                      {
                                                        "type": "null"
                                                      }
                                                    ]
                                                  },
                                                  "thumbnailUrl": {
                                                    "anyOf": [
                                                      {
                                                        "type": "string"
                                                      },
                                                      {
                                                        "type": "null"
                                                      }
                                                    ]
                                                  },
                                                  "tiktokVideoId": {
                                                    "anyOf": [
                                                      {
                                                        "type": "string"
                                                      },
                                                      {
                                                        "type": "null"
                                                      }
                                                    ]
                                                  },
                                                  "type": {
                                                    "anyOf": [
                                                      {
                                                        "anyOf": [
                                                          {
                                                            "type": "string",
                                                            "enum": [
                                                              "image"
                                                            ]
                                                          },
                                                          {
                                                            "type": "string",
                                                            "enum": [
                                                              "video"
                                                            ]
                                                          }
                                                        ]
                                                      },
                                                      {
                                                        "type": "null"
                                                      }
                                                    ]
                                                  },
                                                  "videoId": {
                                                    "anyOf": [
                                                      {
                                                        "type": "string"
                                                      },
                                                      {
                                                        "type": "null"
                                                      }
                                                    ]
                                                  },
                                                  "width": {
                                                    "anyOf": [
                                                      {
                                                        "type": "number"
                                                      },
                                                      {
                                                        "type": "null"
                                                      }
                                                    ]
                                                  }
                                                }
                                              },
                                              {
                                                "type": "null"
                                              }
                                            ]
                                          },
                                          "googleYoutubeUrl": {
                                            "anyOf": [
                                              {
                                                "type": "string"
                                              },
                                              {
                                                "type": "null"
                                              }
                                            ]
                                          },
                                          "headline": {
                                            "anyOf": [
                                              {
                                                "type": "string"
                                              },
                                              {
                                                "type": "null"
                                              }
                                            ]
                                          },
                                          "headlineVariations": {
                                            "anyOf": [
                                              {
                                                "type": "array",
                                                "items": {
                                                  "type": "string"
                                                }
                                              },
                                              {
                                                "type": "null"
                                              }
                                            ]
                                          },
                                          "id": {
                                            "anyOf": [
                                              {
                                                "type": "string"
                                              },
                                              {
                                                "type": "null"
                                              }
                                            ]
                                          },
                                          "media": {
                                            "anyOf": [
                                              {
                                                "type": "array",
                                                "items": {
                                                  "additionalProperties": false,
                                                  "type": "object",
                                                  "properties": {
                                                    "aiGenerated": {
                                                      "anyOf": [
                                                        {
                                                          "type": "boolean"
                                                        },
                                                        {
                                                          "type": "null"
                                                        }
                                                      ]
                                                    },
                                                    "cardDescription": {
                                                      "anyOf": [
                                                        {
                                                          "type": "string"
                                                        },
                                                        {
                                                          "type": "null"
                                                        }
                                                      ]
                                                    },
                                                    "cardHeadline": {
                                                      "anyOf": [
                                                        {
                                                          "type": "string"
                                                        },
                                                        {
                                                          "type": "null"
                                                        }
                                                      ]
                                                    },
                                                    "crops": {
                                                      "anyOf": [
                                                        {
                                                          "additionalProperties": false,
                                                          "type": "object",
                                                          "properties": {
                                                            "100x100": {
                                                              "anyOf": [
                                                                {
                                                                  "minItems": 2,
                                                                  "maxItems": 2,
                                                                  "type": "array",
                                                                  "items": {
                                                                    "minItems": 2,
                                                                    "maxItems": 2,
                                                                    "type": "array",
                                                                    "items": {
                                                                      "type": "number"
                                                                    }
                                                                  }
                                                                },
                                                                {
                                                                  "type": "null"
                                                                }
                                                              ]
                                                            },
                                                            "191x100": {
                                                              "anyOf": [
                                                                {
                                                                  "minItems": 2,
                                                                  "maxItems": 2,
                                                                  "type": "array",
                                                                  "items": {
                                                                    "minItems": 2,
                                                                    "maxItems": 2,
                                                                    "type": "array",
                                                                    "items": {
                                                                      "type": "number"
                                                                    }
                                                                  }
                                                                },
                                                                {
                                                                  "type": "null"
                                                                }
                                                              ]
                                                            },
                                                            "400x500": {
                                                              "anyOf": [
                                                                {
                                                                  "minItems": 2,
                                                                  "maxItems": 2,
                                                                  "type": "array",
                                                                  "items": {
                                                                    "minItems": 2,
                                                                    "maxItems": 2,
                                                                    "type": "array",
                                                                    "items": {
                                                                      "type": "number"
                                                                    }
                                                                  }
                                                                },
                                                                {
                                                                  "type": "null"
                                                                }
                                                              ]
                                                            }
                                                          }
                                                        },
                                                        {
                                                          "type": "null"
                                                        }
                                                      ]
                                                    },
                                                    "duration": {
                                                      "anyOf": [
                                                        {
                                                          "type": "number"
                                                        },
                                                        {
                                                          "type": "null"
                                                        }
                                                      ]
                                                    },
                                                    "fileSizeBytes": {
                                                      "anyOf": [
                                                        {
                                                          "type": "number"
                                                        },
                                                        {
                                                          "type": "null"
                                                        }
                                                      ]
                                                    },
                                                    "height": {
                                                      "anyOf": [
                                                        {
                                                          "type": "number"
                                                        },
                                                        {
                                                          "type": "null"
                                                        }
                                                      ]
                                                    },
                                                    "metaHash": {
                                                      "anyOf": [
                                                        {
                                                          "type": "string"
                                                        },
                                                        {
                                                          "type": "null"
                                                        }
                                                      ]
                                                    },
                                                    "metaVideoId": {
                                                      "anyOf": [
                                                        {
                                                          "type": "string"
                                                        },
                                                        {
                                                          "type": "null"
                                                        }
                                                      ]
                                                    },
                                                    "snapchatMediaId": {
                                                      "anyOf": [
                                                        {
                                                          "type": "string"
                                                        },
                                                        {
                                                          "type": "null"
                                                        }
                                                      ]
                                                    },
                                                    "sourceUrl": {
                                                      "anyOf": [
                                                        {
                                                          "type": "string"
                                                        },
                                                        {
                                                          "type": "null"
                                                        }
                                                      ]
                                                    },
                                                    "thumbnailUrl": {
                                                      "anyOf": [
                                                        {
                                                          "type": "string"
                                                        },
                                                        {
                                                          "type": "null"
                                                        }
                                                      ]
                                                    },
                                                    "tiktokVideoId": {
                                                      "anyOf": [
                                                        {
                                                          "type": "string"
                                                        },
                                                        {
                                                          "type": "null"
                                                        }
                                                      ]
                                                    },
                                                    "type": {
                                                      "anyOf": [
                                                        {
                                                          "anyOf": [
                                                            {
                                                              "type": "string",
                                                              "enum": [
                                                                "image"
                                                              ]
                                                            },
                                                            {
                                                              "type": "string",
                                                              "enum": [
                                                                "video"
                                                              ]
                                                            }
                                                          ]
                                                        },
                                                        {
                                                          "type": "null"
                                                        }
                                                      ]
                                                    },
                                                    "videoId": {
                                                      "anyOf": [
                                                        {
                                                          "type": "string"
                                                        },
                                                        {
                                                          "type": "null"
                                                        }
                                                      ]
                                                    },
                                                    "width": {
                                                      "anyOf": [
                                                        {
                                                          "type": "number"
                                                        },
                                                        {
                                                          "type": "null"
                                                        }
                                                      ]
                                                    }
                                                  }
                                                }
                                              },
                                              {
                                                "type": "null"
                                              }
                                            ]
                                          },
                                          "multiAdvertiser": {
                                            "anyOf": [
                                              {
                                                "type": "boolean"
                                              },
                                              {
                                                "type": "null"
                                              }
                                            ]
                                          },
                                          "multilanguage": {
                                            "anyOf": [
                                              {
                                                "type": "boolean"
                                              },
                                              {
                                                "type": "null"
                                              }
                                            ]
                                          },
                                          "name": {
                                            "anyOf": [
                                              {
                                                "type": "string"
                                              },
                                              {
                                                "type": "null"
                                              }
                                            ]
                                          },
                                          "pageId": {
                                            "anyOf": [
                                              {
                                                "type": "string"
                                              },
                                              {
                                                "type": "null"
                                              }
                                            ]
                                          },
                                          "placementAssets": {
                                            "anyOf": [
                                              {
                                                "additionalProperties": false,
                                                "type": "object",
                                                "properties": {
                                                  "feed": {
                                                    "anyOf": [
                                                      {
                                                        "additionalProperties": false,
                                                        "type": "object",
                                                        "properties": {
                                                          "aiGenerated": {
                                                            "anyOf": [
                                                              {
                                                                "type": "boolean"
                                                              },
                                                              {
                                                                "type": "null"
                                                              }
                                                            ]
                                                          },
                                                          "cardDescription": {
                                                            "anyOf": [
                                                              {
                                                                "type": "string"
                                                              },
                                                              {
                                                                "type": "null"
                                                              }
                                                            ]
                                                          },
                                                          "cardHeadline": {
                                                            "anyOf": [
                                                              {
                                                                "type": "string"
                                                              },
                                                              {
                                                                "type": "null"
                                                              }
                                                            ]
                                                          },
                                                          "crops": {
                                                            "anyOf": [
                                                              {
                                                                "additionalProperties": false,
                                                                "type": "object",
                                                                "properties": {
                                                                  "100x100": {
                                                                    "anyOf": [
                                                                      {
                                                                        "minItems": 2,
                                                                        "maxItems": 2,
                                                                        "type": "array",
                                                                        "items": {
                                                                          "minItems": 2,
                                                                          "maxItems": 2,
                                                                          "type": "array",
                                                                          "items": {
                                                                            "type": "number"
                                                                          }
                                                                        }
                                                                      },
                                                                      {
                                                                        "type": "null"
                                                                      }
                                                                    ]
                                                                  },
                                                                  "191x100": {
                                                                    "anyOf": [
                                                                      {
                                                                        "minItems": 2,
                                                                        "maxItems": 2,
                                                                        "type": "array",
                                                                        "items": {
                                                                          "minItems": 2,
                                                                          "maxItems": 2,
                                                                          "type": "array",
                                                                          "items": {
                                                                            "type": "number"
                                                                          }
                                                                        }
                                                                      },
                                                                      {
                                                                        "type": "null"
                                                                      }
                                                                    ]
                                                                  },
                                                                  "400x500": {
                                                                    "anyOf": [
                                                                      {
                                                                        "minItems": 2,
                                                                        "maxItems": 2,
                                                                        "type": "array",
                                                                        "items": {
                                                                          "minItems": 2,
                                                                          "maxItems": 2,
                                                                          "type": "array",
                                                                          "items": {
                                                                            "type": "number"
                                                                          }
                                                                        }
                                                                      },
                                                                      {
                                                                        "type": "null"
                                                                      }
                                                                    ]
                                                                  }
                                                                }
                                                              },
                                                              {
                                                                "type": "null"
                                                              }
                                                            ]
                                                          },
                                                          "duration": {
                                                            "anyOf": [
                                                              {
                                                                "type": "number"
                                                              },
                                                              {
                                                                "type": "null"
                                                              }
                                                            ]
                                                          },
                                                          "fileSizeBytes": {
                                                            "anyOf": [
                                                              {
                                                                "type": "number"
                                                              },
                                                              {
                                                                "type": "null"
                                                              }
                                                            ]
                                                          },
                                                          "height": {
                                                            "anyOf": [
                                                              {
                                                                "type": "number"
                                                              },
                                                              {
                                                                "type": "null"
                                                              }
                                                            ]
                                                          },
                                                          "metaHash": {
                                                            "anyOf": [
                                                              {
                                                                "type": "string"
                                                              },
                                                              {
                                                                "type": "null"
                                                              }
                                                            ]
                                                          },
                                                          "metaVideoId": {
                                                            "anyOf": [
                                                              {
                                                                "type": "string"
                                                              },
                                                              {
                                                                "type": "null"
                                                              }
                                                            ]
                                                          },
                                                          "snapchatMediaId": {
                                                            "anyOf": [
                                                              {
                                                                "type": "string"
                                                              },
                                                              {
                                                                "type": "null"
                                                              }
                                                            ]
                                                          },
                                                          "sourceUrl": {
                                                            "anyOf": [
                                                              {
                                                                "type": "string"
                                                              },
                                                              {
                                                                "type": "null"
                                                              }
                                                            ]
                                                          },
                                                          "thumbnailUrl": {
                                                            "anyOf": [
                                                              {
                                                                "type": "string"
                                                              },
                                                              {
                                                                "type": "null"
                                                              }
                                                            ]
                                                          },
                                                          "tiktokVideoId": {
                                                            "anyOf": [
                                                              {
                                                                "type": "string"
                                                              },
                                                              {
                                                                "type": "null"
                                                              }
                                                            ]
                                                          },
                                                          "type": {
                                                            "anyOf": [
                                                              {
                                                                "anyOf": [
                                                                  {
                                                                    "type": "string",
                                                                    "enum": [
                                                                      "image"
                                                                    ]
                                                                  },
                                                                  {
                                                                    "type": "string",
                                                                    "enum": [
                                                                      "video"
                                                                    ]
                                                                  }
                                                                ]
                                                              },
                                                              {
                                                                "type": "null"
                                                              }
                                                            ]
                                                          },
                                                          "videoId": {
                                                            "anyOf": [
                                                              {
                                                                "type": "string"
                                                              },
                                                              {
                                                                "type": "null"
                                                              }
                                                            ]
                                                          },
                                                          "width": {
                                                            "anyOf": [
                                                              {
                                                                "type": "number"
                                                              },
                                                              {
                                                                "type": "null"
                                                              }
                                                            ]
                                                          }
                                                        }
                                                      },
                                                      {
                                                        "type": "null"
                                                      }
                                                    ]
                                                  },
                                                  "story": {
                                                    "anyOf": [
                                                      {
                                                        "additionalProperties": false,
                                                        "type": "object",
                                                        "properties": {
                                                          "aiGenerated": {
                                                            "anyOf": [
                                                              {
                                                                "type": "boolean"
                                                              },
                                                              {
                                                                "type": "null"
                                                              }
                                                            ]
                                                          },
                                                          "cardDescription": {
                                                            "anyOf": [
                                                              {
                                                                "type": "string"
                                                              },
                                                              {
                                                                "type": "null"
                                                              }
                                                            ]
                                                          },
                                                          "cardHeadline": {
                                                            "anyOf": [
                                                              {
                                                                "type": "string"
                                                              },
                                                              {
                                                                "type": "null"
                                                              }
                                                            ]
                                                          },
                                                          "crops": {
                                                            "anyOf": [
                                                              {
                                                                "additionalProperties": false,
                                                                "type": "object",
                                                                "properties": {
                                                                  "100x100": {
                                                                    "anyOf": [
                                                                      {
                                                                        "minItems": 2,
                                                                        "maxItems": 2,
                                                                        "type": "array",
                                                                        "items": {
                                                                          "minItems": 2,
                                                                          "maxItems": 2,
                                                                          "type": "array",
                                                                          "items": {
                                                                            "type": "number"
                                                                          }
                                                                        }
                                                                      },
                                                                      {
                                                                        "type": "null"
                                                                      }
                                                                    ]
                                                                  },
                                                                  "191x100": {
                                                                    "anyOf": [
                                                                      {
                                                                        "minItems": 2,
                                                                        "maxItems": 2,
                                                                        "type": "array",
                                                                        "items": {
                                                                          "minItems": 2,
                                                                          "maxItems": 2,
                                                                          "type": "array",
                                                                          "items": {
                                                                            "type": "number"
                                                                          }
                                                                        }
                                                                      },
                                                                      {
                                                                        "type": "null"
                                                                      }
                                                                    ]
                                                                  },
                                                                  "400x500": {
                                                                    "anyOf": [
                                                                      {
                                                                        "minItems": 2,
                                                                        "maxItems": 2,
                                                                        "type": "array",
                                                                        "items": {
                                                                          "minItems": 2,
                                                                          "maxItems": 2,
                                                                          "type": "array",
                                                                          "items": {
                                                                            "type": "number"
                                                                          }
                                                                        }
                                                                      },
                                                                      {
                                                                        "type": "null"
                                                                      }
                                                                    ]
                                                                  }
                                                                }
                                                              },
                                                              {
                                                                "type": "null"
                                                              }
                                                            ]
                                                          },
                                                          "duration": {
                                                            "anyOf": [
                                                              {
                                                                "type": "number"
                                                              },
                                                              {
                                                                "type": "null"
                                                              }
                                                            ]
                                                          },
                                                          "fileSizeBytes": {
                                                            "anyOf": [
                                                              {
                                                                "type": "number"
                                                              },
                                                              {
                                                                "type": "null"
                                                              }
                                                            ]
                                                          },
                                                          "height": {
                                                            "anyOf": [
                                                              {
                                                                "type": "number"
                                                              },
                                                              {
                                                                "type": "null"
                                                              }
                                                            ]
                                                          },
                                                          "metaHash": {
                                                            "anyOf": [
                                                              {
                                                                "type": "string"
                                                              },
                                                              {
                                                                "type": "null"
                                                              }
                                                            ]
                                                          },
                                                          "metaVideoId": {
                                                            "anyOf": [
                                                              {
                                                                "type": "string"
                                                              },
                                                              {
                                                                "type": "null"
                                                              }
                                                            ]
                                                          },
                                                          "snapchatMediaId": {
                                                            "anyOf": [
                                                              {
                                                                "type": "string"
                                                              },
                                                              {
                                                                "type": "null"
                                                              }
                                                            ]
                                                          },
                                                          "sourceUrl": {
                                                            "anyOf": [
                                                              {
                                                                "type": "string"
                                                              },
                                                              {
                                                                "type": "null"
                                                              }
                                                            ]
                                                          },
                                                          "thumbnailUrl": {
                                                            "anyOf": [
                                                              {
                                                                "type": "string"
                                                              },
                                                              {
                                                                "type": "null"
                                                              }
                                                            ]
                                                          },
                                                          "tiktokVideoId": {
                                                            "anyOf": [
                                                              {
                                                                "type": "string"
                                                              },
                                                              {
                                                                "type": "null"
                                                              }
                                                            ]
                                                          },
                                                          "type": {
                                                            "anyOf": [
                                                              {
                                                                "anyOf": [
                                                                  {
                                                                    "type": "string",
                                                                    "enum": [
                                                                      "image"
                                                                    ]
                                                                  },
                                                                  {
                                                                    "type": "string",
                                                                    "enum": [
                                                                      "video"
                                                                    ]
                                                                  }
                                                                ]
                                                              },
                                                              {
                                                                "type": "null"
                                                              }
                                                            ]
                                                          },
                                                          "videoId": {
                                                            "anyOf": [
                                                              {
                                                                "type": "string"
                                                              },
                                                              {
                                                                "type": "null"
                                                              }
                                                            ]
                                                          },
                                                          "width": {
                                                            "anyOf": [
                                                              {
                                                                "type": "number"
                                                              },
                                                              {
                                                                "type": "null"
                                                              }
                                                            ]
                                                          }
                                                        }
                                                      },
                                                      {
                                                        "type": "null"
                                                      }
                                                    ]
                                                  }
                                                }
                                              },
                                              {
                                                "type": "null"
                                              }
                                            ]
                                          },
                                          "placementCustomization": {
                                            "anyOf": [
                                              {
                                                "type": "boolean"
                                              },
                                              {
                                                "type": "null"
                                              }
                                            ]
                                          },
                                          "platformId": {
                                            "anyOf": [
                                              {
                                                "type": "string"
                                              },
                                              {
                                                "type": "null"
                                              }
                                            ]
                                          },
                                          "primaryText": {
                                            "anyOf": [
                                              {
                                                "type": "string"
                                              },
                                              {
                                                "type": "null"
                                              }
                                            ]
                                          },
                                          "primaryTextVariations": {
                                            "anyOf": [
                                              {
                                                "type": "array",
                                                "items": {
                                                  "type": "string"
                                                }
                                              },
                                              {
                                                "type": "null"
                                              }
                                            ]
                                          },
                                          "secondaryDescription": {
                                            "anyOf": [
                                              {
                                                "type": "string"
                                              },
                                              {
                                                "type": "null"
                                              }
                                            ]
                                          },
                                          "secondaryHeadline": {
                                            "anyOf": [
                                              {
                                                "type": "string"
                                              },
                                              {
                                                "type": "null"
                                              }
                                            ]
                                          },
                                          "secondaryLanguages": {
                                            "anyOf": [
                                              {
                                                "type": "array",
                                                "items": {
                                                  "type": "string"
                                                }
                                              },
                                              {
                                                "type": "null"
                                              }
                                            ]
                                          },
                                          "secondaryMedia": {
                                            "anyOf": [
                                              {
                                                "type": "array",
                                                "items": {
                                                  "additionalProperties": false,
                                                  "type": "object",
                                                  "properties": {
                                                    "aiGenerated": {
                                                      "anyOf": [
                                                        {
                                                          "type": "boolean"
                                                        },
                                                        {
                                                          "type": "null"
                                                        }
                                                      ]
                                                    },
                                                    "cardDescription": {
                                                      "anyOf": [
                                                        {
                                                          "type": "string"
                                                        },
                                                        {
                                                          "type": "null"
                                                        }
                                                      ]
                                                    },
                                                    "cardHeadline": {
                                                      "anyOf": [
                                                        {
                                                          "type": "string"
                                                        },
                                                        {
                                                          "type": "null"
                                                        }
                                                      ]
                                                    },
                                                    "crops": {
                                                      "anyOf": [
                                                        {
                                                          "additionalProperties": false,
                                                          "type": "object",
                                                          "properties": {
                                                            "100x100": {
                                                              "anyOf": [
                                                                {
                                                                  "minItems": 2,
                                                                  "maxItems": 2,
                                                                  "type": "array",
                                                                  "items": {
                                                                    "minItems": 2,
                                                                    "maxItems": 2,
                                                                    "type": "array",
                                                                    "items": {
                                                                      "type": "number"
                                                                    }
                                                                  }
                                                                },
                                                                {
                                                                  "type": "null"
                                                                }
                                                              ]
                                                            },
                                                            "191x100": {
                                                              "anyOf": [
                                                                {
                                                                  "minItems": 2,
                                                                  "maxItems": 2,
                                                                  "type": "array",
                                                                  "items": {
                                                                    "minItems": 2,
                                                                    "maxItems": 2,
                                                                    "type": "array",
                                                                    "items": {
                                                                      "type": "number"
                                                                    }
                                                                  }
                                                                },
                                                                {
                                                                  "type": "null"
                                                                }
                                                              ]
                                                            },
                                                            "400x500": {
                                                              "anyOf": [
                                                                {
                                                                  "minItems": 2,
                                                                  "maxItems": 2,
                                                                  "type": "array",
                                                                  "items": {
                                                                    "minItems": 2,
                                                                    "maxItems": 2,
                                                                    "type": "array",
                                                                    "items": {
                                                                      "type": "number"
                                                                    }
                                                                  }
                                                                },
                                                                {
                                                                  "type": "null"
                                                                }
                                                              ]
                                                            }
                                                          }
                                                        },
                                                        {
                                                          "type": "null"
                                                        }
                                                      ]
                                                    },
                                                    "duration": {
                                                      "anyOf": [
                                                        {
                                                          "type": "number"
                                                        },
                                                        {
                                                          "type": "null"
                                                        }
                                                      ]
                                                    },
                                                    "fileSizeBytes": {
                                                      "anyOf": [
                                                        {
                                                          "type": "number"
                                                        },
                                                        {
                                                          "type": "null"
                                                        }
                                                      ]
                                                    },
                                                    "height": {
                                                      "anyOf": [
                                                        {
                                                          "type": "number"
                                                        },
                                                        {
                                                          "type": "null"
                                                        }
                                                      ]
                                                    },
                                                    "metaHash": {
                                                      "anyOf": [
                                                        {
                                                          "type": "string"
                                                        },
                                                        {
                                                          "type": "null"
                                                        }
                                                      ]
                                                    },
                                                    "metaVideoId": {
                                                      "anyOf": [
                                                        {
                                                          "type": "string"
                                                        },
                                                        {
                                                          "type": "null"
                                                        }
                                                      ]
                                                    },
                                                    "snapchatMediaId": {
                                                      "anyOf": [
                                                        {
                                                          "type": "string"
                                                        },
                                                        {
                                                          "type": "null"
                                                        }
                                                      ]
                                                    },
                                                    "sourceUrl": {
                                                      "anyOf": [
                                                        {
                                                          "type": "string"
                                                        },
                                                        {
                                                          "type": "null"
                                                        }
                                                      ]
                                                    },
                                                    "thumbnailUrl": {
                                                      "anyOf": [
                                                        {
                                                          "type": "string"
                                                        },
                                                        {
                                                          "type": "null"
                                                        }
                                                      ]
                                                    },
                                                    "tiktokVideoId": {
                                                      "anyOf": [
                                                        {
                                                          "type": "string"
                                                        },
                                                        {
                                                          "type": "null"
                                                        }
                                                      ]
                                                    },
                                                    "type": {
                                                      "anyOf": [
                                                        {
                                                          "anyOf": [
                                                            {
                                                              "type": "string",
                                                              "enum": [
                                                                "image"
                                                              ]
                                                            },
                                                            {
                                                              "type": "string",
                                                              "enum": [
                                                                "video"
                                                              ]
                                                            }
                                                          ]
                                                        },
                                                        {
                                                          "type": "null"
                                                        }
                                                      ]
                                                    },
                                                    "videoId": {
                                                      "anyOf": [
                                                        {
                                                          "type": "string"
                                                        },
                                                        {
                                                          "type": "null"
                                                        }
                                                      ]
                                                    },
                                                    "width": {
                                                      "anyOf": [
                                                        {
                                                          "type": "number"
                                                        },
                                                        {
                                                          "type": "null"
                                                        }
                                                      ]
                                                    }
                                                  }
                                                }
                                              },
                                              {
                                                "type": "null"
                                              }
                                            ]
                                          },
                                          "secondaryPrimaryText": {
                                            "anyOf": [
                                              {
                                                "type": "string"
                                              },
                                              {
                                                "type": "null"
                                              }
                                            ]
                                          },
                                          "secondaryUrl": {
                                            "anyOf": [
                                              {
                                                "type": "string"
                                              },
                                              {
                                                "type": "null"
                                              }
                                            ]
                                          },
                                          "snapchatAdDisclaimer": {
                                            "anyOf": [
                                              {
                                                "type": "string"
                                              },
                                              {
                                                "type": "null"
                                              }
                                            ]
                                          },
                                          "snapchatAdFavoriting": {
                                            "anyOf": [
                                              {
                                                "type": "boolean"
                                              },
                                              {
                                                "type": "null"
                                              }
                                            ]
                                          },
                                          "snapchatAdType": {
                                            "anyOf": [
                                              {
                                                "type": "string"
                                              },
                                              {
                                                "type": "null"
                                              }
                                            ]
                                          },
                                          "snapchatAppIconMediaId": {
                                            "anyOf": [
                                              {
                                                "type": "string"
                                              },
                                              {
                                                "type": "null"
                                              }
                                            ]
                                          },
                                          "snapchatBrandName": {
                                            "anyOf": [
                                              {
                                                "type": "string"
                                              },
                                              {
                                                "type": "null"
                                              }
                                            ]
                                          },
                                          "snapchatDeepLinkUri": {
                                            "anyOf": [
                                              {
                                                "type": "string"
                                              },
                                              {
                                                "type": "null"
                                              }
                                            ]
                                          },
                                          "snapchatMessageText": {
                                            "anyOf": [
                                              {
                                                "type": "string"
                                              },
                                              {
                                                "type": "null"
                                              }
                                            ]
                                          },
                                          "snapchatPhoneNumberId": {
                                            "anyOf": [
                                              {
                                                "type": "string"
                                              },
                                              {
                                                "type": "null"
                                              }
                                            ]
                                          },
                                          "snapchatShareable": {
                                            "anyOf": [
                                              {
                                                "type": "boolean"
                                              },
                                              {
                                                "type": "null"
                                              }
                                            ]
                                          },
                                          "snapchatSmartPrefetching": {
                                            "anyOf": [
                                              {
                                                "type": "boolean"
                                              },
                                              {
                                                "type": "null"
                                              }
                                            ]
                                          },
                                          "status": {
                                            "anyOf": [
                                              {
                                                "anyOf": [
                                                  {
                                                    "type": "string",
                                                    "enum": [
                                                      "ACTIVE"
                                                    ]
                                                  },
                                                  {
                                                    "type": "string",
                                                    "enum": [
                                                      "PAUSED"
                                                    ]
                                                  }
                                                ]
                                              },
                                              {
                                                "type": "null"
                                              }
                                            ]
                                          },
                                          "taboolaCta": {
                                            "anyOf": [
                                              {
                                                "type": "string"
                                              },
                                              {
                                                "type": "null"
                                              }
                                            ]
                                          },
                                          "taboolaHeadlines": {
                                            "anyOf": [
                                              {
                                                "type": "array",
                                                "items": {
                                                  "type": "string"
                                                }
                                              },
                                              {
                                                "type": "null"
                                              }
                                            ]
                                          },
                                          "targetLanguage": {
                                            "anyOf": [
                                              {
                                                "type": "string"
                                              },
                                              {
                                                "type": "null"
                                              }
                                            ]
                                          },
                                          "unmatchedAudienceVideo": {
                                            "anyOf": [
                                              {
                                                "anyOf": [
                                                  {
                                                    "type": "string",
                                                    "enum": [
                                                      "safe"
                                                    ]
                                                  },
                                                  {
                                                    "type": "string",
                                                    "enum": [
                                                      "targeted"
                                                    ]
                                                  }
                                                ]
                                              },
                                              {
                                                "type": "null"
                                              }
                                            ]
                                          },
                                          "url": {
                                            "anyOf": [
                                              {
                                                "type": "string"
                                              },
                                              {
                                                "type": "null"
                                              }
                                            ]
                                          },
                                          "urlParameters": {
                                            "anyOf": [
                                              {
                                                "type": "string"
                                              },
                                              {
                                                "type": "null"
                                              }
                                            ]
                                          }
                                        }
                                      }
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "attribution": {
                                  "anyOf": [
                                    {
                                      "additionalProperties": false,
                                      "type": "object",
                                      "properties": {
                                        "clickWindow": {
                                          "anyOf": [
                                            {
                                              "anyOf": [
                                                {
                                                  "type": "number",
                                                  "enum": [
                                                    1
                                                  ]
                                                },
                                                {
                                                  "type": "number",
                                                  "enum": [
                                                    7
                                                  ]
                                                }
                                              ]
                                            },
                                            {
                                              "type": "null"
                                            }
                                          ]
                                        },
                                        "viewWindow": {
                                          "anyOf": [
                                            {
                                              "anyOf": [
                                                {
                                                  "type": "number",
                                                  "enum": [
                                                    0
                                                  ]
                                                },
                                                {
                                                  "type": "number",
                                                  "enum": [
                                                    1
                                                  ]
                                                }
                                              ]
                                            },
                                            {
                                              "type": "null"
                                            }
                                          ]
                                        }
                                      }
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "bidAmount": {
                                  "anyOf": [
                                    {
                                      "type": "number"
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "billingEvent": {
                                  "anyOf": [
                                    {
                                      "type": "string"
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "budget": {
                                  "anyOf": [
                                    {
                                      "type": "number"
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "budgetType": {
                                  "anyOf": [
                                    {
                                      "anyOf": [
                                        {
                                          "type": "string",
                                          "enum": [
                                            "DAILY"
                                          ]
                                        },
                                        {
                                          "type": "string",
                                          "enum": [
                                            "LIFETIME"
                                          ]
                                        }
                                      ]
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "customAudiences": {
                                  "anyOf": [
                                    {
                                      "type": "array",
                                      "items": {
                                        "type": "string"
                                      }
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "destinationType": {
                                  "anyOf": [
                                    {
                                      "type": "string"
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "dsaFields": {
                                  "anyOf": [
                                    {
                                      "additionalProperties": false,
                                      "type": "object",
                                      "properties": {
                                        "beneficiary": {
                                          "anyOf": [
                                            {
                                              "type": "string"
                                            },
                                            {
                                              "type": "null"
                                            }
                                          ]
                                        },
                                        "payer": {
                                          "anyOf": [
                                            {
                                              "type": "string"
                                            },
                                            {
                                              "type": "null"
                                            }
                                          ]
                                        }
                                      }
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "endDate": {
                                  "anyOf": [
                                    {
                                      "type": "string"
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "endTime": {
                                  "anyOf": [
                                    {
                                      "type": "string"
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "excludedAudiences": {
                                  "anyOf": [
                                    {
                                      "type": "array",
                                      "items": {
                                        "type": "string"
                                      }
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "id": {
                                  "anyOf": [
                                    {
                                      "type": "string"
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "keywords": {
                                  "anyOf": [
                                    {
                                      "type": "string"
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "metaLeadFormId": {
                                  "anyOf": [
                                    {
                                      "type": "string"
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "name": {
                                  "anyOf": [
                                    {
                                      "type": "string"
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "optimizationGoal": {
                                  "anyOf": [
                                    {
                                      "type": "string"
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "placements": {
                                  "anyOf": [
                                    {
                                      "additionalProperties": false,
                                      "type": "object",
                                      "properties": {
                                        "audienceNetworkPositions": {
                                          "anyOf": [
                                            {
                                              "type": "array",
                                              "items": {
                                                "type": "string"
                                              }
                                            },
                                            {
                                              "type": "null"
                                            }
                                          ]
                                        },
                                        "automatic": {
                                          "anyOf": [
                                            {
                                              "type": "boolean"
                                            },
                                            {
                                              "type": "null"
                                            }
                                          ]
                                        },
                                        "facebookPositions": {
                                          "anyOf": [
                                            {
                                              "type": "array",
                                              "items": {
                                                "type": "string"
                                              }
                                            },
                                            {
                                              "type": "null"
                                            }
                                          ]
                                        },
                                        "instagramPositions": {
                                          "anyOf": [
                                            {
                                              "type": "array",
                                              "items": {
                                                "type": "string"
                                              }
                                            },
                                            {
                                              "type": "null"
                                            }
                                          ]
                                        },
                                        "messengerPositions": {
                                          "anyOf": [
                                            {
                                              "type": "array",
                                              "items": {
                                                "type": "string"
                                              }
                                            },
                                            {
                                              "type": "null"
                                            }
                                          ]
                                        },
                                        "publisherPlatforms": {
                                          "anyOf": [
                                            {
                                              "type": "array",
                                              "items": {
                                                "anyOf": [
                                                  {
                                                    "type": "string",
                                                    "enum": [
                                                      "facebook"
                                                    ]
                                                  },
                                                  {
                                                    "type": "string",
                                                    "enum": [
                                                      "instagram"
                                                    ]
                                                  },
                                                  {
                                                    "type": "string",
                                                    "enum": [
                                                      "audience_network"
                                                    ]
                                                  },
                                                  {
                                                    "type": "string",
                                                    "enum": [
                                                      "messenger"
                                                    ]
                                                  },
                                                  {
                                                    "type": "string",
                                                    "enum": [
                                                      "threads"
                                                    ]
                                                  }
                                                ]
                                              }
                                            },
                                            {
                                              "type": "null"
                                            }
                                          ]
                                        },
                                        "snapchatBrandSuitability": {
                                          "anyOf": [
                                            {
                                              "type": "string"
                                            },
                                            {
                                              "type": "null"
                                            }
                                          ]
                                        },
                                        "snapchatConfig": {
                                          "anyOf": [
                                            {
                                              "type": "string"
                                            },
                                            {
                                              "type": "null"
                                            }
                                          ]
                                        },
                                        "snapchatCustomType": {
                                          "anyOf": [
                                            {
                                              "type": "string"
                                            },
                                            {
                                              "type": "null"
                                            }
                                          ]
                                        },
                                        "snapchatPositions": {
                                          "anyOf": [
                                            {
                                              "type": "array",
                                              "items": {
                                                "type": "string"
                                              }
                                            },
                                            {
                                              "type": "null"
                                            }
                                          ]
                                        },
                                        "threadsPositions": {
                                          "anyOf": [
                                            {
                                              "type": "array",
                                              "items": {
                                                "type": "string"
                                              }
                                            },
                                            {
                                              "type": "null"
                                            }
                                          ]
                                        }
                                      }
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "platformId": {
                                  "anyOf": [
                                    {
                                      "type": "string"
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "promotedObject": {
                                  "anyOf": [
                                    {
                                      "additionalProperties": false,
                                      "type": "object",
                                      "properties": {
                                        "appId": {
                                          "anyOf": [
                                            {
                                              "type": "string"
                                            },
                                            {
                                              "type": "null"
                                            }
                                          ]
                                        },
                                        "catalogId": {
                                          "anyOf": [
                                            {
                                              "type": "string"
                                            },
                                            {
                                              "type": "null"
                                            }
                                          ]
                                        },
                                        "customEventType": {
                                          "anyOf": [
                                            {
                                              "type": "string"
                                            },
                                            {
                                              "type": "null"
                                            }
                                          ]
                                        },
                                        "objectStoreUrl": {
                                          "anyOf": [
                                            {
                                              "type": "string"
                                            },
                                            {
                                              "type": "null"
                                            }
                                          ]
                                        },
                                        "pageId": {
                                          "anyOf": [
                                            {
                                              "type": "string"
                                            },
                                            {
                                              "type": "null"
                                            }
                                          ]
                                        },
                                        "pixelId": {
                                          "anyOf": [
                                            {
                                              "type": "string"
                                            },
                                            {
                                              "type": "null"
                                            }
                                          ]
                                        },
                                        "productSetId": {
                                          "anyOf": [
                                            {
                                              "type": "string"
                                            },
                                            {
                                              "type": "null"
                                            }
                                          ]
                                        }
                                      }
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "roasFloor": {
                                  "anyOf": [
                                    {
                                      "type": "number"
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "snapchatAppId": {
                                  "anyOf": [
                                    {
                                      "type": "string"
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "snapchatAudienceType": {
                                  "anyOf": [
                                    {
                                      "anyOf": [
                                        {
                                          "type": "string",
                                          "enum": [
                                            "PROSPECTING"
                                          ]
                                        },
                                        {
                                          "type": "string",
                                          "enum": [
                                            "RETARGETING"
                                          ]
                                        }
                                      ]
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "snapchatCatalogId": {
                                  "anyOf": [
                                    {
                                      "type": "string"
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "snapchatConversionLocation": {
                                  "anyOf": [
                                    {
                                      "type": "string"
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "snapchatLeadFormId": {
                                  "anyOf": [
                                    {
                                      "type": "string"
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "snapchatPixelId": {
                                  "anyOf": [
                                    {
                                      "type": "string"
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "snapchatProductSetId": {
                                  "anyOf": [
                                    {
                                      "type": "string"
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "spendPercent": {
                                  "anyOf": [
                                    {
                                      "minimum": 1,
                                      "maximum": 100,
                                      "type": "number"
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "startDate": {
                                  "anyOf": [
                                    {
                                      "type": "string"
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "startTime": {
                                  "anyOf": [
                                    {
                                      "type": "string"
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "status": {
                                  "anyOf": [
                                    {
                                      "anyOf": [
                                        {
                                          "type": "string",
                                          "enum": [
                                            "ACTIVE"
                                          ]
                                        },
                                        {
                                          "type": "string",
                                          "enum": [
                                            "PAUSED"
                                          ]
                                        }
                                      ]
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "targeting": {
                                  "anyOf": [
                                    {
                                      "additionalProperties": false,
                                      "type": "object",
                                      "properties": {
                                        "advantageAge": {
                                          "anyOf": [
                                            {
                                              "type": "boolean"
                                            },
                                            {
                                              "type": "null"
                                            }
                                          ]
                                        },
                                        "advantageAudience": {
                                          "anyOf": [
                                            {
                                              "type": "boolean"
                                            },
                                            {
                                              "type": "null"
                                            }
                                          ]
                                        },
                                        "advantageDetailedTargeting": {
                                          "anyOf": [
                                            {
                                              "type": "boolean"
                                            },
                                            {
                                              "type": "null"
                                            }
                                          ]
                                        },
                                        "advantageGender": {
                                          "anyOf": [
                                            {
                                              "type": "boolean"
                                            },
                                            {
                                              "type": "null"
                                            }
                                          ]
                                        },
                                        "advantageLookalike": {
                                          "anyOf": [
                                            {
                                              "type": "boolean"
                                            },
                                            {
                                              "type": "null"
                                            }
                                          ]
                                        },
                                        "ageMax": {
                                          "anyOf": [
                                            {
                                              "type": "number"
                                            },
                                            {
                                              "type": "null"
                                            }
                                          ]
                                        },
                                        "ageMin": {
                                          "anyOf": [
                                            {
                                              "type": "number"
                                            },
                                            {
                                              "type": "null"
                                            }
                                          ]
                                        },
                                        "countries": {
                                          "anyOf": [
                                            {
                                              "type": "array",
                                              "items": {
                                                "type": "string"
                                              }
                                            },
                                            {
                                              "type": "null"
                                            }
                                          ]
                                        },
                                        "devicePlatforms": {
                                          "anyOf": [
                                            {
                                              "type": "array",
                                              "items": {
                                                "anyOf": [
                                                  {
                                                    "type": "string",
                                                    "enum": [
                                                      "mobile"
                                                    ]
                                                  },
                                                  {
                                                    "type": "string",
                                                    "enum": [
                                                      "desktop"
                                                    ]
                                                  }
                                                ]
                                              }
                                            },
                                            {
                                              "type": "null"
                                            }
                                          ]
                                        },
                                        "genders": {
                                          "anyOf": [
                                            {
                                              "type": "array",
                                              "items": {
                                                "type": "number"
                                              }
                                            },
                                            {
                                              "type": "null"
                                            }
                                          ]
                                        },
                                        "locales": {
                                          "anyOf": [
                                            {
                                              "type": "array",
                                              "items": {
                                                "type": "number"
                                              }
                                            },
                                            {
                                              "type": "null"
                                            }
                                          ]
                                        },
                                        "locations": {
                                          "anyOf": [
                                            {
                                              "type": "array",
                                              "items": {
                                                "additionalProperties": false,
                                                "type": "object",
                                                "required": [
                                                  "countryCode",
                                                  "key",
                                                  "name",
                                                  "type"
                                                ],
                                                "properties": {
                                                  "countryCode": {
                                                    "type": "string"
                                                  },
                                                  "distanceUnit": {
                                                    "anyOf": [
                                                      {
                                                        "type": "string"
                                                      },
                                                      {
                                                        "type": "null"
                                                      }
                                                    ]
                                                  },
                                                  "key": {
                                                    "type": "string"
                                                  },
                                                  "name": {
                                                    "type": "string"
                                                  },
                                                  "radius": {
                                                    "anyOf": [
                                                      {
                                                        "minimum": 10,
                                                        "maximum": 80,
                                                        "type": "number"
                                                      },
                                                      {
                                                        "type": "null"
                                                      }
                                                    ]
                                                  },
                                                  "region": {
                                                    "anyOf": [
                                                      {
                                                        "type": "string"
                                                      },
                                                      {
                                                        "type": "null"
                                                      }
                                                    ]
                                                  },
                                                  "type": {
                                                    "anyOf": [
                                                      {
                                                        "type": "string",
                                                        "enum": [
                                                          "region"
                                                        ]
                                                      },
                                                      {
                                                        "type": "string",
                                                        "enum": [
                                                          "city"
                                                        ]
                                                      }
                                                    ]
                                                  }
                                                }
                                              }
                                            },
                                            {
                                              "type": "null"
                                            }
                                          ]
                                        },
                                        "operatingSystems": {
                                          "anyOf": [
                                            {
                                              "type": "array",
                                              "items": {
                                                "type": "string"
                                              }
                                            },
                                            {
                                              "type": "null"
                                            }
                                          ]
                                        }
                                      }
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                }
                              }
                            }
                          },
                          {
                            "type": "null"
                          }
                        ]
                      },
                      "campaign": {
                        "anyOf": [
                          {
                            "additionalProperties": false,
                            "type": "object",
                            "properties": {
                              "acceleratedDelivery": {
                                "anyOf": [
                                  {
                                    "type": "boolean"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "advantagePlus": {
                                "anyOf": [
                                  {
                                    "type": "boolean"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "bidStrategy": {
                                "anyOf": [
                                  {
                                    "type": "string"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "budget": {
                                "anyOf": [
                                  {
                                    "type": "number"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "budgetLevel": {
                                "anyOf": [
                                  {
                                    "anyOf": [
                                      {
                                        "type": "string",
                                        "enum": [
                                          "CBO"
                                        ]
                                      },
                                      {
                                        "type": "string",
                                        "enum": [
                                          "ABO"
                                        ]
                                      }
                                    ]
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "budgetType": {
                                "anyOf": [
                                  {
                                    "anyOf": [
                                      {
                                        "type": "string",
                                        "enum": [
                                          "DAILY"
                                        ]
                                      },
                                      {
                                        "type": "string",
                                        "enum": [
                                          "LIFETIME"
                                        ]
                                      }
                                    ]
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "buyingType": {
                                "anyOf": [
                                  {
                                    "anyOf": [
                                      {
                                        "type": "string",
                                        "enum": [
                                          "AUCTION"
                                        ]
                                      },
                                      {
                                        "type": "string",
                                        "enum": [
                                          "RESERVED"
                                        ]
                                      }
                                    ]
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "customerAcquisition": {
                                "anyOf": [
                                  {
                                    "type": "boolean"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "googleGoal": {
                                "anyOf": [
                                  {
                                    "anyOf": [
                                      {
                                        "type": "string",
                                        "enum": [
                                          "SALES"
                                        ]
                                      },
                                      {
                                        "type": "string",
                                        "enum": [
                                          "LEADS"
                                        ]
                                      },
                                      {
                                        "type": "string",
                                        "enum": [
                                          "WEBSITE_TRAFFIC"
                                        ]
                                      },
                                      {
                                        "type": "string",
                                        "enum": [
                                          "APP_PROMOTION"
                                        ]
                                      },
                                      {
                                        "type": "string",
                                        "enum": [
                                          "AWARENESS"
                                        ]
                                      },
                                      {
                                        "type": "string",
                                        "enum": [
                                          "LOCAL_STORE"
                                        ]
                                      },
                                      {
                                        "type": "string",
                                        "enum": [
                                          "NO_GOAL"
                                        ]
                                      }
                                    ]
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "googleMerchantId": {
                                "anyOf": [
                                  {
                                    "type": "string"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "metaLeadFormId": {
                                "anyOf": [
                                  {
                                    "type": "string"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "metaTokenId": {
                                "anyOf": [
                                  {
                                    "type": "string"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "name": {
                                "anyOf": [
                                  {
                                    "type": "string"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "objective": {
                                "anyOf": [
                                  {
                                    "type": "string"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "outbrainBudgetPacing": {
                                "anyOf": [
                                  {
                                    "anyOf": [
                                      {
                                        "type": "string",
                                        "enum": [
                                          "DAILY"
                                        ]
                                      },
                                      {
                                        "type": "string",
                                        "enum": [
                                          "MONTHLY"
                                        ]
                                      },
                                      {
                                        "type": "string",
                                        "enum": [
                                          "ENTIRE"
                                        ]
                                      }
                                    ]
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "outbrainConversionGoalId": {
                                "anyOf": [
                                  {
                                    "type": "string"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "outbrainCpcCents": {
                                "anyOf": [
                                  {
                                    "type": "number"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "outbrainCurrency": {
                                "anyOf": [
                                  {
                                    "type": "string"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "outbrainDailyBudgetCents": {
                                "anyOf": [
                                  {
                                    "type": "number"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "outbrainDayparting": {
                                "anyOf": [
                                  {
                                    "additionalProperties": false,
                                    "type": "object",
                                    "properties": {
                                      "FRIDAY": {
                                        "anyOf": [
                                          {
                                            "type": "array",
                                            "items": {
                                              "minimum": 0,
                                              "maximum": 23,
                                              "type": "integer"
                                            }
                                          },
                                          {
                                            "type": "null"
                                          }
                                        ]
                                      },
                                      "MONDAY": {
                                        "anyOf": [
                                          {
                                            "type": "array",
                                            "items": {
                                              "minimum": 0,
                                              "maximum": 23,
                                              "type": "integer"
                                            }
                                          },
                                          {
                                            "type": "null"
                                          }
                                        ]
                                      },
                                      "SATURDAY": {
                                        "anyOf": [
                                          {
                                            "type": "array",
                                            "items": {
                                              "minimum": 0,
                                              "maximum": 23,
                                              "type": "integer"
                                            }
                                          },
                                          {
                                            "type": "null"
                                          }
                                        ]
                                      },
                                      "SUNDAY": {
                                        "anyOf": [
                                          {
                                            "type": "array",
                                            "items": {
                                              "minimum": 0,
                                              "maximum": 23,
                                              "type": "integer"
                                            }
                                          },
                                          {
                                            "type": "null"
                                          }
                                        ]
                                      },
                                      "THURSDAY": {
                                        "anyOf": [
                                          {
                                            "type": "array",
                                            "items": {
                                              "minimum": 0,
                                              "maximum": 23,
                                              "type": "integer"
                                            }
                                          },
                                          {
                                            "type": "null"
                                          }
                                        ]
                                      },
                                      "TUESDAY": {
                                        "anyOf": [
                                          {
                                            "type": "array",
                                            "items": {
                                              "minimum": 0,
                                              "maximum": 23,
                                              "type": "integer"
                                            }
                                          },
                                          {
                                            "type": "null"
                                          }
                                        ]
                                      },
                                      "WEDNESDAY": {
                                        "anyOf": [
                                          {
                                            "type": "array",
                                            "items": {
                                              "minimum": 0,
                                              "maximum": 23,
                                              "type": "integer"
                                            }
                                          },
                                          {
                                            "type": "null"
                                          }
                                        ]
                                      }
                                    }
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "outbrainEndDate": {
                                "anyOf": [
                                  {
                                    "type": "string"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "outbrainStartDate": {
                                "anyOf": [
                                  {
                                    "type": "string"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "outbrainTargeting": {
                                "anyOf": [
                                  {
                                    "additionalProperties": false,
                                    "type": "object",
                                    "properties": {
                                      "browsers": {
                                        "anyOf": [
                                          {
                                            "type": "array",
                                            "items": {
                                              "type": "string"
                                            }
                                          },
                                          {
                                            "type": "null"
                                          }
                                        ]
                                      },
                                      "countries": {
                                        "anyOf": [
                                          {
                                            "type": "array",
                                            "items": {
                                              "type": "string"
                                            }
                                          },
                                          {
                                            "type": "null"
                                          }
                                        ]
                                      },
                                      "custom_audiences": {
                                        "anyOf": [
                                          {
                                            "type": "array",
                                            "items": {
                                              "type": "string"
                                            }
                                          },
                                          {
                                            "type": "null"
                                          }
                                        ]
                                      },
                                      "iab_categories": {
                                        "anyOf": [
                                          {
                                            "type": "array",
                                            "items": {
                                              "type": "string"
                                            }
                                          },
                                          {
                                            "type": "null"
                                          }
                                        ]
                                      },
                                      "languages": {
                                        "anyOf": [
                                          {
                                            "type": "array",
                                            "items": {
                                              "type": "string"
                                            }
                                          },
                                          {
                                            "type": "null"
                                          }
                                        ]
                                      },
                                      "operating_systems": {
                                        "anyOf": [
                                          {
                                            "type": "array",
                                            "items": {
                                              "type": "string"
                                            }
                                          },
                                          {
                                            "type": "null"
                                          }
                                        ]
                                      },
                                      "platforms": {
                                        "anyOf": [
                                          {
                                            "type": "array",
                                            "items": {
                                              "type": "string"
                                            }
                                          },
                                          {
                                            "type": "null"
                                          }
                                        ]
                                      },
                                      "sections": {
                                        "anyOf": [
                                          {
                                            "additionalProperties": false,
                                            "type": "object",
                                            "properties": {
                                              "exclude": {
                                                "anyOf": [
                                                  {
                                                    "type": "array",
                                                    "items": {
                                                      "type": "string"
                                                    }
                                                  },
                                                  {
                                                    "type": "null"
                                                  }
                                                ]
                                              },
                                              "include": {
                                                "anyOf": [
                                                  {
                                                    "type": "array",
                                                    "items": {
                                                      "type": "string"
                                                    }
                                                  },
                                                  {
                                                    "type": "null"
                                                  }
                                                ]
                                              }
                                            }
                                          },
                                          {
                                            "type": "null"
                                          }
                                        ]
                                      }
                                    }
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "reachGoals": {
                                "anyOf": [
                                  {
                                    "additionalProperties": false,
                                    "type": "object",
                                    "properties": {
                                      "phoneCall": {
                                        "anyOf": [
                                          {
                                            "type": "boolean"
                                          },
                                          {
                                            "type": "null"
                                          }
                                        ]
                                      },
                                      "storeVisit": {
                                        "anyOf": [
                                          {
                                            "type": "boolean"
                                          },
                                          {
                                            "type": "null"
                                          }
                                        ]
                                      },
                                      "websiteVisit": {
                                        "anyOf": [
                                          {
                                            "type": "boolean"
                                          },
                                          {
                                            "type": "null"
                                          }
                                        ]
                                      }
                                    }
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "snapchatDynamicAds": {
                                "anyOf": [
                                  {
                                    "type": "boolean"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "snapchatLifetimeSpendCap": {
                                "anyOf": [
                                  {
                                    "type": "number"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "snapchatMobileApp": {
                                "anyOf": [
                                  {
                                    "additionalProperties": false,
                                    "type": "object",
                                    "properties": {
                                      "android_app_url": {
                                        "anyOf": [
                                          {
                                            "type": "string"
                                          },
                                          {
                                            "type": "null"
                                          }
                                        ]
                                      },
                                      "app_name": {
                                        "anyOf": [
                                          {
                                            "type": "string"
                                          },
                                          {
                                            "type": "null"
                                          }
                                        ]
                                      },
                                      "ios_app_id": {
                                        "anyOf": [
                                          {
                                            "type": "string"
                                          },
                                          {
                                            "type": "null"
                                          }
                                        ]
                                      }
                                    }
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "snapchatPromotionType": {
                                "anyOf": [
                                  {
                                    "anyOf": [
                                      {
                                        "type": "string",
                                        "enum": [
                                          "APP_INSTALL"
                                        ]
                                      },
                                      {
                                        "type": "string",
                                        "enum": [
                                          "APP_REENGAGEMENT"
                                        ]
                                      }
                                    ]
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "snapchatPublicProfileId": {
                                "anyOf": [
                                  {
                                    "type": "string"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "specialAdCategories": {
                                "anyOf": [
                                  {
                                    "type": "array",
                                    "items": {
                                      "anyOf": [
                                        {
                                          "type": "string",
                                          "enum": [
                                            "NONE"
                                          ]
                                        },
                                        {
                                          "type": "string",
                                          "enum": [
                                            "HOUSING"
                                          ]
                                        },
                                        {
                                          "type": "string",
                                          "enum": [
                                            "EMPLOYMENT"
                                          ]
                                        },
                                        {
                                          "type": "string",
                                          "enum": [
                                            "CREDIT"
                                          ]
                                        },
                                        {
                                          "type": "string",
                                          "enum": [
                                            "ISSUES_ELECTIONS_POLITICS"
                                          ]
                                        },
                                        {
                                          "type": "string",
                                          "enum": [
                                            "ONLINE_GAMBLING_AND_GAMING"
                                          ]
                                        }
                                      ]
                                    }
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "status": {
                                "anyOf": [
                                  {
                                    "anyOf": [
                                      {
                                        "type": "string",
                                        "enum": [
                                          "ACTIVE"
                                        ]
                                      },
                                      {
                                        "type": "string",
                                        "enum": [
                                          "PAUSED"
                                        ]
                                      }
                                    ]
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "taboolaBidStrategy": {
                                "anyOf": [
                                  {
                                    "anyOf": [
                                      {
                                        "type": "string",
                                        "enum": [
                                          "FIXED"
                                        ]
                                      },
                                      {
                                        "type": "string",
                                        "enum": [
                                          "TARGET_CPA"
                                        ]
                                      }
                                    ]
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "taboolaBrandingText": {
                                "anyOf": [
                                  {
                                    "type": "string"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "taboolaCpaGoal": {
                                "anyOf": [
                                  {
                                    "type": "number"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "taboolaCpc": {
                                "anyOf": [
                                  {
                                    "type": "number"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "taboolaDailyCap": {
                                "anyOf": [
                                  {
                                    "type": "number"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "taboolaPricingModel": {
                                "anyOf": [
                                  {
                                    "type": "string"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "taboolaSpendingLimit": {
                                "anyOf": [
                                  {
                                    "type": "number"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "taboolaSpendingLimitType": {
                                "anyOf": [
                                  {
                                    "anyOf": [
                                      {
                                        "type": "string",
                                        "enum": [
                                          "MONTHLY"
                                        ]
                                      },
                                      {
                                        "type": "string",
                                        "enum": [
                                          "ENTIRE"
                                        ]
                                      }
                                    ]
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "tiktokAppId": {
                                "anyOf": [
                                  {
                                    "type": "string"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "tiktokBidAmount": {
                                "anyOf": [
                                  {
                                    "type": "number"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "tiktokBidType": {
                                "anyOf": [
                                  {
                                    "anyOf": [
                                      {
                                        "type": "string",
                                        "enum": [
                                          "BID_TYPE_CUSTOM"
                                        ]
                                      },
                                      {
                                        "type": "string",
                                        "enum": [
                                          "BID_TYPE_NO_BID"
                                        ]
                                      }
                                    ]
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "tiktokBillingEvent": {
                                "anyOf": [
                                  {
                                    "anyOf": [
                                      {
                                        "type": "string",
                                        "enum": [
                                          "CPM"
                                        ]
                                      },
                                      {
                                        "type": "string",
                                        "enum": [
                                          "OCPM"
                                        ]
                                      },
                                      {
                                        "type": "string",
                                        "enum": [
                                          "CPC"
                                        ]
                                      },
                                      {
                                        "type": "string",
                                        "enum": [
                                          "CPV"
                                        ]
                                      }
                                    ]
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "tiktokCatalogId": {
                                "anyOf": [
                                  {
                                    "type": "string"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "tiktokIdentityId": {
                                "anyOf": [
                                  {
                                    "type": "string"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "tiktokIdentityType": {
                                "anyOf": [
                                  {
                                    "anyOf": [
                                      {
                                        "type": "string",
                                        "enum": [
                                          "TT_USER"
                                        ]
                                      },
                                      {
                                        "type": "string",
                                        "enum": [
                                          "CUSTOMIZED_USER"
                                        ]
                                      },
                                      {
                                        "type": "string",
                                        "enum": [
                                          "BC_AUTH_TT"
                                        ]
                                      }
                                    ]
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "tiktokItemId": {
                                "anyOf": [
                                  {
                                    "type": "string"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "tiktokLeadFormId": {
                                "anyOf": [
                                  {
                                    "type": "string"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "tiktokOptimizeGoal": {
                                "anyOf": [
                                  {
                                    "type": "string"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "tiktokPixelEvent": {
                                "anyOf": [
                                  {
                                    "type": "string"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "tiktokPixelId": {
                                "anyOf": [
                                  {
                                    "type": "string"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "tiktokRoasBid": {
                                "anyOf": [
                                  {
                                    "type": "number"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              }
                            }
                          },
                          {
                            "type": "null"
                          }
                        ]
                      },
                      "currency": {
                        "anyOf": [
                          {
                            "type": "string"
                          },
                          {
                            "type": "null"
                          }
                        ]
                      },
                      "editWarning": {
                        "anyOf": [
                          {
                            "additionalProperties": false,
                            "type": "object",
                            "properties": {
                              "kind": {
                                "anyOf": [
                                  {
                                    "anyOf": [
                                      {
                                        "type": "string",
                                        "enum": [
                                          "none"
                                        ]
                                      },
                                      {
                                        "type": "string",
                                        "enum": [
                                          "learning_reset"
                                        ]
                                      },
                                      {
                                        "type": "string",
                                        "enum": [
                                          "recreate"
                                        ]
                                      },
                                      {
                                        "type": "string",
                                        "enum": [
                                          "re_review"
                                        ]
                                      },
                                      {
                                        "type": "string",
                                        "enum": [
                                          "id_change"
                                        ]
                                      }
                                    ]
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "reason": {
                                "anyOf": [
                                  {
                                    "type": "string"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              }
                            }
                          },
                          {
                            "type": "null"
                          }
                        ]
                      },
                      "id": {
                        "anyOf": [
                          {
                            "type": "string"
                          },
                          {
                            "type": "null"
                          }
                        ]
                      },
                      "platformId": {
                        "anyOf": [
                          {
                            "type": "string"
                          },
                          {
                            "type": "null"
                          }
                        ]
                      },
                      "publishMode": {
                        "anyOf": [
                          {
                            "anyOf": [
                              {
                                "type": "string",
                                "enum": [
                                  "create_all"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "ads_only"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "add_adset"
                                ]
                              }
                            ]
                          },
                          {
                            "type": "null"
                          }
                        ]
                      },
                      "sessionId": {
                        "anyOf": [
                          {
                            "type": "string"
                          },
                          {
                            "type": "null"
                          }
                        ]
                      }
                    }
                  },
                  "current_step": {
                    "minimum": 0,
                    "maximum": 20,
                    "type": "integer"
                  },
                  "status": {
                    "type": "string"
                  },
                  "platform": {
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "id",
                    "account_id",
                    "name",
                    "source",
                    "status",
                    "platform",
                    "current_step",
                    "canonical_campaign",
                    "created_at",
                    "updated_at"
                  ],
                  "properties": {
                    "id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "account_id": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "name": {
                      "type": "string"
                    },
                    "source": {
                      "type": "string"
                    },
                    "status": {
                      "type": "string"
                    },
                    "platform": {
                      "type": "string"
                    },
                    "current_step": {
                      "type": "integer"
                    },
                    "canonical_campaign": {
                      "$comment": "json-value",
                      "description": "Arbitrary JSON value with nested arrays and objects."
                    },
                    "created_at": {
                      "format": "date-time",
                      "type": "string"
                    },
                    "updated_at": {
                      "anyOf": [
                        {
                          "format": "date-time",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "error_code": {
                      "type": "string"
                    },
                    "detail": {}
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "error_code": {
                      "type": "string"
                    },
                    "detail": {}
                  }
                }
              }
            }
          }
        }
      },
      "delete": {
        "operationId": "deleteCampaignDraft",
        "summary": "Delete campaign draft",
        "tags": [
          "campaigns"
        ],
        "description": "Soft-deletes a campaign draft by its UUID.",
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "message"
                  ],
                  "properties": {
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "error_code": {
                      "type": "string"
                    },
                    "detail": {}
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "error_code": {
                      "type": "string"
                    },
                    "detail": {}
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/campaign-drafts/{id}/validate": {
      "post": {
        "operationId": "validateCampaignDraft",
        "summary": "Validate campaign draft",
        "tags": [
          "campaigns"
        ],
        "description": "Runs full validation on all fields of a campaign draft and returns any errors or warnings. Optionally accepts canonical_campaign in body to validate in-memory state.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "properties": {
                  "canonical_campaign": {
                    "additionalProperties": false,
                    "description": "Canonical campaign JSONB shape used by campaign drafts. Fields are optional because drafts are auto-saved while incomplete.",
                    "type": "object",
                    "properties": {
                      "accountId": {
                        "anyOf": [
                          {
                            "type": "string"
                          },
                          {
                            "type": "null"
                          }
                        ]
                      },
                      "adSets": {
                        "anyOf": [
                          {
                            "type": "array",
                            "items": {
                              "additionalProperties": false,
                              "type": "object",
                              "properties": {
                                "ads": {
                                  "anyOf": [
                                    {
                                      "type": "array",
                                      "items": {
                                        "additionalProperties": false,
                                        "type": "object",
                                        "properties": {
                                          "advantageCreative": {
                                            "anyOf": [
                                              {
                                                "type": "boolean"
                                              },
                                              {
                                                "type": "null"
                                              }
                                            ]
                                          },
                                          "callToAction": {
                                            "anyOf": [
                                              {
                                                "type": "string"
                                              },
                                              {
                                                "type": "null"
                                              }
                                            ]
                                          },
                                          "creativeFormat": {
                                            "anyOf": [
                                              {
                                                "anyOf": [
                                                  {
                                                    "type": "string",
                                                    "enum": [
                                                      "SINGLE_IMAGE"
                                                    ]
                                                  },
                                                  {
                                                    "type": "string",
                                                    "enum": [
                                                      "SINGLE_VIDEO"
                                                    ]
                                                  },
                                                  {
                                                    "type": "string",
                                                    "enum": [
                                                      "CAROUSEL"
                                                    ]
                                                  },
                                                  {
                                                    "type": "string",
                                                    "enum": [
                                                      "EXISTING_POST"
                                                    ]
                                                  },
                                                  {
                                                    "type": "string",
                                                    "enum": [
                                                      "CATALOG"
                                                    ]
                                                  },
                                                  {
                                                    "type": "string",
                                                    "enum": [
                                                      "FLEXIBLE"
                                                    ]
                                                  }
                                                ]
                                              },
                                              {
                                                "type": "null"
                                              }
                                            ]
                                          },
                                          "description": {
                                            "anyOf": [
                                              {
                                                "type": "string"
                                              },
                                              {
                                                "type": "null"
                                              }
                                            ]
                                          },
                                          "descriptionVariations": {
                                            "anyOf": [
                                              {
                                                "type": "array",
                                                "items": {
                                                  "type": "string"
                                                }
                                              },
                                              {
                                                "type": "null"
                                              }
                                            ]
                                          },
                                          "dynamicCreative": {
                                            "anyOf": [
                                              {
                                                "type": "boolean"
                                              },
                                              {
                                                "type": "null"
                                              }
                                            ]
                                          },
                                          "existingPostId": {
                                            "anyOf": [
                                              {
                                                "type": "string"
                                              },
                                              {
                                                "type": "null"
                                              }
                                            ]
                                          },
                                          "existingPostPreview": {
                                            "anyOf": [
                                              {
                                                "additionalProperties": false,
                                                "type": "object",
                                                "properties": {
                                                  "imageUrl": {
                                                    "anyOf": [
                                                      {
                                                        "type": "string"
                                                      },
                                                      {
                                                        "type": "null"
                                                      }
                                                    ]
                                                  },
                                                  "message": {
                                                    "anyOf": [
                                                      {
                                                        "type": "string"
                                                      },
                                                      {
                                                        "type": "null"
                                                      }
                                                    ]
                                                  }
                                                }
                                              },
                                              {
                                                "type": "null"
                                              }
                                            ]
                                          },
                                          "googleDescriptions": {
                                            "anyOf": [
                                              {
                                                "type": "array",
                                                "items": {
                                                  "type": "string"
                                                }
                                              },
                                              {
                                                "type": "null"
                                              }
                                            ]
                                          },
                                          "googleDisplayPath1": {
                                            "anyOf": [
                                              {
                                                "type": "string"
                                              },
                                              {
                                                "type": "null"
                                              }
                                            ]
                                          },
                                          "googleDisplayPath2": {
                                            "anyOf": [
                                              {
                                                "type": "string"
                                              },
                                              {
                                                "type": "null"
                                              }
                                            ]
                                          },
                                          "googleHeadlines": {
                                            "anyOf": [
                                              {
                                                "type": "array",
                                                "items": {
                                                  "type": "string"
                                                }
                                              },
                                              {
                                                "type": "null"
                                              }
                                            ]
                                          },
                                          "googleLogoAsset": {
                                            "anyOf": [
                                              {
                                                "additionalProperties": false,
                                                "type": "object",
                                                "properties": {
                                                  "aiGenerated": {
                                                    "anyOf": [
                                                      {
                                                        "type": "boolean"
                                                      },
                                                      {
                                                        "type": "null"
                                                      }
                                                    ]
                                                  },
                                                  "cardDescription": {
                                                    "anyOf": [
                                                      {
                                                        "type": "string"
                                                      },
                                                      {
                                                        "type": "null"
                                                      }
                                                    ]
                                                  },
                                                  "cardHeadline": {
                                                    "anyOf": [
                                                      {
                                                        "type": "string"
                                                      },
                                                      {
                                                        "type": "null"
                                                      }
                                                    ]
                                                  },
                                                  "crops": {
                                                    "anyOf": [
                                                      {
                                                        "additionalProperties": false,
                                                        "type": "object",
                                                        "properties": {
                                                          "100x100": {
                                                            "anyOf": [
                                                              {
                                                                "minItems": 2,
                                                                "maxItems": 2,
                                                                "type": "array",
                                                                "items": {
                                                                  "minItems": 2,
                                                                  "maxItems": 2,
                                                                  "type": "array",
                                                                  "items": {
                                                                    "type": "number"
                                                                  }
                                                                }
                                                              },
                                                              {
                                                                "type": "null"
                                                              }
                                                            ]
                                                          },
                                                          "191x100": {
                                                            "anyOf": [
                                                              {
                                                                "minItems": 2,
                                                                "maxItems": 2,
                                                                "type": "array",
                                                                "items": {
                                                                  "minItems": 2,
                                                                  "maxItems": 2,
                                                                  "type": "array",
                                                                  "items": {
                                                                    "type": "number"
                                                                  }
                                                                }
                                                              },
                                                              {
                                                                "type": "null"
                                                              }
                                                            ]
                                                          },
                                                          "400x500": {
                                                            "anyOf": [
                                                              {
                                                                "minItems": 2,
                                                                "maxItems": 2,
                                                                "type": "array",
                                                                "items": {
                                                                  "minItems": 2,
                                                                  "maxItems": 2,
                                                                  "type": "array",
                                                                  "items": {
                                                                    "type": "number"
                                                                  }
                                                                }
                                                              },
                                                              {
                                                                "type": "null"
                                                              }
                                                            ]
                                                          }
                                                        }
                                                      },
                                                      {
                                                        "type": "null"
                                                      }
                                                    ]
                                                  },
                                                  "duration": {
                                                    "anyOf": [
                                                      {
                                                        "type": "number"
                                                      },
                                                      {
                                                        "type": "null"
                                                      }
                                                    ]
                                                  },
                                                  "fileSizeBytes": {
                                                    "anyOf": [
                                                      {
                                                        "type": "number"
                                                      },
                                                      {
                                                        "type": "null"
                                                      }
                                                    ]
                                                  },
                                                  "height": {
                                                    "anyOf": [
                                                      {
                                                        "type": "number"
                                                      },
                                                      {
                                                        "type": "null"
                                                      }
                                                    ]
                                                  },
                                                  "metaHash": {
                                                    "anyOf": [
                                                      {
                                                        "type": "string"
                                                      },
                                                      {
                                                        "type": "null"
                                                      }
                                                    ]
                                                  },
                                                  "metaVideoId": {
                                                    "anyOf": [
                                                      {
                                                        "type": "string"
                                                      },
                                                      {
                                                        "type": "null"
                                                      }
                                                    ]
                                                  },
                                                  "snapchatMediaId": {
                                                    "anyOf": [
                                                      {
                                                        "type": "string"
                                                      },
                                                      {
                                                        "type": "null"
                                                      }
                                                    ]
                                                  },
                                                  "sourceUrl": {
                                                    "anyOf": [
                                                      {
                                                        "type": "string"
                                                      },
                                                      {
                                                        "type": "null"
                                                      }
                                                    ]
                                                  },
                                                  "thumbnailUrl": {
                                                    "anyOf": [
                                                      {
                                                        "type": "string"
                                                      },
                                                      {
                                                        "type": "null"
                                                      }
                                                    ]
                                                  },
                                                  "tiktokVideoId": {
                                                    "anyOf": [
                                                      {
                                                        "type": "string"
                                                      },
                                                      {
                                                        "type": "null"
                                                      }
                                                    ]
                                                  },
                                                  "type": {
                                                    "anyOf": [
                                                      {
                                                        "anyOf": [
                                                          {
                                                            "type": "string",
                                                            "enum": [
                                                              "image"
                                                            ]
                                                          },
                                                          {
                                                            "type": "string",
                                                            "enum": [
                                                              "video"
                                                            ]
                                                          }
                                                        ]
                                                      },
                                                      {
                                                        "type": "null"
                                                      }
                                                    ]
                                                  },
                                                  "videoId": {
                                                    "anyOf": [
                                                      {
                                                        "type": "string"
                                                      },
                                                      {
                                                        "type": "null"
                                                      }
                                                    ]
                                                  },
                                                  "width": {
                                                    "anyOf": [
                                                      {
                                                        "type": "number"
                                                      },
                                                      {
                                                        "type": "null"
                                                      }
                                                    ]
                                                  }
                                                }
                                              },
                                              {
                                                "type": "null"
                                              }
                                            ]
                                          },
                                          "googleYoutubeUrl": {
                                            "anyOf": [
                                              {
                                                "type": "string"
                                              },
                                              {
                                                "type": "null"
                                              }
                                            ]
                                          },
                                          "headline": {
                                            "anyOf": [
                                              {
                                                "type": "string"
                                              },
                                              {
                                                "type": "null"
                                              }
                                            ]
                                          },
                                          "headlineVariations": {
                                            "anyOf": [
                                              {
                                                "type": "array",
                                                "items": {
                                                  "type": "string"
                                                }
                                              },
                                              {
                                                "type": "null"
                                              }
                                            ]
                                          },
                                          "id": {
                                            "anyOf": [
                                              {
                                                "type": "string"
                                              },
                                              {
                                                "type": "null"
                                              }
                                            ]
                                          },
                                          "media": {
                                            "anyOf": [
                                              {
                                                "type": "array",
                                                "items": {
                                                  "additionalProperties": false,
                                                  "type": "object",
                                                  "properties": {
                                                    "aiGenerated": {
                                                      "anyOf": [
                                                        {
                                                          "type": "boolean"
                                                        },
                                                        {
                                                          "type": "null"
                                                        }
                                                      ]
                                                    },
                                                    "cardDescription": {
                                                      "anyOf": [
                                                        {
                                                          "type": "string"
                                                        },
                                                        {
                                                          "type": "null"
                                                        }
                                                      ]
                                                    },
                                                    "cardHeadline": {
                                                      "anyOf": [
                                                        {
                                                          "type": "string"
                                                        },
                                                        {
                                                          "type": "null"
                                                        }
                                                      ]
                                                    },
                                                    "crops": {
                                                      "anyOf": [
                                                        {
                                                          "additionalProperties": false,
                                                          "type": "object",
                                                          "properties": {
                                                            "100x100": {
                                                              "anyOf": [
                                                                {
                                                                  "minItems": 2,
                                                                  "maxItems": 2,
                                                                  "type": "array",
                                                                  "items": {
                                                                    "minItems": 2,
                                                                    "maxItems": 2,
                                                                    "type": "array",
                                                                    "items": {
                                                                      "type": "number"
                                                                    }
                                                                  }
                                                                },
                                                                {
                                                                  "type": "null"
                                                                }
                                                              ]
                                                            },
                                                            "191x100": {
                                                              "anyOf": [
                                                                {
                                                                  "minItems": 2,
                                                                  "maxItems": 2,
                                                                  "type": "array",
                                                                  "items": {
                                                                    "minItems": 2,
                                                                    "maxItems": 2,
                                                                    "type": "array",
                                                                    "items": {
                                                                      "type": "number"
                                                                    }
                                                                  }
                                                                },
                                                                {
                                                                  "type": "null"
                                                                }
                                                              ]
                                                            },
                                                            "400x500": {
                                                              "anyOf": [
                                                                {
                                                                  "minItems": 2,
                                                                  "maxItems": 2,
                                                                  "type": "array",
                                                                  "items": {
                                                                    "minItems": 2,
                                                                    "maxItems": 2,
                                                                    "type": "array",
                                                                    "items": {
                                                                      "type": "number"
                                                                    }
                                                                  }
                                                                },
                                                                {
                                                                  "type": "null"
                                                                }
                                                              ]
                                                            }
                                                          }
                                                        },
                                                        {
                                                          "type": "null"
                                                        }
                                                      ]
                                                    },
                                                    "duration": {
                                                      "anyOf": [
                                                        {
                                                          "type": "number"
                                                        },
                                                        {
                                                          "type": "null"
                                                        }
                                                      ]
                                                    },
                                                    "fileSizeBytes": {
                                                      "anyOf": [
                                                        {
                                                          "type": "number"
                                                        },
                                                        {
                                                          "type": "null"
                                                        }
                                                      ]
                                                    },
                                                    "height": {
                                                      "anyOf": [
                                                        {
                                                          "type": "number"
                                                        },
                                                        {
                                                          "type": "null"
                                                        }
                                                      ]
                                                    },
                                                    "metaHash": {
                                                      "anyOf": [
                                                        {
                                                          "type": "string"
                                                        },
                                                        {
                                                          "type": "null"
                                                        }
                                                      ]
                                                    },
                                                    "metaVideoId": {
                                                      "anyOf": [
                                                        {
                                                          "type": "string"
                                                        },
                                                        {
                                                          "type": "null"
                                                        }
                                                      ]
                                                    },
                                                    "snapchatMediaId": {
                                                      "anyOf": [
                                                        {
                                                          "type": "string"
                                                        },
                                                        {
                                                          "type": "null"
                                                        }
                                                      ]
                                                    },
                                                    "sourceUrl": {
                                                      "anyOf": [
                                                        {
                                                          "type": "string"
                                                        },
                                                        {
                                                          "type": "null"
                                                        }
                                                      ]
                                                    },
                                                    "thumbnailUrl": {
                                                      "anyOf": [
                                                        {
                                                          "type": "string"
                                                        },
                                                        {
                                                          "type": "null"
                                                        }
                                                      ]
                                                    },
                                                    "tiktokVideoId": {
                                                      "anyOf": [
                                                        {
                                                          "type": "string"
                                                        },
                                                        {
                                                          "type": "null"
                                                        }
                                                      ]
                                                    },
                                                    "type": {
                                                      "anyOf": [
                                                        {
                                                          "anyOf": [
                                                            {
                                                              "type": "string",
                                                              "enum": [
                                                                "image"
                                                              ]
                                                            },
                                                            {
                                                              "type": "string",
                                                              "enum": [
                                                                "video"
                                                              ]
                                                            }
                                                          ]
                                                        },
                                                        {
                                                          "type": "null"
                                                        }
                                                      ]
                                                    },
                                                    "videoId": {
                                                      "anyOf": [
                                                        {
                                                          "type": "string"
                                                        },
                                                        {
                                                          "type": "null"
                                                        }
                                                      ]
                                                    },
                                                    "width": {
                                                      "anyOf": [
                                                        {
                                                          "type": "number"
                                                        },
                                                        {
                                                          "type": "null"
                                                        }
                                                      ]
                                                    }
                                                  }
                                                }
                                              },
                                              {
                                                "type": "null"
                                              }
                                            ]
                                          },
                                          "multiAdvertiser": {
                                            "anyOf": [
                                              {
                                                "type": "boolean"
                                              },
                                              {
                                                "type": "null"
                                              }
                                            ]
                                          },
                                          "multilanguage": {
                                            "anyOf": [
                                              {
                                                "type": "boolean"
                                              },
                                              {
                                                "type": "null"
                                              }
                                            ]
                                          },
                                          "name": {
                                            "anyOf": [
                                              {
                                                "type": "string"
                                              },
                                              {
                                                "type": "null"
                                              }
                                            ]
                                          },
                                          "pageId": {
                                            "anyOf": [
                                              {
                                                "type": "string"
                                              },
                                              {
                                                "type": "null"
                                              }
                                            ]
                                          },
                                          "placementAssets": {
                                            "anyOf": [
                                              {
                                                "additionalProperties": false,
                                                "type": "object",
                                                "properties": {
                                                  "feed": {
                                                    "anyOf": [
                                                      {
                                                        "additionalProperties": false,
                                                        "type": "object",
                                                        "properties": {
                                                          "aiGenerated": {
                                                            "anyOf": [
                                                              {
                                                                "type": "boolean"
                                                              },
                                                              {
                                                                "type": "null"
                                                              }
                                                            ]
                                                          },
                                                          "cardDescription": {
                                                            "anyOf": [
                                                              {
                                                                "type": "string"
                                                              },
                                                              {
                                                                "type": "null"
                                                              }
                                                            ]
                                                          },
                                                          "cardHeadline": {
                                                            "anyOf": [
                                                              {
                                                                "type": "string"
                                                              },
                                                              {
                                                                "type": "null"
                                                              }
                                                            ]
                                                          },
                                                          "crops": {
                                                            "anyOf": [
                                                              {
                                                                "additionalProperties": false,
                                                                "type": "object",
                                                                "properties": {
                                                                  "100x100": {
                                                                    "anyOf": [
                                                                      {
                                                                        "minItems": 2,
                                                                        "maxItems": 2,
                                                                        "type": "array",
                                                                        "items": {
                                                                          "minItems": 2,
                                                                          "maxItems": 2,
                                                                          "type": "array",
                                                                          "items": {
                                                                            "type": "number"
                                                                          }
                                                                        }
                                                                      },
                                                                      {
                                                                        "type": "null"
                                                                      }
                                                                    ]
                                                                  },
                                                                  "191x100": {
                                                                    "anyOf": [
                                                                      {
                                                                        "minItems": 2,
                                                                        "maxItems": 2,
                                                                        "type": "array",
                                                                        "items": {
                                                                          "minItems": 2,
                                                                          "maxItems": 2,
                                                                          "type": "array",
                                                                          "items": {
                                                                            "type": "number"
                                                                          }
                                                                        }
                                                                      },
                                                                      {
                                                                        "type": "null"
                                                                      }
                                                                    ]
                                                                  },
                                                                  "400x500": {
                                                                    "anyOf": [
                                                                      {
                                                                        "minItems": 2,
                                                                        "maxItems": 2,
                                                                        "type": "array",
                                                                        "items": {
                                                                          "minItems": 2,
                                                                          "maxItems": 2,
                                                                          "type": "array",
                                                                          "items": {
                                                                            "type": "number"
                                                                          }
                                                                        }
                                                                      },
                                                                      {
                                                                        "type": "null"
                                                                      }
                                                                    ]
                                                                  }
                                                                }
                                                              },
                                                              {
                                                                "type": "null"
                                                              }
                                                            ]
                                                          },
                                                          "duration": {
                                                            "anyOf": [
                                                              {
                                                                "type": "number"
                                                              },
                                                              {
                                                                "type": "null"
                                                              }
                                                            ]
                                                          },
                                                          "fileSizeBytes": {
                                                            "anyOf": [
                                                              {
                                                                "type": "number"
                                                              },
                                                              {
                                                                "type": "null"
                                                              }
                                                            ]
                                                          },
                                                          "height": {
                                                            "anyOf": [
                                                              {
                                                                "type": "number"
                                                              },
                                                              {
                                                                "type": "null"
                                                              }
                                                            ]
                                                          },
                                                          "metaHash": {
                                                            "anyOf": [
                                                              {
                                                                "type": "string"
                                                              },
                                                              {
                                                                "type": "null"
                                                              }
                                                            ]
                                                          },
                                                          "metaVideoId": {
                                                            "anyOf": [
                                                              {
                                                                "type": "string"
                                                              },
                                                              {
                                                                "type": "null"
                                                              }
                                                            ]
                                                          },
                                                          "snapchatMediaId": {
                                                            "anyOf": [
                                                              {
                                                                "type": "string"
                                                              },
                                                              {
                                                                "type": "null"
                                                              }
                                                            ]
                                                          },
                                                          "sourceUrl": {
                                                            "anyOf": [
                                                              {
                                                                "type": "string"
                                                              },
                                                              {
                                                                "type": "null"
                                                              }
                                                            ]
                                                          },
                                                          "thumbnailUrl": {
                                                            "anyOf": [
                                                              {
                                                                "type": "string"
                                                              },
                                                              {
                                                                "type": "null"
                                                              }
                                                            ]
                                                          },
                                                          "tiktokVideoId": {
                                                            "anyOf": [
                                                              {
                                                                "type": "string"
                                                              },
                                                              {
                                                                "type": "null"
                                                              }
                                                            ]
                                                          },
                                                          "type": {
                                                            "anyOf": [
                                                              {
                                                                "anyOf": [
                                                                  {
                                                                    "type": "string",
                                                                    "enum": [
                                                                      "image"
                                                                    ]
                                                                  },
                                                                  {
                                                                    "type": "string",
                                                                    "enum": [
                                                                      "video"
                                                                    ]
                                                                  }
                                                                ]
                                                              },
                                                              {
                                                                "type": "null"
                                                              }
                                                            ]
                                                          },
                                                          "videoId": {
                                                            "anyOf": [
                                                              {
                                                                "type": "string"
                                                              },
                                                              {
                                                                "type": "null"
                                                              }
                                                            ]
                                                          },
                                                          "width": {
                                                            "anyOf": [
                                                              {
                                                                "type": "number"
                                                              },
                                                              {
                                                                "type": "null"
                                                              }
                                                            ]
                                                          }
                                                        }
                                                      },
                                                      {
                                                        "type": "null"
                                                      }
                                                    ]
                                                  },
                                                  "story": {
                                                    "anyOf": [
                                                      {
                                                        "additionalProperties": false,
                                                        "type": "object",
                                                        "properties": {
                                                          "aiGenerated": {
                                                            "anyOf": [
                                                              {
                                                                "type": "boolean"
                                                              },
                                                              {
                                                                "type": "null"
                                                              }
                                                            ]
                                                          },
                                                          "cardDescription": {
                                                            "anyOf": [
                                                              {
                                                                "type": "string"
                                                              },
                                                              {
                                                                "type": "null"
                                                              }
                                                            ]
                                                          },
                                                          "cardHeadline": {
                                                            "anyOf": [
                                                              {
                                                                "type": "string"
                                                              },
                                                              {
                                                                "type": "null"
                                                              }
                                                            ]
                                                          },
                                                          "crops": {
                                                            "anyOf": [
                                                              {
                                                                "additionalProperties": false,
                                                                "type": "object",
                                                                "properties": {
                                                                  "100x100": {
                                                                    "anyOf": [
                                                                      {
                                                                        "minItems": 2,
                                                                        "maxItems": 2,
                                                                        "type": "array",
                                                                        "items": {
                                                                          "minItems": 2,
                                                                          "maxItems": 2,
                                                                          "type": "array",
                                                                          "items": {
                                                                            "type": "number"
                                                                          }
                                                                        }
                                                                      },
                                                                      {
                                                                        "type": "null"
                                                                      }
                                                                    ]
                                                                  },
                                                                  "191x100": {
                                                                    "anyOf": [
                                                                      {
                                                                        "minItems": 2,
                                                                        "maxItems": 2,
                                                                        "type": "array",
                                                                        "items": {
                                                                          "minItems": 2,
                                                                          "maxItems": 2,
                                                                          "type": "array",
                                                                          "items": {
                                                                            "type": "number"
                                                                          }
                                                                        }
                                                                      },
                                                                      {
                                                                        "type": "null"
                                                                      }
                                                                    ]
                                                                  },
                                                                  "400x500": {
                                                                    "anyOf": [
                                                                      {
                                                                        "minItems": 2,
                                                                        "maxItems": 2,
                                                                        "type": "array",
                                                                        "items": {
                                                                          "minItems": 2,
                                                                          "maxItems": 2,
                                                                          "type": "array",
                                                                          "items": {
                                                                            "type": "number"
                                                                          }
                                                                        }
                                                                      },
                                                                      {
                                                                        "type": "null"
                                                                      }
                                                                    ]
                                                                  }
                                                                }
                                                              },
                                                              {
                                                                "type": "null"
                                                              }
                                                            ]
                                                          },
                                                          "duration": {
                                                            "anyOf": [
                                                              {
                                                                "type": "number"
                                                              },
                                                              {
                                                                "type": "null"
                                                              }
                                                            ]
                                                          },
                                                          "fileSizeBytes": {
                                                            "anyOf": [
                                                              {
                                                                "type": "number"
                                                              },
                                                              {
                                                                "type": "null"
                                                              }
                                                            ]
                                                          },
                                                          "height": {
                                                            "anyOf": [
                                                              {
                                                                "type": "number"
                                                              },
                                                              {
                                                                "type": "null"
                                                              }
                                                            ]
                                                          },
                                                          "metaHash": {
                                                            "anyOf": [
                                                              {
                                                                "type": "string"
                                                              },
                                                              {
                                                                "type": "null"
                                                              }
                                                            ]
                                                          },
                                                          "metaVideoId": {
                                                            "anyOf": [
                                                              {
                                                                "type": "string"
                                                              },
                                                              {
                                                                "type": "null"
                                                              }
                                                            ]
                                                          },
                                                          "snapchatMediaId": {
                                                            "anyOf": [
                                                              {
                                                                "type": "string"
                                                              },
                                                              {
                                                                "type": "null"
                                                              }
                                                            ]
                                                          },
                                                          "sourceUrl": {
                                                            "anyOf": [
                                                              {
                                                                "type": "string"
                                                              },
                                                              {
                                                                "type": "null"
                                                              }
                                                            ]
                                                          },
                                                          "thumbnailUrl": {
                                                            "anyOf": [
                                                              {
                                                                "type": "string"
                                                              },
                                                              {
                                                                "type": "null"
                                                              }
                                                            ]
                                                          },
                                                          "tiktokVideoId": {
                                                            "anyOf": [
                                                              {
                                                                "type": "string"
                                                              },
                                                              {
                                                                "type": "null"
                                                              }
                                                            ]
                                                          },
                                                          "type": {
                                                            "anyOf": [
                                                              {
                                                                "anyOf": [
                                                                  {
                                                                    "type": "string",
                                                                    "enum": [
                                                                      "image"
                                                                    ]
                                                                  },
                                                                  {
                                                                    "type": "string",
                                                                    "enum": [
                                                                      "video"
                                                                    ]
                                                                  }
                                                                ]
                                                              },
                                                              {
                                                                "type": "null"
                                                              }
                                                            ]
                                                          },
                                                          "videoId": {
                                                            "anyOf": [
                                                              {
                                                                "type": "string"
                                                              },
                                                              {
                                                                "type": "null"
                                                              }
                                                            ]
                                                          },
                                                          "width": {
                                                            "anyOf": [
                                                              {
                                                                "type": "number"
                                                              },
                                                              {
                                                                "type": "null"
                                                              }
                                                            ]
                                                          }
                                                        }
                                                      },
                                                      {
                                                        "type": "null"
                                                      }
                                                    ]
                                                  }
                                                }
                                              },
                                              {
                                                "type": "null"
                                              }
                                            ]
                                          },
                                          "placementCustomization": {
                                            "anyOf": [
                                              {
                                                "type": "boolean"
                                              },
                                              {
                                                "type": "null"
                                              }
                                            ]
                                          },
                                          "platformId": {
                                            "anyOf": [
                                              {
                                                "type": "string"
                                              },
                                              {
                                                "type": "null"
                                              }
                                            ]
                                          },
                                          "primaryText": {
                                            "anyOf": [
                                              {
                                                "type": "string"
                                              },
                                              {
                                                "type": "null"
                                              }
                                            ]
                                          },
                                          "primaryTextVariations": {
                                            "anyOf": [
                                              {
                                                "type": "array",
                                                "items": {
                                                  "type": "string"
                                                }
                                              },
                                              {
                                                "type": "null"
                                              }
                                            ]
                                          },
                                          "secondaryDescription": {
                                            "anyOf": [
                                              {
                                                "type": "string"
                                              },
                                              {
                                                "type": "null"
                                              }
                                            ]
                                          },
                                          "secondaryHeadline": {
                                            "anyOf": [
                                              {
                                                "type": "string"
                                              },
                                              {
                                                "type": "null"
                                              }
                                            ]
                                          },
                                          "secondaryLanguages": {
                                            "anyOf": [
                                              {
                                                "type": "array",
                                                "items": {
                                                  "type": "string"
                                                }
                                              },
                                              {
                                                "type": "null"
                                              }
                                            ]
                                          },
                                          "secondaryMedia": {
                                            "anyOf": [
                                              {
                                                "type": "array",
                                                "items": {
                                                  "additionalProperties": false,
                                                  "type": "object",
                                                  "properties": {
                                                    "aiGenerated": {
                                                      "anyOf": [
                                                        {
                                                          "type": "boolean"
                                                        },
                                                        {
                                                          "type": "null"
                                                        }
                                                      ]
                                                    },
                                                    "cardDescription": {
                                                      "anyOf": [
                                                        {
                                                          "type": "string"
                                                        },
                                                        {
                                                          "type": "null"
                                                        }
                                                      ]
                                                    },
                                                    "cardHeadline": {
                                                      "anyOf": [
                                                        {
                                                          "type": "string"
                                                        },
                                                        {
                                                          "type": "null"
                                                        }
                                                      ]
                                                    },
                                                    "crops": {
                                                      "anyOf": [
                                                        {
                                                          "additionalProperties": false,
                                                          "type": "object",
                                                          "properties": {
                                                            "100x100": {
                                                              "anyOf": [
                                                                {
                                                                  "minItems": 2,
                                                                  "maxItems": 2,
                                                                  "type": "array",
                                                                  "items": {
                                                                    "minItems": 2,
                                                                    "maxItems": 2,
                                                                    "type": "array",
                                                                    "items": {
                                                                      "type": "number"
                                                                    }
                                                                  }
                                                                },
                                                                {
                                                                  "type": "null"
                                                                }
                                                              ]
                                                            },
                                                            "191x100": {
                                                              "anyOf": [
                                                                {
                                                                  "minItems": 2,
                                                                  "maxItems": 2,
                                                                  "type": "array",
                                                                  "items": {
                                                                    "minItems": 2,
                                                                    "maxItems": 2,
                                                                    "type": "array",
                                                                    "items": {
                                                                      "type": "number"
                                                                    }
                                                                  }
                                                                },
                                                                {
                                                                  "type": "null"
                                                                }
                                                              ]
                                                            },
                                                            "400x500": {
                                                              "anyOf": [
                                                                {
                                                                  "minItems": 2,
                                                                  "maxItems": 2,
                                                                  "type": "array",
                                                                  "items": {
                                                                    "minItems": 2,
                                                                    "maxItems": 2,
                                                                    "type": "array",
                                                                    "items": {
                                                                      "type": "number"
                                                                    }
                                                                  }
                                                                },
                                                                {
                                                                  "type": "null"
                                                                }
                                                              ]
                                                            }
                                                          }
                                                        },
                                                        {
                                                          "type": "null"
                                                        }
                                                      ]
                                                    },
                                                    "duration": {
                                                      "anyOf": [
                                                        {
                                                          "type": "number"
                                                        },
                                                        {
                                                          "type": "null"
                                                        }
                                                      ]
                                                    },
                                                    "fileSizeBytes": {
                                                      "anyOf": [
                                                        {
                                                          "type": "number"
                                                        },
                                                        {
                                                          "type": "null"
                                                        }
                                                      ]
                                                    },
                                                    "height": {
                                                      "anyOf": [
                                                        {
                                                          "type": "number"
                                                        },
                                                        {
                                                          "type": "null"
                                                        }
                                                      ]
                                                    },
                                                    "metaHash": {
                                                      "anyOf": [
                                                        {
                                                          "type": "string"
                                                        },
                                                        {
                                                          "type": "null"
                                                        }
                                                      ]
                                                    },
                                                    "metaVideoId": {
                                                      "anyOf": [
                                                        {
                                                          "type": "string"
                                                        },
                                                        {
                                                          "type": "null"
                                                        }
                                                      ]
                                                    },
                                                    "snapchatMediaId": {
                                                      "anyOf": [
                                                        {
                                                          "type": "string"
                                                        },
                                                        {
                                                          "type": "null"
                                                        }
                                                      ]
                                                    },
                                                    "sourceUrl": {
                                                      "anyOf": [
                                                        {
                                                          "type": "string"
                                                        },
                                                        {
                                                          "type": "null"
                                                        }
                                                      ]
                                                    },
                                                    "thumbnailUrl": {
                                                      "anyOf": [
                                                        {
                                                          "type": "string"
                                                        },
                                                        {
                                                          "type": "null"
                                                        }
                                                      ]
                                                    },
                                                    "tiktokVideoId": {
                                                      "anyOf": [
                                                        {
                                                          "type": "string"
                                                        },
                                                        {
                                                          "type": "null"
                                                        }
                                                      ]
                                                    },
                                                    "type": {
                                                      "anyOf": [
                                                        {
                                                          "anyOf": [
                                                            {
                                                              "type": "string",
                                                              "enum": [
                                                                "image"
                                                              ]
                                                            },
                                                            {
                                                              "type": "string",
                                                              "enum": [
                                                                "video"
                                                              ]
                                                            }
                                                          ]
                                                        },
                                                        {
                                                          "type": "null"
                                                        }
                                                      ]
                                                    },
                                                    "videoId": {
                                                      "anyOf": [
                                                        {
                                                          "type": "string"
                                                        },
                                                        {
                                                          "type": "null"
                                                        }
                                                      ]
                                                    },
                                                    "width": {
                                                      "anyOf": [
                                                        {
                                                          "type": "number"
                                                        },
                                                        {
                                                          "type": "null"
                                                        }
                                                      ]
                                                    }
                                                  }
                                                }
                                              },
                                              {
                                                "type": "null"
                                              }
                                            ]
                                          },
                                          "secondaryPrimaryText": {
                                            "anyOf": [
                                              {
                                                "type": "string"
                                              },
                                              {
                                                "type": "null"
                                              }
                                            ]
                                          },
                                          "secondaryUrl": {
                                            "anyOf": [
                                              {
                                                "type": "string"
                                              },
                                              {
                                                "type": "null"
                                              }
                                            ]
                                          },
                                          "snapchatAdDisclaimer": {
                                            "anyOf": [
                                              {
                                                "type": "string"
                                              },
                                              {
                                                "type": "null"
                                              }
                                            ]
                                          },
                                          "snapchatAdFavoriting": {
                                            "anyOf": [
                                              {
                                                "type": "boolean"
                                              },
                                              {
                                                "type": "null"
                                              }
                                            ]
                                          },
                                          "snapchatAdType": {
                                            "anyOf": [
                                              {
                                                "type": "string"
                                              },
                                              {
                                                "type": "null"
                                              }
                                            ]
                                          },
                                          "snapchatAppIconMediaId": {
                                            "anyOf": [
                                              {
                                                "type": "string"
                                              },
                                              {
                                                "type": "null"
                                              }
                                            ]
                                          },
                                          "snapchatBrandName": {
                                            "anyOf": [
                                              {
                                                "type": "string"
                                              },
                                              {
                                                "type": "null"
                                              }
                                            ]
                                          },
                                          "snapchatDeepLinkUri": {
                                            "anyOf": [
                                              {
                                                "type": "string"
                                              },
                                              {
                                                "type": "null"
                                              }
                                            ]
                                          },
                                          "snapchatMessageText": {
                                            "anyOf": [
                                              {
                                                "type": "string"
                                              },
                                              {
                                                "type": "null"
                                              }
                                            ]
                                          },
                                          "snapchatPhoneNumberId": {
                                            "anyOf": [
                                              {
                                                "type": "string"
                                              },
                                              {
                                                "type": "null"
                                              }
                                            ]
                                          },
                                          "snapchatShareable": {
                                            "anyOf": [
                                              {
                                                "type": "boolean"
                                              },
                                              {
                                                "type": "null"
                                              }
                                            ]
                                          },
                                          "snapchatSmartPrefetching": {
                                            "anyOf": [
                                              {
                                                "type": "boolean"
                                              },
                                              {
                                                "type": "null"
                                              }
                                            ]
                                          },
                                          "status": {
                                            "anyOf": [
                                              {
                                                "anyOf": [
                                                  {
                                                    "type": "string",
                                                    "enum": [
                                                      "ACTIVE"
                                                    ]
                                                  },
                                                  {
                                                    "type": "string",
                                                    "enum": [
                                                      "PAUSED"
                                                    ]
                                                  }
                                                ]
                                              },
                                              {
                                                "type": "null"
                                              }
                                            ]
                                          },
                                          "taboolaCta": {
                                            "anyOf": [
                                              {
                                                "type": "string"
                                              },
                                              {
                                                "type": "null"
                                              }
                                            ]
                                          },
                                          "taboolaHeadlines": {
                                            "anyOf": [
                                              {
                                                "type": "array",
                                                "items": {
                                                  "type": "string"
                                                }
                                              },
                                              {
                                                "type": "null"
                                              }
                                            ]
                                          },
                                          "targetLanguage": {
                                            "anyOf": [
                                              {
                                                "type": "string"
                                              },
                                              {
                                                "type": "null"
                                              }
                                            ]
                                          },
                                          "unmatchedAudienceVideo": {
                                            "anyOf": [
                                              {
                                                "anyOf": [
                                                  {
                                                    "type": "string",
                                                    "enum": [
                                                      "safe"
                                                    ]
                                                  },
                                                  {
                                                    "type": "string",
                                                    "enum": [
                                                      "targeted"
                                                    ]
                                                  }
                                                ]
                                              },
                                              {
                                                "type": "null"
                                              }
                                            ]
                                          },
                                          "url": {
                                            "anyOf": [
                                              {
                                                "type": "string"
                                              },
                                              {
                                                "type": "null"
                                              }
                                            ]
                                          },
                                          "urlParameters": {
                                            "anyOf": [
                                              {
                                                "type": "string"
                                              },
                                              {
                                                "type": "null"
                                              }
                                            ]
                                          }
                                        }
                                      }
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "attribution": {
                                  "anyOf": [
                                    {
                                      "additionalProperties": false,
                                      "type": "object",
                                      "properties": {
                                        "clickWindow": {
                                          "anyOf": [
                                            {
                                              "anyOf": [
                                                {
                                                  "type": "number",
                                                  "enum": [
                                                    1
                                                  ]
                                                },
                                                {
                                                  "type": "number",
                                                  "enum": [
                                                    7
                                                  ]
                                                }
                                              ]
                                            },
                                            {
                                              "type": "null"
                                            }
                                          ]
                                        },
                                        "viewWindow": {
                                          "anyOf": [
                                            {
                                              "anyOf": [
                                                {
                                                  "type": "number",
                                                  "enum": [
                                                    0
                                                  ]
                                                },
                                                {
                                                  "type": "number",
                                                  "enum": [
                                                    1
                                                  ]
                                                }
                                              ]
                                            },
                                            {
                                              "type": "null"
                                            }
                                          ]
                                        }
                                      }
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "bidAmount": {
                                  "anyOf": [
                                    {
                                      "type": "number"
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "billingEvent": {
                                  "anyOf": [
                                    {
                                      "type": "string"
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "budget": {
                                  "anyOf": [
                                    {
                                      "type": "number"
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "budgetType": {
                                  "anyOf": [
                                    {
                                      "anyOf": [
                                        {
                                          "type": "string",
                                          "enum": [
                                            "DAILY"
                                          ]
                                        },
                                        {
                                          "type": "string",
                                          "enum": [
                                            "LIFETIME"
                                          ]
                                        }
                                      ]
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "customAudiences": {
                                  "anyOf": [
                                    {
                                      "type": "array",
                                      "items": {
                                        "type": "string"
                                      }
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "destinationType": {
                                  "anyOf": [
                                    {
                                      "type": "string"
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "dsaFields": {
                                  "anyOf": [
                                    {
                                      "additionalProperties": false,
                                      "type": "object",
                                      "properties": {
                                        "beneficiary": {
                                          "anyOf": [
                                            {
                                              "type": "string"
                                            },
                                            {
                                              "type": "null"
                                            }
                                          ]
                                        },
                                        "payer": {
                                          "anyOf": [
                                            {
                                              "type": "string"
                                            },
                                            {
                                              "type": "null"
                                            }
                                          ]
                                        }
                                      }
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "endDate": {
                                  "anyOf": [
                                    {
                                      "type": "string"
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "endTime": {
                                  "anyOf": [
                                    {
                                      "type": "string"
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "excludedAudiences": {
                                  "anyOf": [
                                    {
                                      "type": "array",
                                      "items": {
                                        "type": "string"
                                      }
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "id": {
                                  "anyOf": [
                                    {
                                      "type": "string"
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "keywords": {
                                  "anyOf": [
                                    {
                                      "type": "string"
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "metaLeadFormId": {
                                  "anyOf": [
                                    {
                                      "type": "string"
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "name": {
                                  "anyOf": [
                                    {
                                      "type": "string"
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "optimizationGoal": {
                                  "anyOf": [
                                    {
                                      "type": "string"
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "placements": {
                                  "anyOf": [
                                    {
                                      "additionalProperties": false,
                                      "type": "object",
                                      "properties": {
                                        "audienceNetworkPositions": {
                                          "anyOf": [
                                            {
                                              "type": "array",
                                              "items": {
                                                "type": "string"
                                              }
                                            },
                                            {
                                              "type": "null"
                                            }
                                          ]
                                        },
                                        "automatic": {
                                          "anyOf": [
                                            {
                                              "type": "boolean"
                                            },
                                            {
                                              "type": "null"
                                            }
                                          ]
                                        },
                                        "facebookPositions": {
                                          "anyOf": [
                                            {
                                              "type": "array",
                                              "items": {
                                                "type": "string"
                                              }
                                            },
                                            {
                                              "type": "null"
                                            }
                                          ]
                                        },
                                        "instagramPositions": {
                                          "anyOf": [
                                            {
                                              "type": "array",
                                              "items": {
                                                "type": "string"
                                              }
                                            },
                                            {
                                              "type": "null"
                                            }
                                          ]
                                        },
                                        "messengerPositions": {
                                          "anyOf": [
                                            {
                                              "type": "array",
                                              "items": {
                                                "type": "string"
                                              }
                                            },
                                            {
                                              "type": "null"
                                            }
                                          ]
                                        },
                                        "publisherPlatforms": {
                                          "anyOf": [
                                            {
                                              "type": "array",
                                              "items": {
                                                "anyOf": [
                                                  {
                                                    "type": "string",
                                                    "enum": [
                                                      "facebook"
                                                    ]
                                                  },
                                                  {
                                                    "type": "string",
                                                    "enum": [
                                                      "instagram"
                                                    ]
                                                  },
                                                  {
                                                    "type": "string",
                                                    "enum": [
                                                      "audience_network"
                                                    ]
                                                  },
                                                  {
                                                    "type": "string",
                                                    "enum": [
                                                      "messenger"
                                                    ]
                                                  },
                                                  {
                                                    "type": "string",
                                                    "enum": [
                                                      "threads"
                                                    ]
                                                  }
                                                ]
                                              }
                                            },
                                            {
                                              "type": "null"
                                            }
                                          ]
                                        },
                                        "snapchatBrandSuitability": {
                                          "anyOf": [
                                            {
                                              "type": "string"
                                            },
                                            {
                                              "type": "null"
                                            }
                                          ]
                                        },
                                        "snapchatConfig": {
                                          "anyOf": [
                                            {
                                              "type": "string"
                                            },
                                            {
                                              "type": "null"
                                            }
                                          ]
                                        },
                                        "snapchatCustomType": {
                                          "anyOf": [
                                            {
                                              "type": "string"
                                            },
                                            {
                                              "type": "null"
                                            }
                                          ]
                                        },
                                        "snapchatPositions": {
                                          "anyOf": [
                                            {
                                              "type": "array",
                                              "items": {
                                                "type": "string"
                                              }
                                            },
                                            {
                                              "type": "null"
                                            }
                                          ]
                                        },
                                        "threadsPositions": {
                                          "anyOf": [
                                            {
                                              "type": "array",
                                              "items": {
                                                "type": "string"
                                              }
                                            },
                                            {
                                              "type": "null"
                                            }
                                          ]
                                        }
                                      }
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "platformId": {
                                  "anyOf": [
                                    {
                                      "type": "string"
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "promotedObject": {
                                  "anyOf": [
                                    {
                                      "additionalProperties": false,
                                      "type": "object",
                                      "properties": {
                                        "appId": {
                                          "anyOf": [
                                            {
                                              "type": "string"
                                            },
                                            {
                                              "type": "null"
                                            }
                                          ]
                                        },
                                        "catalogId": {
                                          "anyOf": [
                                            {
                                              "type": "string"
                                            },
                                            {
                                              "type": "null"
                                            }
                                          ]
                                        },
                                        "customEventType": {
                                          "anyOf": [
                                            {
                                              "type": "string"
                                            },
                                            {
                                              "type": "null"
                                            }
                                          ]
                                        },
                                        "objectStoreUrl": {
                                          "anyOf": [
                                            {
                                              "type": "string"
                                            },
                                            {
                                              "type": "null"
                                            }
                                          ]
                                        },
                                        "pageId": {
                                          "anyOf": [
                                            {
                                              "type": "string"
                                            },
                                            {
                                              "type": "null"
                                            }
                                          ]
                                        },
                                        "pixelId": {
                                          "anyOf": [
                                            {
                                              "type": "string"
                                            },
                                            {
                                              "type": "null"
                                            }
                                          ]
                                        },
                                        "productSetId": {
                                          "anyOf": [
                                            {
                                              "type": "string"
                                            },
                                            {
                                              "type": "null"
                                            }
                                          ]
                                        }
                                      }
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "roasFloor": {
                                  "anyOf": [
                                    {
                                      "type": "number"
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "snapchatAppId": {
                                  "anyOf": [
                                    {
                                      "type": "string"
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "snapchatAudienceType": {
                                  "anyOf": [
                                    {
                                      "anyOf": [
                                        {
                                          "type": "string",
                                          "enum": [
                                            "PROSPECTING"
                                          ]
                                        },
                                        {
                                          "type": "string",
                                          "enum": [
                                            "RETARGETING"
                                          ]
                                        }
                                      ]
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "snapchatCatalogId": {
                                  "anyOf": [
                                    {
                                      "type": "string"
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "snapchatConversionLocation": {
                                  "anyOf": [
                                    {
                                      "type": "string"
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "snapchatLeadFormId": {
                                  "anyOf": [
                                    {
                                      "type": "string"
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "snapchatPixelId": {
                                  "anyOf": [
                                    {
                                      "type": "string"
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "snapchatProductSetId": {
                                  "anyOf": [
                                    {
                                      "type": "string"
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "spendPercent": {
                                  "anyOf": [
                                    {
                                      "minimum": 1,
                                      "maximum": 100,
                                      "type": "number"
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "startDate": {
                                  "anyOf": [
                                    {
                                      "type": "string"
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "startTime": {
                                  "anyOf": [
                                    {
                                      "type": "string"
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "status": {
                                  "anyOf": [
                                    {
                                      "anyOf": [
                                        {
                                          "type": "string",
                                          "enum": [
                                            "ACTIVE"
                                          ]
                                        },
                                        {
                                          "type": "string",
                                          "enum": [
                                            "PAUSED"
                                          ]
                                        }
                                      ]
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "targeting": {
                                  "anyOf": [
                                    {
                                      "additionalProperties": false,
                                      "type": "object",
                                      "properties": {
                                        "advantageAge": {
                                          "anyOf": [
                                            {
                                              "type": "boolean"
                                            },
                                            {
                                              "type": "null"
                                            }
                                          ]
                                        },
                                        "advantageAudience": {
                                          "anyOf": [
                                            {
                                              "type": "boolean"
                                            },
                                            {
                                              "type": "null"
                                            }
                                          ]
                                        },
                                        "advantageDetailedTargeting": {
                                          "anyOf": [
                                            {
                                              "type": "boolean"
                                            },
                                            {
                                              "type": "null"
                                            }
                                          ]
                                        },
                                        "advantageGender": {
                                          "anyOf": [
                                            {
                                              "type": "boolean"
                                            },
                                            {
                                              "type": "null"
                                            }
                                          ]
                                        },
                                        "advantageLookalike": {
                                          "anyOf": [
                                            {
                                              "type": "boolean"
                                            },
                                            {
                                              "type": "null"
                                            }
                                          ]
                                        },
                                        "ageMax": {
                                          "anyOf": [
                                            {
                                              "type": "number"
                                            },
                                            {
                                              "type": "null"
                                            }
                                          ]
                                        },
                                        "ageMin": {
                                          "anyOf": [
                                            {
                                              "type": "number"
                                            },
                                            {
                                              "type": "null"
                                            }
                                          ]
                                        },
                                        "countries": {
                                          "anyOf": [
                                            {
                                              "type": "array",
                                              "items": {
                                                "type": "string"
                                              }
                                            },
                                            {
                                              "type": "null"
                                            }
                                          ]
                                        },
                                        "devicePlatforms": {
                                          "anyOf": [
                                            {
                                              "type": "array",
                                              "items": {
                                                "anyOf": [
                                                  {
                                                    "type": "string",
                                                    "enum": [
                                                      "mobile"
                                                    ]
                                                  },
                                                  {
                                                    "type": "string",
                                                    "enum": [
                                                      "desktop"
                                                    ]
                                                  }
                                                ]
                                              }
                                            },
                                            {
                                              "type": "null"
                                            }
                                          ]
                                        },
                                        "genders": {
                                          "anyOf": [
                                            {
                                              "type": "array",
                                              "items": {
                                                "type": "number"
                                              }
                                            },
                                            {
                                              "type": "null"
                                            }
                                          ]
                                        },
                                        "locales": {
                                          "anyOf": [
                                            {
                                              "type": "array",
                                              "items": {
                                                "type": "number"
                                              }
                                            },
                                            {
                                              "type": "null"
                                            }
                                          ]
                                        },
                                        "locations": {
                                          "anyOf": [
                                            {
                                              "type": "array",
                                              "items": {
                                                "additionalProperties": false,
                                                "type": "object",
                                                "required": [
                                                  "countryCode",
                                                  "key",
                                                  "name",
                                                  "type"
                                                ],
                                                "properties": {
                                                  "countryCode": {
                                                    "type": "string"
                                                  },
                                                  "distanceUnit": {
                                                    "anyOf": [
                                                      {
                                                        "type": "string"
                                                      },
                                                      {
                                                        "type": "null"
                                                      }
                                                    ]
                                                  },
                                                  "key": {
                                                    "type": "string"
                                                  },
                                                  "name": {
                                                    "type": "string"
                                                  },
                                                  "radius": {
                                                    "anyOf": [
                                                      {
                                                        "minimum": 10,
                                                        "maximum": 80,
                                                        "type": "number"
                                                      },
                                                      {
                                                        "type": "null"
                                                      }
                                                    ]
                                                  },
                                                  "region": {
                                                    "anyOf": [
                                                      {
                                                        "type": "string"
                                                      },
                                                      {
                                                        "type": "null"
                                                      }
                                                    ]
                                                  },
                                                  "type": {
                                                    "anyOf": [
                                                      {
                                                        "type": "string",
                                                        "enum": [
                                                          "region"
                                                        ]
                                                      },
                                                      {
                                                        "type": "string",
                                                        "enum": [
                                                          "city"
                                                        ]
                                                      }
                                                    ]
                                                  }
                                                }
                                              }
                                            },
                                            {
                                              "type": "null"
                                            }
                                          ]
                                        },
                                        "operatingSystems": {
                                          "anyOf": [
                                            {
                                              "type": "array",
                                              "items": {
                                                "type": "string"
                                              }
                                            },
                                            {
                                              "type": "null"
                                            }
                                          ]
                                        }
                                      }
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                }
                              }
                            }
                          },
                          {
                            "type": "null"
                          }
                        ]
                      },
                      "campaign": {
                        "anyOf": [
                          {
                            "additionalProperties": false,
                            "type": "object",
                            "properties": {
                              "acceleratedDelivery": {
                                "anyOf": [
                                  {
                                    "type": "boolean"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "advantagePlus": {
                                "anyOf": [
                                  {
                                    "type": "boolean"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "bidStrategy": {
                                "anyOf": [
                                  {
                                    "type": "string"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "budget": {
                                "anyOf": [
                                  {
                                    "type": "number"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "budgetLevel": {
                                "anyOf": [
                                  {
                                    "anyOf": [
                                      {
                                        "type": "string",
                                        "enum": [
                                          "CBO"
                                        ]
                                      },
                                      {
                                        "type": "string",
                                        "enum": [
                                          "ABO"
                                        ]
                                      }
                                    ]
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "budgetType": {
                                "anyOf": [
                                  {
                                    "anyOf": [
                                      {
                                        "type": "string",
                                        "enum": [
                                          "DAILY"
                                        ]
                                      },
                                      {
                                        "type": "string",
                                        "enum": [
                                          "LIFETIME"
                                        ]
                                      }
                                    ]
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "buyingType": {
                                "anyOf": [
                                  {
                                    "anyOf": [
                                      {
                                        "type": "string",
                                        "enum": [
                                          "AUCTION"
                                        ]
                                      },
                                      {
                                        "type": "string",
                                        "enum": [
                                          "RESERVED"
                                        ]
                                      }
                                    ]
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "customerAcquisition": {
                                "anyOf": [
                                  {
                                    "type": "boolean"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "googleGoal": {
                                "anyOf": [
                                  {
                                    "anyOf": [
                                      {
                                        "type": "string",
                                        "enum": [
                                          "SALES"
                                        ]
                                      },
                                      {
                                        "type": "string",
                                        "enum": [
                                          "LEADS"
                                        ]
                                      },
                                      {
                                        "type": "string",
                                        "enum": [
                                          "WEBSITE_TRAFFIC"
                                        ]
                                      },
                                      {
                                        "type": "string",
                                        "enum": [
                                          "APP_PROMOTION"
                                        ]
                                      },
                                      {
                                        "type": "string",
                                        "enum": [
                                          "AWARENESS"
                                        ]
                                      },
                                      {
                                        "type": "string",
                                        "enum": [
                                          "LOCAL_STORE"
                                        ]
                                      },
                                      {
                                        "type": "string",
                                        "enum": [
                                          "NO_GOAL"
                                        ]
                                      }
                                    ]
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "googleMerchantId": {
                                "anyOf": [
                                  {
                                    "type": "string"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "metaLeadFormId": {
                                "anyOf": [
                                  {
                                    "type": "string"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "metaTokenId": {
                                "anyOf": [
                                  {
                                    "type": "string"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "name": {
                                "anyOf": [
                                  {
                                    "type": "string"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "objective": {
                                "anyOf": [
                                  {
                                    "type": "string"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "outbrainBudgetPacing": {
                                "anyOf": [
                                  {
                                    "anyOf": [
                                      {
                                        "type": "string",
                                        "enum": [
                                          "DAILY"
                                        ]
                                      },
                                      {
                                        "type": "string",
                                        "enum": [
                                          "MONTHLY"
                                        ]
                                      },
                                      {
                                        "type": "string",
                                        "enum": [
                                          "ENTIRE"
                                        ]
                                      }
                                    ]
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "outbrainConversionGoalId": {
                                "anyOf": [
                                  {
                                    "type": "string"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "outbrainCpcCents": {
                                "anyOf": [
                                  {
                                    "type": "number"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "outbrainCurrency": {
                                "anyOf": [
                                  {
                                    "type": "string"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "outbrainDailyBudgetCents": {
                                "anyOf": [
                                  {
                                    "type": "number"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "outbrainDayparting": {
                                "anyOf": [
                                  {
                                    "additionalProperties": false,
                                    "type": "object",
                                    "properties": {
                                      "FRIDAY": {
                                        "anyOf": [
                                          {
                                            "type": "array",
                                            "items": {
                                              "minimum": 0,
                                              "maximum": 23,
                                              "type": "integer"
                                            }
                                          },
                                          {
                                            "type": "null"
                                          }
                                        ]
                                      },
                                      "MONDAY": {
                                        "anyOf": [
                                          {
                                            "type": "array",
                                            "items": {
                                              "minimum": 0,
                                              "maximum": 23,
                                              "type": "integer"
                                            }
                                          },
                                          {
                                            "type": "null"
                                          }
                                        ]
                                      },
                                      "SATURDAY": {
                                        "anyOf": [
                                          {
                                            "type": "array",
                                            "items": {
                                              "minimum": 0,
                                              "maximum": 23,
                                              "type": "integer"
                                            }
                                          },
                                          {
                                            "type": "null"
                                          }
                                        ]
                                      },
                                      "SUNDAY": {
                                        "anyOf": [
                                          {
                                            "type": "array",
                                            "items": {
                                              "minimum": 0,
                                              "maximum": 23,
                                              "type": "integer"
                                            }
                                          },
                                          {
                                            "type": "null"
                                          }
                                        ]
                                      },
                                      "THURSDAY": {
                                        "anyOf": [
                                          {
                                            "type": "array",
                                            "items": {
                                              "minimum": 0,
                                              "maximum": 23,
                                              "type": "integer"
                                            }
                                          },
                                          {
                                            "type": "null"
                                          }
                                        ]
                                      },
                                      "TUESDAY": {
                                        "anyOf": [
                                          {
                                            "type": "array",
                                            "items": {
                                              "minimum": 0,
                                              "maximum": 23,
                                              "type": "integer"
                                            }
                                          },
                                          {
                                            "type": "null"
                                          }
                                        ]
                                      },
                                      "WEDNESDAY": {
                                        "anyOf": [
                                          {
                                            "type": "array",
                                            "items": {
                                              "minimum": 0,
                                              "maximum": 23,
                                              "type": "integer"
                                            }
                                          },
                                          {
                                            "type": "null"
                                          }
                                        ]
                                      }
                                    }
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "outbrainEndDate": {
                                "anyOf": [
                                  {
                                    "type": "string"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "outbrainStartDate": {
                                "anyOf": [
                                  {
                                    "type": "string"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "outbrainTargeting": {
                                "anyOf": [
                                  {
                                    "additionalProperties": false,
                                    "type": "object",
                                    "properties": {
                                      "browsers": {
                                        "anyOf": [
                                          {
                                            "type": "array",
                                            "items": {
                                              "type": "string"
                                            }
                                          },
                                          {
                                            "type": "null"
                                          }
                                        ]
                                      },
                                      "countries": {
                                        "anyOf": [
                                          {
                                            "type": "array",
                                            "items": {
                                              "type": "string"
                                            }
                                          },
                                          {
                                            "type": "null"
                                          }
                                        ]
                                      },
                                      "custom_audiences": {
                                        "anyOf": [
                                          {
                                            "type": "array",
                                            "items": {
                                              "type": "string"
                                            }
                                          },
                                          {
                                            "type": "null"
                                          }
                                        ]
                                      },
                                      "iab_categories": {
                                        "anyOf": [
                                          {
                                            "type": "array",
                                            "items": {
                                              "type": "string"
                                            }
                                          },
                                          {
                                            "type": "null"
                                          }
                                        ]
                                      },
                                      "languages": {
                                        "anyOf": [
                                          {
                                            "type": "array",
                                            "items": {
                                              "type": "string"
                                            }
                                          },
                                          {
                                            "type": "null"
                                          }
                                        ]
                                      },
                                      "operating_systems": {
                                        "anyOf": [
                                          {
                                            "type": "array",
                                            "items": {
                                              "type": "string"
                                            }
                                          },
                                          {
                                            "type": "null"
                                          }
                                        ]
                                      },
                                      "platforms": {
                                        "anyOf": [
                                          {
                                            "type": "array",
                                            "items": {
                                              "type": "string"
                                            }
                                          },
                                          {
                                            "type": "null"
                                          }
                                        ]
                                      },
                                      "sections": {
                                        "anyOf": [
                                          {
                                            "additionalProperties": false,
                                            "type": "object",
                                            "properties": {
                                              "exclude": {
                                                "anyOf": [
                                                  {
                                                    "type": "array",
                                                    "items": {
                                                      "type": "string"
                                                    }
                                                  },
                                                  {
                                                    "type": "null"
                                                  }
                                                ]
                                              },
                                              "include": {
                                                "anyOf": [
                                                  {
                                                    "type": "array",
                                                    "items": {
                                                      "type": "string"
                                                    }
                                                  },
                                                  {
                                                    "type": "null"
                                                  }
                                                ]
                                              }
                                            }
                                          },
                                          {
                                            "type": "null"
                                          }
                                        ]
                                      }
                                    }
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "reachGoals": {
                                "anyOf": [
                                  {
                                    "additionalProperties": false,
                                    "type": "object",
                                    "properties": {
                                      "phoneCall": {
                                        "anyOf": [
                                          {
                                            "type": "boolean"
                                          },
                                          {
                                            "type": "null"
                                          }
                                        ]
                                      },
                                      "storeVisit": {
                                        "anyOf": [
                                          {
                                            "type": "boolean"
                                          },
                                          {
                                            "type": "null"
                                          }
                                        ]
                                      },
                                      "websiteVisit": {
                                        "anyOf": [
                                          {
                                            "type": "boolean"
                                          },
                                          {
                                            "type": "null"
                                          }
                                        ]
                                      }
                                    }
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "snapchatDynamicAds": {
                                "anyOf": [
                                  {
                                    "type": "boolean"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "snapchatLifetimeSpendCap": {
                                "anyOf": [
                                  {
                                    "type": "number"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "snapchatMobileApp": {
                                "anyOf": [
                                  {
                                    "additionalProperties": false,
                                    "type": "object",
                                    "properties": {
                                      "android_app_url": {
                                        "anyOf": [
                                          {
                                            "type": "string"
                                          },
                                          {
                                            "type": "null"
                                          }
                                        ]
                                      },
                                      "app_name": {
                                        "anyOf": [
                                          {
                                            "type": "string"
                                          },
                                          {
                                            "type": "null"
                                          }
                                        ]
                                      },
                                      "ios_app_id": {
                                        "anyOf": [
                                          {
                                            "type": "string"
                                          },
                                          {
                                            "type": "null"
                                          }
                                        ]
                                      }
                                    }
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "snapchatPromotionType": {
                                "anyOf": [
                                  {
                                    "anyOf": [
                                      {
                                        "type": "string",
                                        "enum": [
                                          "APP_INSTALL"
                                        ]
                                      },
                                      {
                                        "type": "string",
                                        "enum": [
                                          "APP_REENGAGEMENT"
                                        ]
                                      }
                                    ]
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "snapchatPublicProfileId": {
                                "anyOf": [
                                  {
                                    "type": "string"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "specialAdCategories": {
                                "anyOf": [
                                  {
                                    "type": "array",
                                    "items": {
                                      "anyOf": [
                                        {
                                          "type": "string",
                                          "enum": [
                                            "NONE"
                                          ]
                                        },
                                        {
                                          "type": "string",
                                          "enum": [
                                            "HOUSING"
                                          ]
                                        },
                                        {
                                          "type": "string",
                                          "enum": [
                                            "EMPLOYMENT"
                                          ]
                                        },
                                        {
                                          "type": "string",
                                          "enum": [
                                            "CREDIT"
                                          ]
                                        },
                                        {
                                          "type": "string",
                                          "enum": [
                                            "ISSUES_ELECTIONS_POLITICS"
                                          ]
                                        },
                                        {
                                          "type": "string",
                                          "enum": [
                                            "ONLINE_GAMBLING_AND_GAMING"
                                          ]
                                        }
                                      ]
                                    }
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "status": {
                                "anyOf": [
                                  {
                                    "anyOf": [
                                      {
                                        "type": "string",
                                        "enum": [
                                          "ACTIVE"
                                        ]
                                      },
                                      {
                                        "type": "string",
                                        "enum": [
                                          "PAUSED"
                                        ]
                                      }
                                    ]
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "taboolaBidStrategy": {
                                "anyOf": [
                                  {
                                    "anyOf": [
                                      {
                                        "type": "string",
                                        "enum": [
                                          "FIXED"
                                        ]
                                      },
                                      {
                                        "type": "string",
                                        "enum": [
                                          "TARGET_CPA"
                                        ]
                                      }
                                    ]
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "taboolaBrandingText": {
                                "anyOf": [
                                  {
                                    "type": "string"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "taboolaCpaGoal": {
                                "anyOf": [
                                  {
                                    "type": "number"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "taboolaCpc": {
                                "anyOf": [
                                  {
                                    "type": "number"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "taboolaDailyCap": {
                                "anyOf": [
                                  {
                                    "type": "number"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "taboolaPricingModel": {
                                "anyOf": [
                                  {
                                    "type": "string"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "taboolaSpendingLimit": {
                                "anyOf": [
                                  {
                                    "type": "number"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "taboolaSpendingLimitType": {
                                "anyOf": [
                                  {
                                    "anyOf": [
                                      {
                                        "type": "string",
                                        "enum": [
                                          "MONTHLY"
                                        ]
                                      },
                                      {
                                        "type": "string",
                                        "enum": [
                                          "ENTIRE"
                                        ]
                                      }
                                    ]
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "tiktokAppId": {
                                "anyOf": [
                                  {
                                    "type": "string"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "tiktokBidAmount": {
                                "anyOf": [
                                  {
                                    "type": "number"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "tiktokBidType": {
                                "anyOf": [
                                  {
                                    "anyOf": [
                                      {
                                        "type": "string",
                                        "enum": [
                                          "BID_TYPE_CUSTOM"
                                        ]
                                      },
                                      {
                                        "type": "string",
                                        "enum": [
                                          "BID_TYPE_NO_BID"
                                        ]
                                      }
                                    ]
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "tiktokBillingEvent": {
                                "anyOf": [
                                  {
                                    "anyOf": [
                                      {
                                        "type": "string",
                                        "enum": [
                                          "CPM"
                                        ]
                                      },
                                      {
                                        "type": "string",
                                        "enum": [
                                          "OCPM"
                                        ]
                                      },
                                      {
                                        "type": "string",
                                        "enum": [
                                          "CPC"
                                        ]
                                      },
                                      {
                                        "type": "string",
                                        "enum": [
                                          "CPV"
                                        ]
                                      }
                                    ]
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "tiktokCatalogId": {
                                "anyOf": [
                                  {
                                    "type": "string"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "tiktokIdentityId": {
                                "anyOf": [
                                  {
                                    "type": "string"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "tiktokIdentityType": {
                                "anyOf": [
                                  {
                                    "anyOf": [
                                      {
                                        "type": "string",
                                        "enum": [
                                          "TT_USER"
                                        ]
                                      },
                                      {
                                        "type": "string",
                                        "enum": [
                                          "CUSTOMIZED_USER"
                                        ]
                                      },
                                      {
                                        "type": "string",
                                        "enum": [
                                          "BC_AUTH_TT"
                                        ]
                                      }
                                    ]
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "tiktokItemId": {
                                "anyOf": [
                                  {
                                    "type": "string"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "tiktokLeadFormId": {
                                "anyOf": [
                                  {
                                    "type": "string"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "tiktokOptimizeGoal": {
                                "anyOf": [
                                  {
                                    "type": "string"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "tiktokPixelEvent": {
                                "anyOf": [
                                  {
                                    "type": "string"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "tiktokPixelId": {
                                "anyOf": [
                                  {
                                    "type": "string"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "tiktokRoasBid": {
                                "anyOf": [
                                  {
                                    "type": "number"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              }
                            }
                          },
                          {
                            "type": "null"
                          }
                        ]
                      },
                      "currency": {
                        "anyOf": [
                          {
                            "type": "string"
                          },
                          {
                            "type": "null"
                          }
                        ]
                      },
                      "editWarning": {
                        "anyOf": [
                          {
                            "additionalProperties": false,
                            "type": "object",
                            "properties": {
                              "kind": {
                                "anyOf": [
                                  {
                                    "anyOf": [
                                      {
                                        "type": "string",
                                        "enum": [
                                          "none"
                                        ]
                                      },
                                      {
                                        "type": "string",
                                        "enum": [
                                          "learning_reset"
                                        ]
                                      },
                                      {
                                        "type": "string",
                                        "enum": [
                                          "recreate"
                                        ]
                                      },
                                      {
                                        "type": "string",
                                        "enum": [
                                          "re_review"
                                        ]
                                      },
                                      {
                                        "type": "string",
                                        "enum": [
                                          "id_change"
                                        ]
                                      }
                                    ]
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "reason": {
                                "anyOf": [
                                  {
                                    "type": "string"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              }
                            }
                          },
                          {
                            "type": "null"
                          }
                        ]
                      },
                      "id": {
                        "anyOf": [
                          {
                            "type": "string"
                          },
                          {
                            "type": "null"
                          }
                        ]
                      },
                      "platformId": {
                        "anyOf": [
                          {
                            "type": "string"
                          },
                          {
                            "type": "null"
                          }
                        ]
                      },
                      "publishMode": {
                        "anyOf": [
                          {
                            "anyOf": [
                              {
                                "type": "string",
                                "enum": [
                                  "create_all"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "ads_only"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "add_adset"
                                ]
                              }
                            ]
                          },
                          {
                            "type": "null"
                          }
                        ]
                      },
                      "sessionId": {
                        "anyOf": [
                          {
                            "type": "string"
                          },
                          {
                            "type": "null"
                          }
                        ]
                      }
                    }
                  },
                  "platform": {
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object",
                  "required": [
                    "valid",
                    "errors",
                    "warnings",
                    "info"
                  ],
                  "properties": {
                    "valid": {
                      "type": "boolean"
                    },
                    "errors": {
                      "type": "array",
                      "items": {
                        "additionalProperties": true,
                        "type": "object",
                        "required": [
                          "code",
                          "fieldPath",
                          "message",
                          "severity"
                        ],
                        "properties": {
                          "code": {
                            "description": "Stable error code (e.g. \"INVALID_AGE_RANGE\").",
                            "type": "string"
                          },
                          "fieldPath": {
                            "description": "Dot-notation path of the offending field.",
                            "type": "string"
                          },
                          "message": {
                            "type": "string"
                          },
                          "metaErrorCode": {
                            "type": "number"
                          },
                          "severity": {
                            "anyOf": [
                              {
                                "type": "string",
                                "enum": [
                                  "error"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "warning"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "info"
                                ]
                              }
                            ]
                          }
                        }
                      }
                    },
                    "warnings": {
                      "type": "array",
                      "items": {
                        "additionalProperties": true,
                        "type": "object",
                        "required": [
                          "code",
                          "fieldPath",
                          "message",
                          "severity"
                        ],
                        "properties": {
                          "code": {
                            "description": "Stable error code (e.g. \"INVALID_AGE_RANGE\").",
                            "type": "string"
                          },
                          "fieldPath": {
                            "description": "Dot-notation path of the offending field.",
                            "type": "string"
                          },
                          "message": {
                            "type": "string"
                          },
                          "metaErrorCode": {
                            "type": "number"
                          },
                          "severity": {
                            "anyOf": [
                              {
                                "type": "string",
                                "enum": [
                                  "error"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "warning"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "info"
                                ]
                              }
                            ]
                          }
                        }
                      }
                    },
                    "info": {
                      "type": "array",
                      "items": {
                        "additionalProperties": true,
                        "type": "object",
                        "required": [
                          "code",
                          "fieldPath",
                          "message",
                          "severity"
                        ],
                        "properties": {
                          "code": {
                            "description": "Stable error code (e.g. \"INVALID_AGE_RANGE\").",
                            "type": "string"
                          },
                          "fieldPath": {
                            "description": "Dot-notation path of the offending field.",
                            "type": "string"
                          },
                          "message": {
                            "type": "string"
                          },
                          "metaErrorCode": {
                            "type": "number"
                          },
                          "severity": {
                            "anyOf": [
                              {
                                "type": "string",
                                "enum": [
                                  "error"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "warning"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "info"
                                ]
                              }
                            ]
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "error_code": {
                      "type": "string"
                    },
                    "detail": {}
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/campaign-drafts/{id}/validate-field": {
      "post": {
        "operationId": "validateCampaignDraftField",
        "summary": "Validate a single field in campaign draft",
        "tags": [
          "campaigns"
        ],
        "description": "Validates a specific field path in the campaign draft and returns its validation result.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "field_path"
                ],
                "properties": {
                  "field_path": {
                    "minLength": 1,
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object",
                  "required": [
                    "valid",
                    "errors",
                    "warnings",
                    "info"
                  ],
                  "properties": {
                    "valid": {
                      "type": "boolean"
                    },
                    "errors": {
                      "type": "array",
                      "items": {
                        "additionalProperties": true,
                        "type": "object",
                        "required": [
                          "code",
                          "fieldPath",
                          "message",
                          "severity"
                        ],
                        "properties": {
                          "code": {
                            "description": "Stable error code (e.g. \"INVALID_AGE_RANGE\").",
                            "type": "string"
                          },
                          "fieldPath": {
                            "description": "Dot-notation path of the offending field.",
                            "type": "string"
                          },
                          "message": {
                            "type": "string"
                          },
                          "metaErrorCode": {
                            "type": "number"
                          },
                          "severity": {
                            "anyOf": [
                              {
                                "type": "string",
                                "enum": [
                                  "error"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "warning"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "info"
                                ]
                              }
                            ]
                          }
                        }
                      }
                    },
                    "warnings": {
                      "type": "array",
                      "items": {
                        "additionalProperties": true,
                        "type": "object",
                        "required": [
                          "code",
                          "fieldPath",
                          "message",
                          "severity"
                        ],
                        "properties": {
                          "code": {
                            "description": "Stable error code (e.g. \"INVALID_AGE_RANGE\").",
                            "type": "string"
                          },
                          "fieldPath": {
                            "description": "Dot-notation path of the offending field.",
                            "type": "string"
                          },
                          "message": {
                            "type": "string"
                          },
                          "metaErrorCode": {
                            "type": "number"
                          },
                          "severity": {
                            "anyOf": [
                              {
                                "type": "string",
                                "enum": [
                                  "error"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "warning"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "info"
                                ]
                              }
                            ]
                          }
                        }
                      }
                    },
                    "info": {
                      "type": "array",
                      "items": {
                        "additionalProperties": true,
                        "type": "object",
                        "required": [
                          "code",
                          "fieldPath",
                          "message",
                          "severity"
                        ],
                        "properties": {
                          "code": {
                            "description": "Stable error code (e.g. \"INVALID_AGE_RANGE\").",
                            "type": "string"
                          },
                          "fieldPath": {
                            "description": "Dot-notation path of the offending field.",
                            "type": "string"
                          },
                          "message": {
                            "type": "string"
                          },
                          "metaErrorCode": {
                            "type": "number"
                          },
                          "severity": {
                            "anyOf": [
                              {
                                "type": "string",
                                "enum": [
                                  "error"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "warning"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "info"
                                ]
                              }
                            ]
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "error_code": {
                      "type": "string"
                    },
                    "detail": {}
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/campaign-drafts/{id}/preflight": {
      "post": {
        "operationId": "preflightCampaignDraft",
        "summary": "Pre-flight check: verify account, tokens, and platform resources",
        "tags": [
          "campaigns"
        ],
        "description": "Verifies that the platform account, tokens, and required native resources referenced in the draft are valid and accessible before publishing.",
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object",
                  "required": [
                    "valid",
                    "errors",
                    "warnings",
                    "info"
                  ],
                  "properties": {
                    "valid": {
                      "type": "boolean"
                    },
                    "errors": {
                      "type": "array",
                      "items": {
                        "additionalProperties": true,
                        "type": "object",
                        "required": [
                          "code",
                          "fieldPath",
                          "message",
                          "severity"
                        ],
                        "properties": {
                          "code": {
                            "description": "Stable error code (e.g. \"INVALID_AGE_RANGE\").",
                            "type": "string"
                          },
                          "fieldPath": {
                            "description": "Dot-notation path of the offending field.",
                            "type": "string"
                          },
                          "message": {
                            "type": "string"
                          },
                          "metaErrorCode": {
                            "type": "number"
                          },
                          "severity": {
                            "anyOf": [
                              {
                                "type": "string",
                                "enum": [
                                  "error"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "warning"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "info"
                                ]
                              }
                            ]
                          }
                        }
                      }
                    },
                    "warnings": {
                      "type": "array",
                      "items": {
                        "additionalProperties": true,
                        "type": "object",
                        "required": [
                          "code",
                          "fieldPath",
                          "message",
                          "severity"
                        ],
                        "properties": {
                          "code": {
                            "description": "Stable error code (e.g. \"INVALID_AGE_RANGE\").",
                            "type": "string"
                          },
                          "fieldPath": {
                            "description": "Dot-notation path of the offending field.",
                            "type": "string"
                          },
                          "message": {
                            "type": "string"
                          },
                          "metaErrorCode": {
                            "type": "number"
                          },
                          "severity": {
                            "anyOf": [
                              {
                                "type": "string",
                                "enum": [
                                  "error"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "warning"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "info"
                                ]
                              }
                            ]
                          }
                        }
                      }
                    },
                    "info": {
                      "type": "array",
                      "items": {
                        "additionalProperties": true,
                        "type": "object",
                        "required": [
                          "code",
                          "fieldPath",
                          "message",
                          "severity"
                        ],
                        "properties": {
                          "code": {
                            "description": "Stable error code (e.g. \"INVALID_AGE_RANGE\").",
                            "type": "string"
                          },
                          "fieldPath": {
                            "description": "Dot-notation path of the offending field.",
                            "type": "string"
                          },
                          "message": {
                            "type": "string"
                          },
                          "metaErrorCode": {
                            "type": "number"
                          },
                          "severity": {
                            "anyOf": [
                              {
                                "type": "string",
                                "enum": [
                                  "error"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "warning"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "info"
                                ]
                              }
                            ]
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "error_code": {
                      "type": "string"
                    },
                    "detail": {}
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/campaign-drafts/{id}/dry-run": {
      "post": {
        "operationId": "dryRunCampaignDraft",
        "summary": "Dry run: preview native API payloads",
        "tags": [
          "campaigns"
        ],
        "description": "Generates the native platform API payloads that would be sent on publish, without actually creating anything. Returns validation result and preview payloads.",
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object",
                  "required": [
                    "validation"
                  ],
                  "properties": {
                    "validation": {
                      "additionalProperties": true,
                      "type": "object",
                      "required": [
                        "valid",
                        "errors",
                        "warnings",
                        "info"
                      ],
                      "properties": {
                        "valid": {
                          "type": "boolean"
                        },
                        "errors": {
                          "type": "array",
                          "items": {
                            "additionalProperties": true,
                            "type": "object",
                            "required": [
                              "code",
                              "fieldPath",
                              "message",
                              "severity"
                            ],
                            "properties": {
                              "code": {
                                "description": "Stable error code (e.g. \"INVALID_AGE_RANGE\").",
                                "type": "string"
                              },
                              "fieldPath": {
                                "description": "Dot-notation path of the offending field.",
                                "type": "string"
                              },
                              "message": {
                                "type": "string"
                              },
                              "metaErrorCode": {
                                "type": "number"
                              },
                              "severity": {
                                "anyOf": [
                                  {
                                    "type": "string",
                                    "enum": [
                                      "error"
                                    ]
                                  },
                                  {
                                    "type": "string",
                                    "enum": [
                                      "warning"
                                    ]
                                  },
                                  {
                                    "type": "string",
                                    "enum": [
                                      "info"
                                    ]
                                  }
                                ]
                              }
                            }
                          }
                        },
                        "warnings": {
                          "type": "array",
                          "items": {
                            "additionalProperties": true,
                            "type": "object",
                            "required": [
                              "code",
                              "fieldPath",
                              "message",
                              "severity"
                            ],
                            "properties": {
                              "code": {
                                "description": "Stable error code (e.g. \"INVALID_AGE_RANGE\").",
                                "type": "string"
                              },
                              "fieldPath": {
                                "description": "Dot-notation path of the offending field.",
                                "type": "string"
                              },
                              "message": {
                                "type": "string"
                              },
                              "metaErrorCode": {
                                "type": "number"
                              },
                              "severity": {
                                "anyOf": [
                                  {
                                    "type": "string",
                                    "enum": [
                                      "error"
                                    ]
                                  },
                                  {
                                    "type": "string",
                                    "enum": [
                                      "warning"
                                    ]
                                  },
                                  {
                                    "type": "string",
                                    "enum": [
                                      "info"
                                    ]
                                  }
                                ]
                              }
                            }
                          }
                        },
                        "info": {
                          "type": "array",
                          "items": {
                            "additionalProperties": true,
                            "type": "object",
                            "required": [
                              "code",
                              "fieldPath",
                              "message",
                              "severity"
                            ],
                            "properties": {
                              "code": {
                                "description": "Stable error code (e.g. \"INVALID_AGE_RANGE\").",
                                "type": "string"
                              },
                              "fieldPath": {
                                "description": "Dot-notation path of the offending field.",
                                "type": "string"
                              },
                              "message": {
                                "type": "string"
                              },
                              "metaErrorCode": {
                                "type": "number"
                              },
                              "severity": {
                                "anyOf": [
                                  {
                                    "type": "string",
                                    "enum": [
                                      "error"
                                    ]
                                  },
                                  {
                                    "type": "string",
                                    "enum": [
                                      "warning"
                                    ]
                                  },
                                  {
                                    "type": "string",
                                    "enum": [
                                      "info"
                                    ]
                                  }
                                ]
                              }
                            }
                          }
                        }
                      }
                    },
                    "preview": {
                      "additionalProperties": true,
                      "type": "object",
                      "required": [
                        "campaign",
                        "adSets"
                      ],
                      "properties": {
                        "campaign": {
                          "$comment": "json-value",
                          "description": "Arbitrary JSON value with nested arrays and objects."
                        },
                        "adSets": {
                          "type": "array",
                          "items": {
                            "additionalProperties": true,
                            "type": "object",
                            "required": [
                              "adSet",
                              "ads"
                            ],
                            "properties": {
                              "adSet": {
                                "$comment": "json-value",
                                "description": "Arbitrary JSON value with nested arrays and objects."
                              },
                              "ads": {
                                "type": "array",
                                "items": {
                                  "$comment": "json-value",
                                  "description": "Arbitrary JSON value with nested arrays and objects."
                                }
                              }
                            }
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "422": {
            "description": "Unprocessable entity - semantic validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object",
                  "required": [
                    "validation"
                  ],
                  "properties": {
                    "validation": {
                      "additionalProperties": true,
                      "type": "object",
                      "required": [
                        "valid",
                        "errors",
                        "warnings",
                        "info"
                      ],
                      "properties": {
                        "valid": {
                          "type": "boolean"
                        },
                        "errors": {
                          "type": "array",
                          "items": {
                            "additionalProperties": true,
                            "type": "object",
                            "required": [
                              "code",
                              "fieldPath",
                              "message",
                              "severity"
                            ],
                            "properties": {
                              "code": {
                                "description": "Stable error code (e.g. \"INVALID_AGE_RANGE\").",
                                "type": "string"
                              },
                              "fieldPath": {
                                "description": "Dot-notation path of the offending field.",
                                "type": "string"
                              },
                              "message": {
                                "type": "string"
                              },
                              "metaErrorCode": {
                                "type": "number"
                              },
                              "severity": {
                                "anyOf": [
                                  {
                                    "type": "string",
                                    "enum": [
                                      "error"
                                    ]
                                  },
                                  {
                                    "type": "string",
                                    "enum": [
                                      "warning"
                                    ]
                                  },
                                  {
                                    "type": "string",
                                    "enum": [
                                      "info"
                                    ]
                                  }
                                ]
                              }
                            }
                          }
                        },
                        "warnings": {
                          "type": "array",
                          "items": {
                            "additionalProperties": true,
                            "type": "object",
                            "required": [
                              "code",
                              "fieldPath",
                              "message",
                              "severity"
                            ],
                            "properties": {
                              "code": {
                                "description": "Stable error code (e.g. \"INVALID_AGE_RANGE\").",
                                "type": "string"
                              },
                              "fieldPath": {
                                "description": "Dot-notation path of the offending field.",
                                "type": "string"
                              },
                              "message": {
                                "type": "string"
                              },
                              "metaErrorCode": {
                                "type": "number"
                              },
                              "severity": {
                                "anyOf": [
                                  {
                                    "type": "string",
                                    "enum": [
                                      "error"
                                    ]
                                  },
                                  {
                                    "type": "string",
                                    "enum": [
                                      "warning"
                                    ]
                                  },
                                  {
                                    "type": "string",
                                    "enum": [
                                      "info"
                                    ]
                                  }
                                ]
                              }
                            }
                          }
                        },
                        "info": {
                          "type": "array",
                          "items": {
                            "additionalProperties": true,
                            "type": "object",
                            "required": [
                              "code",
                              "fieldPath",
                              "message",
                              "severity"
                            ],
                            "properties": {
                              "code": {
                                "description": "Stable error code (e.g. \"INVALID_AGE_RANGE\").",
                                "type": "string"
                              },
                              "fieldPath": {
                                "description": "Dot-notation path of the offending field.",
                                "type": "string"
                              },
                              "message": {
                                "type": "string"
                              },
                              "metaErrorCode": {
                                "type": "number"
                              },
                              "severity": {
                                "anyOf": [
                                  {
                                    "type": "string",
                                    "enum": [
                                      "error"
                                    ]
                                  },
                                  {
                                    "type": "string",
                                    "enum": [
                                      "warning"
                                    ]
                                  },
                                  {
                                    "type": "string",
                                    "enum": [
                                      "info"
                                    ]
                                  }
                                ]
                              }
                            }
                          }
                        }
                      }
                    },
                    "preview": {
                      "additionalProperties": true,
                      "type": "object",
                      "required": [
                        "campaign",
                        "adSets"
                      ],
                      "properties": {
                        "campaign": {
                          "$comment": "json-value",
                          "description": "Arbitrary JSON value with nested arrays and objects."
                        },
                        "adSets": {
                          "type": "array",
                          "items": {
                            "additionalProperties": true,
                            "type": "object",
                            "required": [
                              "adSet",
                              "ads"
                            ],
                            "properties": {
                              "adSet": {
                                "$comment": "json-value",
                                "description": "Arbitrary JSON value with nested arrays and objects."
                              },
                              "ads": {
                                "type": "array",
                                "items": {
                                  "$comment": "json-value",
                                  "description": "Arbitrary JSON value with nested arrays and objects."
                                }
                              }
                            }
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "error_code": {
                      "type": "string"
                    },
                    "detail": {}
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/campaign-drafts/{id}/publish": {
      "post": {
        "operationId": "publishCampaignDraft",
        "summary": "Publish campaign draft via native worker",
        "tags": [
          "campaigns"
        ],
        "description": "Publishes the campaign draft to its selected platform by dispatching it to the native publish worker. Requires an active subscription.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "properties": {
                  "idempotency_key": {
                    "maxLength": 255,
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object",
                  "required": [
                    "publishJobId"
                  ],
                  "properties": {
                    "publishJobId": {
                      "type": "string"
                    },
                    "naming_warnings": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "description": "Reason the operation was rejected (e.g. \"Draft not found\", \"Validation failed\", \"Duplicate account_id in targets\").",
                      "type": "string"
                    },
                    "validation": {
                      "additionalProperties": true,
                      "type": "object",
                      "required": [
                        "valid",
                        "errors",
                        "warnings",
                        "info"
                      ],
                      "properties": {
                        "valid": {
                          "type": "boolean"
                        },
                        "errors": {
                          "type": "array",
                          "items": {
                            "additionalProperties": true,
                            "type": "object",
                            "required": [
                              "code",
                              "fieldPath",
                              "message",
                              "severity"
                            ],
                            "properties": {
                              "code": {
                                "description": "Stable error code (e.g. \"INVALID_AGE_RANGE\").",
                                "type": "string"
                              },
                              "fieldPath": {
                                "description": "Dot-notation path of the offending field.",
                                "type": "string"
                              },
                              "message": {
                                "type": "string"
                              },
                              "metaErrorCode": {
                                "type": "number"
                              },
                              "severity": {
                                "anyOf": [
                                  {
                                    "type": "string",
                                    "enum": [
                                      "error"
                                    ]
                                  },
                                  {
                                    "type": "string",
                                    "enum": [
                                      "warning"
                                    ]
                                  },
                                  {
                                    "type": "string",
                                    "enum": [
                                      "info"
                                    ]
                                  }
                                ]
                              }
                            }
                          }
                        },
                        "warnings": {
                          "type": "array",
                          "items": {
                            "additionalProperties": true,
                            "type": "object",
                            "required": [
                              "code",
                              "fieldPath",
                              "message",
                              "severity"
                            ],
                            "properties": {
                              "code": {
                                "description": "Stable error code (e.g. \"INVALID_AGE_RANGE\").",
                                "type": "string"
                              },
                              "fieldPath": {
                                "description": "Dot-notation path of the offending field.",
                                "type": "string"
                              },
                              "message": {
                                "type": "string"
                              },
                              "metaErrorCode": {
                                "type": "number"
                              },
                              "severity": {
                                "anyOf": [
                                  {
                                    "type": "string",
                                    "enum": [
                                      "error"
                                    ]
                                  },
                                  {
                                    "type": "string",
                                    "enum": [
                                      "warning"
                                    ]
                                  },
                                  {
                                    "type": "string",
                                    "enum": [
                                      "info"
                                    ]
                                  }
                                ]
                              }
                            }
                          }
                        },
                        "info": {
                          "type": "array",
                          "items": {
                            "additionalProperties": true,
                            "type": "object",
                            "required": [
                              "code",
                              "fieldPath",
                              "message",
                              "severity"
                            ],
                            "properties": {
                              "code": {
                                "description": "Stable error code (e.g. \"INVALID_AGE_RANGE\").",
                                "type": "string"
                              },
                              "fieldPath": {
                                "description": "Dot-notation path of the offending field.",
                                "type": "string"
                              },
                              "message": {
                                "type": "string"
                              },
                              "metaErrorCode": {
                                "type": "number"
                              },
                              "severity": {
                                "anyOf": [
                                  {
                                    "type": "string",
                                    "enum": [
                                      "error"
                                    ]
                                  },
                                  {
                                    "type": "string",
                                    "enum": [
                                      "warning"
                                    ]
                                  },
                                  {
                                    "type": "string",
                                    "enum": [
                                      "info"
                                    ]
                                  }
                                ]
                              }
                            }
                          }
                        }
                      }
                    },
                    "code": {
                      "description": "Machine-readable code (e.g. NAMING_CONVENTION_BLOCKED).",
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "description": "Reason the operation was rejected (e.g. \"Draft not found\", \"Validation failed\", \"Duplicate account_id in targets\").",
                      "type": "string"
                    },
                    "validation": {
                      "additionalProperties": true,
                      "type": "object",
                      "required": [
                        "valid",
                        "errors",
                        "warnings",
                        "info"
                      ],
                      "properties": {
                        "valid": {
                          "type": "boolean"
                        },
                        "errors": {
                          "type": "array",
                          "items": {
                            "additionalProperties": true,
                            "type": "object",
                            "required": [
                              "code",
                              "fieldPath",
                              "message",
                              "severity"
                            ],
                            "properties": {
                              "code": {
                                "description": "Stable error code (e.g. \"INVALID_AGE_RANGE\").",
                                "type": "string"
                              },
                              "fieldPath": {
                                "description": "Dot-notation path of the offending field.",
                                "type": "string"
                              },
                              "message": {
                                "type": "string"
                              },
                              "metaErrorCode": {
                                "type": "number"
                              },
                              "severity": {
                                "anyOf": [
                                  {
                                    "type": "string",
                                    "enum": [
                                      "error"
                                    ]
                                  },
                                  {
                                    "type": "string",
                                    "enum": [
                                      "warning"
                                    ]
                                  },
                                  {
                                    "type": "string",
                                    "enum": [
                                      "info"
                                    ]
                                  }
                                ]
                              }
                            }
                          }
                        },
                        "warnings": {
                          "type": "array",
                          "items": {
                            "additionalProperties": true,
                            "type": "object",
                            "required": [
                              "code",
                              "fieldPath",
                              "message",
                              "severity"
                            ],
                            "properties": {
                              "code": {
                                "description": "Stable error code (e.g. \"INVALID_AGE_RANGE\").",
                                "type": "string"
                              },
                              "fieldPath": {
                                "description": "Dot-notation path of the offending field.",
                                "type": "string"
                              },
                              "message": {
                                "type": "string"
                              },
                              "metaErrorCode": {
                                "type": "number"
                              },
                              "severity": {
                                "anyOf": [
                                  {
                                    "type": "string",
                                    "enum": [
                                      "error"
                                    ]
                                  },
                                  {
                                    "type": "string",
                                    "enum": [
                                      "warning"
                                    ]
                                  },
                                  {
                                    "type": "string",
                                    "enum": [
                                      "info"
                                    ]
                                  }
                                ]
                              }
                            }
                          }
                        },
                        "info": {
                          "type": "array",
                          "items": {
                            "additionalProperties": true,
                            "type": "object",
                            "required": [
                              "code",
                              "fieldPath",
                              "message",
                              "severity"
                            ],
                            "properties": {
                              "code": {
                                "description": "Stable error code (e.g. \"INVALID_AGE_RANGE\").",
                                "type": "string"
                              },
                              "fieldPath": {
                                "description": "Dot-notation path of the offending field.",
                                "type": "string"
                              },
                              "message": {
                                "type": "string"
                              },
                              "metaErrorCode": {
                                "type": "number"
                              },
                              "severity": {
                                "anyOf": [
                                  {
                                    "type": "string",
                                    "enum": [
                                      "error"
                                    ]
                                  },
                                  {
                                    "type": "string",
                                    "enum": [
                                      "warning"
                                    ]
                                  },
                                  {
                                    "type": "string",
                                    "enum": [
                                      "info"
                                    ]
                                  }
                                ]
                              }
                            }
                          }
                        }
                      }
                    },
                    "code": {
                      "description": "Machine-readable code (e.g. NAMING_CONVENTION_BLOCKED).",
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "description": "Reason the operation was rejected (e.g. \"Draft not found\", \"Validation failed\", \"Duplicate account_id in targets\").",
                      "type": "string"
                    },
                    "validation": {
                      "additionalProperties": true,
                      "type": "object",
                      "required": [
                        "valid",
                        "errors",
                        "warnings",
                        "info"
                      ],
                      "properties": {
                        "valid": {
                          "type": "boolean"
                        },
                        "errors": {
                          "type": "array",
                          "items": {
                            "additionalProperties": true,
                            "type": "object",
                            "required": [
                              "code",
                              "fieldPath",
                              "message",
                              "severity"
                            ],
                            "properties": {
                              "code": {
                                "description": "Stable error code (e.g. \"INVALID_AGE_RANGE\").",
                                "type": "string"
                              },
                              "fieldPath": {
                                "description": "Dot-notation path of the offending field.",
                                "type": "string"
                              },
                              "message": {
                                "type": "string"
                              },
                              "metaErrorCode": {
                                "type": "number"
                              },
                              "severity": {
                                "anyOf": [
                                  {
                                    "type": "string",
                                    "enum": [
                                      "error"
                                    ]
                                  },
                                  {
                                    "type": "string",
                                    "enum": [
                                      "warning"
                                    ]
                                  },
                                  {
                                    "type": "string",
                                    "enum": [
                                      "info"
                                    ]
                                  }
                                ]
                              }
                            }
                          }
                        },
                        "warnings": {
                          "type": "array",
                          "items": {
                            "additionalProperties": true,
                            "type": "object",
                            "required": [
                              "code",
                              "fieldPath",
                              "message",
                              "severity"
                            ],
                            "properties": {
                              "code": {
                                "description": "Stable error code (e.g. \"INVALID_AGE_RANGE\").",
                                "type": "string"
                              },
                              "fieldPath": {
                                "description": "Dot-notation path of the offending field.",
                                "type": "string"
                              },
                              "message": {
                                "type": "string"
                              },
                              "metaErrorCode": {
                                "type": "number"
                              },
                              "severity": {
                                "anyOf": [
                                  {
                                    "type": "string",
                                    "enum": [
                                      "error"
                                    ]
                                  },
                                  {
                                    "type": "string",
                                    "enum": [
                                      "warning"
                                    ]
                                  },
                                  {
                                    "type": "string",
                                    "enum": [
                                      "info"
                                    ]
                                  }
                                ]
                              }
                            }
                          }
                        },
                        "info": {
                          "type": "array",
                          "items": {
                            "additionalProperties": true,
                            "type": "object",
                            "required": [
                              "code",
                              "fieldPath",
                              "message",
                              "severity"
                            ],
                            "properties": {
                              "code": {
                                "description": "Stable error code (e.g. \"INVALID_AGE_RANGE\").",
                                "type": "string"
                              },
                              "fieldPath": {
                                "description": "Dot-notation path of the offending field.",
                                "type": "string"
                              },
                              "message": {
                                "type": "string"
                              },
                              "metaErrorCode": {
                                "type": "number"
                              },
                              "severity": {
                                "anyOf": [
                                  {
                                    "type": "string",
                                    "enum": [
                                      "error"
                                    ]
                                  },
                                  {
                                    "type": "string",
                                    "enum": [
                                      "warning"
                                    ]
                                  },
                                  {
                                    "type": "string",
                                    "enum": [
                                      "info"
                                    ]
                                  }
                                ]
                              }
                            }
                          }
                        }
                      }
                    },
                    "code": {
                      "description": "Machine-readable code (e.g. NAMING_CONVENTION_BLOCKED).",
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "422": {
            "description": "Unprocessable entity - semantic validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "description": "Reason the operation was rejected (e.g. \"Draft not found\", \"Validation failed\", \"Duplicate account_id in targets\").",
                      "type": "string"
                    },
                    "validation": {
                      "additionalProperties": true,
                      "type": "object",
                      "required": [
                        "valid",
                        "errors",
                        "warnings",
                        "info"
                      ],
                      "properties": {
                        "valid": {
                          "type": "boolean"
                        },
                        "errors": {
                          "type": "array",
                          "items": {
                            "additionalProperties": true,
                            "type": "object",
                            "required": [
                              "code",
                              "fieldPath",
                              "message",
                              "severity"
                            ],
                            "properties": {
                              "code": {
                                "description": "Stable error code (e.g. \"INVALID_AGE_RANGE\").",
                                "type": "string"
                              },
                              "fieldPath": {
                                "description": "Dot-notation path of the offending field.",
                                "type": "string"
                              },
                              "message": {
                                "type": "string"
                              },
                              "metaErrorCode": {
                                "type": "number"
                              },
                              "severity": {
                                "anyOf": [
                                  {
                                    "type": "string",
                                    "enum": [
                                      "error"
                                    ]
                                  },
                                  {
                                    "type": "string",
                                    "enum": [
                                      "warning"
                                    ]
                                  },
                                  {
                                    "type": "string",
                                    "enum": [
                                      "info"
                                    ]
                                  }
                                ]
                              }
                            }
                          }
                        },
                        "warnings": {
                          "type": "array",
                          "items": {
                            "additionalProperties": true,
                            "type": "object",
                            "required": [
                              "code",
                              "fieldPath",
                              "message",
                              "severity"
                            ],
                            "properties": {
                              "code": {
                                "description": "Stable error code (e.g. \"INVALID_AGE_RANGE\").",
                                "type": "string"
                              },
                              "fieldPath": {
                                "description": "Dot-notation path of the offending field.",
                                "type": "string"
                              },
                              "message": {
                                "type": "string"
                              },
                              "metaErrorCode": {
                                "type": "number"
                              },
                              "severity": {
                                "anyOf": [
                                  {
                                    "type": "string",
                                    "enum": [
                                      "error"
                                    ]
                                  },
                                  {
                                    "type": "string",
                                    "enum": [
                                      "warning"
                                    ]
                                  },
                                  {
                                    "type": "string",
                                    "enum": [
                                      "info"
                                    ]
                                  }
                                ]
                              }
                            }
                          }
                        },
                        "info": {
                          "type": "array",
                          "items": {
                            "additionalProperties": true,
                            "type": "object",
                            "required": [
                              "code",
                              "fieldPath",
                              "message",
                              "severity"
                            ],
                            "properties": {
                              "code": {
                                "description": "Stable error code (e.g. \"INVALID_AGE_RANGE\").",
                                "type": "string"
                              },
                              "fieldPath": {
                                "description": "Dot-notation path of the offending field.",
                                "type": "string"
                              },
                              "message": {
                                "type": "string"
                              },
                              "metaErrorCode": {
                                "type": "number"
                              },
                              "severity": {
                                "anyOf": [
                                  {
                                    "type": "string",
                                    "enum": [
                                      "error"
                                    ]
                                  },
                                  {
                                    "type": "string",
                                    "enum": [
                                      "warning"
                                    ]
                                  },
                                  {
                                    "type": "string",
                                    "enum": [
                                      "info"
                                    ]
                                  }
                                ]
                              }
                            }
                          }
                        }
                      }
                    },
                    "code": {
                      "description": "Machine-readable code (e.g. NAMING_CONVENTION_BLOCKED).",
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "error_code": {
                      "type": "string"
                    },
                    "detail": {}
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/campaign-drafts/{id}/multi-publish": {
      "post": {
        "operationId": "multiPublishCampaignDraft",
        "summary": "Publish campaign draft to multiple ad accounts",
        "tags": [
          "campaigns"
        ],
        "description": "Publishes the same campaign draft to multiple target ad accounts on the draft platform. Creates one publish job per target account.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "targets"
                ],
                "properties": {
                  "targets": {
                    "minItems": 1,
                    "maxItems": 20,
                    "type": "array",
                    "items": {
                      "additionalProperties": false,
                      "type": "object",
                      "required": [
                        "account_id",
                        "fan_page_id"
                      ],
                      "properties": {
                        "account_id": {
                          "minLength": 1,
                          "type": "string"
                        },
                        "fan_page_id": {
                          "minLength": 1,
                          "type": "string"
                        },
                        "pixel_id": {
                          "type": "string"
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object",
                  "required": [
                    "publishJobs"
                  ],
                  "properties": {
                    "publishJobs": {
                      "type": "array",
                      "items": {
                        "additionalProperties": true,
                        "type": "object",
                        "required": [
                          "publishJobId",
                          "accountId"
                        ],
                        "properties": {
                          "publishJobId": {
                            "type": "string"
                          },
                          "accountId": {
                            "type": "string"
                          }
                        }
                      }
                    },
                    "naming_warnings": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "description": "Reason the operation was rejected (e.g. \"Draft not found\", \"Validation failed\", \"Duplicate account_id in targets\").",
                      "type": "string"
                    },
                    "validation": {
                      "additionalProperties": true,
                      "type": "object",
                      "required": [
                        "valid",
                        "errors",
                        "warnings",
                        "info"
                      ],
                      "properties": {
                        "valid": {
                          "type": "boolean"
                        },
                        "errors": {
                          "type": "array",
                          "items": {
                            "additionalProperties": true,
                            "type": "object",
                            "required": [
                              "code",
                              "fieldPath",
                              "message",
                              "severity"
                            ],
                            "properties": {
                              "code": {
                                "description": "Stable error code (e.g. \"INVALID_AGE_RANGE\").",
                                "type": "string"
                              },
                              "fieldPath": {
                                "description": "Dot-notation path of the offending field.",
                                "type": "string"
                              },
                              "message": {
                                "type": "string"
                              },
                              "metaErrorCode": {
                                "type": "number"
                              },
                              "severity": {
                                "anyOf": [
                                  {
                                    "type": "string",
                                    "enum": [
                                      "error"
                                    ]
                                  },
                                  {
                                    "type": "string",
                                    "enum": [
                                      "warning"
                                    ]
                                  },
                                  {
                                    "type": "string",
                                    "enum": [
                                      "info"
                                    ]
                                  }
                                ]
                              }
                            }
                          }
                        },
                        "warnings": {
                          "type": "array",
                          "items": {
                            "additionalProperties": true,
                            "type": "object",
                            "required": [
                              "code",
                              "fieldPath",
                              "message",
                              "severity"
                            ],
                            "properties": {
                              "code": {
                                "description": "Stable error code (e.g. \"INVALID_AGE_RANGE\").",
                                "type": "string"
                              },
                              "fieldPath": {
                                "description": "Dot-notation path of the offending field.",
                                "type": "string"
                              },
                              "message": {
                                "type": "string"
                              },
                              "metaErrorCode": {
                                "type": "number"
                              },
                              "severity": {
                                "anyOf": [
                                  {
                                    "type": "string",
                                    "enum": [
                                      "error"
                                    ]
                                  },
                                  {
                                    "type": "string",
                                    "enum": [
                                      "warning"
                                    ]
                                  },
                                  {
                                    "type": "string",
                                    "enum": [
                                      "info"
                                    ]
                                  }
                                ]
                              }
                            }
                          }
                        },
                        "info": {
                          "type": "array",
                          "items": {
                            "additionalProperties": true,
                            "type": "object",
                            "required": [
                              "code",
                              "fieldPath",
                              "message",
                              "severity"
                            ],
                            "properties": {
                              "code": {
                                "description": "Stable error code (e.g. \"INVALID_AGE_RANGE\").",
                                "type": "string"
                              },
                              "fieldPath": {
                                "description": "Dot-notation path of the offending field.",
                                "type": "string"
                              },
                              "message": {
                                "type": "string"
                              },
                              "metaErrorCode": {
                                "type": "number"
                              },
                              "severity": {
                                "anyOf": [
                                  {
                                    "type": "string",
                                    "enum": [
                                      "error"
                                    ]
                                  },
                                  {
                                    "type": "string",
                                    "enum": [
                                      "warning"
                                    ]
                                  },
                                  {
                                    "type": "string",
                                    "enum": [
                                      "info"
                                    ]
                                  }
                                ]
                              }
                            }
                          }
                        }
                      }
                    },
                    "code": {
                      "description": "Machine-readable code (e.g. NAMING_CONVENTION_BLOCKED).",
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "description": "Reason the operation was rejected (e.g. \"Draft not found\", \"Validation failed\", \"Duplicate account_id in targets\").",
                      "type": "string"
                    },
                    "validation": {
                      "additionalProperties": true,
                      "type": "object",
                      "required": [
                        "valid",
                        "errors",
                        "warnings",
                        "info"
                      ],
                      "properties": {
                        "valid": {
                          "type": "boolean"
                        },
                        "errors": {
                          "type": "array",
                          "items": {
                            "additionalProperties": true,
                            "type": "object",
                            "required": [
                              "code",
                              "fieldPath",
                              "message",
                              "severity"
                            ],
                            "properties": {
                              "code": {
                                "description": "Stable error code (e.g. \"INVALID_AGE_RANGE\").",
                                "type": "string"
                              },
                              "fieldPath": {
                                "description": "Dot-notation path of the offending field.",
                                "type": "string"
                              },
                              "message": {
                                "type": "string"
                              },
                              "metaErrorCode": {
                                "type": "number"
                              },
                              "severity": {
                                "anyOf": [
                                  {
                                    "type": "string",
                                    "enum": [
                                      "error"
                                    ]
                                  },
                                  {
                                    "type": "string",
                                    "enum": [
                                      "warning"
                                    ]
                                  },
                                  {
                                    "type": "string",
                                    "enum": [
                                      "info"
                                    ]
                                  }
                                ]
                              }
                            }
                          }
                        },
                        "warnings": {
                          "type": "array",
                          "items": {
                            "additionalProperties": true,
                            "type": "object",
                            "required": [
                              "code",
                              "fieldPath",
                              "message",
                              "severity"
                            ],
                            "properties": {
                              "code": {
                                "description": "Stable error code (e.g. \"INVALID_AGE_RANGE\").",
                                "type": "string"
                              },
                              "fieldPath": {
                                "description": "Dot-notation path of the offending field.",
                                "type": "string"
                              },
                              "message": {
                                "type": "string"
                              },
                              "metaErrorCode": {
                                "type": "number"
                              },
                              "severity": {
                                "anyOf": [
                                  {
                                    "type": "string",
                                    "enum": [
                                      "error"
                                    ]
                                  },
                                  {
                                    "type": "string",
                                    "enum": [
                                      "warning"
                                    ]
                                  },
                                  {
                                    "type": "string",
                                    "enum": [
                                      "info"
                                    ]
                                  }
                                ]
                              }
                            }
                          }
                        },
                        "info": {
                          "type": "array",
                          "items": {
                            "additionalProperties": true,
                            "type": "object",
                            "required": [
                              "code",
                              "fieldPath",
                              "message",
                              "severity"
                            ],
                            "properties": {
                              "code": {
                                "description": "Stable error code (e.g. \"INVALID_AGE_RANGE\").",
                                "type": "string"
                              },
                              "fieldPath": {
                                "description": "Dot-notation path of the offending field.",
                                "type": "string"
                              },
                              "message": {
                                "type": "string"
                              },
                              "metaErrorCode": {
                                "type": "number"
                              },
                              "severity": {
                                "anyOf": [
                                  {
                                    "type": "string",
                                    "enum": [
                                      "error"
                                    ]
                                  },
                                  {
                                    "type": "string",
                                    "enum": [
                                      "warning"
                                    ]
                                  },
                                  {
                                    "type": "string",
                                    "enum": [
                                      "info"
                                    ]
                                  }
                                ]
                              }
                            }
                          }
                        }
                      }
                    },
                    "code": {
                      "description": "Machine-readable code (e.g. NAMING_CONVENTION_BLOCKED).",
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "422": {
            "description": "Unprocessable entity - semantic validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "description": "Reason the operation was rejected (e.g. \"Draft not found\", \"Validation failed\", \"Duplicate account_id in targets\").",
                      "type": "string"
                    },
                    "validation": {
                      "additionalProperties": true,
                      "type": "object",
                      "required": [
                        "valid",
                        "errors",
                        "warnings",
                        "info"
                      ],
                      "properties": {
                        "valid": {
                          "type": "boolean"
                        },
                        "errors": {
                          "type": "array",
                          "items": {
                            "additionalProperties": true,
                            "type": "object",
                            "required": [
                              "code",
                              "fieldPath",
                              "message",
                              "severity"
                            ],
                            "properties": {
                              "code": {
                                "description": "Stable error code (e.g. \"INVALID_AGE_RANGE\").",
                                "type": "string"
                              },
                              "fieldPath": {
                                "description": "Dot-notation path of the offending field.",
                                "type": "string"
                              },
                              "message": {
                                "type": "string"
                              },
                              "metaErrorCode": {
                                "type": "number"
                              },
                              "severity": {
                                "anyOf": [
                                  {
                                    "type": "string",
                                    "enum": [
                                      "error"
                                    ]
                                  },
                                  {
                                    "type": "string",
                                    "enum": [
                                      "warning"
                                    ]
                                  },
                                  {
                                    "type": "string",
                                    "enum": [
                                      "info"
                                    ]
                                  }
                                ]
                              }
                            }
                          }
                        },
                        "warnings": {
                          "type": "array",
                          "items": {
                            "additionalProperties": true,
                            "type": "object",
                            "required": [
                              "code",
                              "fieldPath",
                              "message",
                              "severity"
                            ],
                            "properties": {
                              "code": {
                                "description": "Stable error code (e.g. \"INVALID_AGE_RANGE\").",
                                "type": "string"
                              },
                              "fieldPath": {
                                "description": "Dot-notation path of the offending field.",
                                "type": "string"
                              },
                              "message": {
                                "type": "string"
                              },
                              "metaErrorCode": {
                                "type": "number"
                              },
                              "severity": {
                                "anyOf": [
                                  {
                                    "type": "string",
                                    "enum": [
                                      "error"
                                    ]
                                  },
                                  {
                                    "type": "string",
                                    "enum": [
                                      "warning"
                                    ]
                                  },
                                  {
                                    "type": "string",
                                    "enum": [
                                      "info"
                                    ]
                                  }
                                ]
                              }
                            }
                          }
                        },
                        "info": {
                          "type": "array",
                          "items": {
                            "additionalProperties": true,
                            "type": "object",
                            "required": [
                              "code",
                              "fieldPath",
                              "message",
                              "severity"
                            ],
                            "properties": {
                              "code": {
                                "description": "Stable error code (e.g. \"INVALID_AGE_RANGE\").",
                                "type": "string"
                              },
                              "fieldPath": {
                                "description": "Dot-notation path of the offending field.",
                                "type": "string"
                              },
                              "message": {
                                "type": "string"
                              },
                              "metaErrorCode": {
                                "type": "number"
                              },
                              "severity": {
                                "anyOf": [
                                  {
                                    "type": "string",
                                    "enum": [
                                      "error"
                                    ]
                                  },
                                  {
                                    "type": "string",
                                    "enum": [
                                      "warning"
                                    ]
                                  },
                                  {
                                    "type": "string",
                                    "enum": [
                                      "info"
                                    ]
                                  }
                                ]
                              }
                            }
                          }
                        }
                      }
                    },
                    "code": {
                      "description": "Machine-readable code (e.g. NAMING_CONVENTION_BLOCKED).",
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "error_code": {
                      "type": "string"
                    },
                    "detail": {}
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/campaign-drafts/publish-jobs/{jobId}": {
      "get": {
        "operationId": "getCampaignPublishJob",
        "summary": "Get publish job status with logs",
        "tags": [
          "campaigns"
        ],
        "description": "Returns the current status and execution logs of a specific publish job.",
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "jobId",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "id",
                    "campaign_draft_id",
                    "source",
                    "status",
                    "platform",
                    "canonical_campaign",
                    "total_entities",
                    "completed_entities",
                    "failed_entities",
                    "dry_run",
                    "idempotency_key",
                    "created_at",
                    "processing_started_at",
                    "completed_at"
                  ],
                  "properties": {
                    "id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "campaign_draft_id": {
                      "anyOf": [
                        {
                          "format": "uuid",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "source": {
                      "type": "string"
                    },
                    "status": {
                      "type": "string"
                    },
                    "platform": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "canonical_campaign": {
                      "$comment": "json-value",
                      "description": "Arbitrary JSON value with nested arrays and objects."
                    },
                    "total_entities": {
                      "type": "integer"
                    },
                    "completed_entities": {
                      "type": "integer"
                    },
                    "failed_entities": {
                      "type": "integer"
                    },
                    "dry_run": {
                      "type": "boolean"
                    },
                    "idempotency_key": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "created_at": {
                      "format": "date-time",
                      "type": "string"
                    },
                    "processing_started_at": {
                      "anyOf": [
                        {
                          "format": "date-time",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "completed_at": {
                      "anyOf": [
                        {
                          "format": "date-time",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "logs": {
                      "type": "array",
                      "items": {
                        "additionalProperties": false,
                        "type": "object",
                        "required": [
                          "id",
                          "publish_job_id",
                          "entity_type",
                          "entity_name",
                          "status",
                          "attempt",
                          "error_message",
                          "meta_entity_id",
                          "created_at"
                        ],
                        "properties": {
                          "id": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "publish_job_id": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "entity_type": {
                            "type": "string"
                          },
                          "entity_name": {
                            "type": "string"
                          },
                          "status": {
                            "type": "string"
                          },
                          "attempt": {
                            "type": "integer"
                          },
                          "error_message": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "meta_entity_id": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "created_at": {
                            "format": "date-time",
                            "type": "string"
                          }
                        },
                        "title": "PublicPublishLogResponse"
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "error_code": {
                      "type": "string"
                    },
                    "detail": {}
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "error_code": {
                      "type": "string"
                    },
                    "detail": {}
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/campaign-drafts/{id}/publish-jobs": {
      "get": {
        "operationId": "listCampaignPublishJobs",
        "summary": "List publish jobs for a campaign draft",
        "tags": [
          "campaigns"
        ],
        "description": "Returns all publish jobs associated with a specific campaign draft.",
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "additionalProperties": false,
                    "type": "object",
                    "required": [
                      "id",
                      "campaign_draft_id",
                      "source",
                      "status",
                      "platform",
                      "canonical_campaign",
                      "total_entities",
                      "completed_entities",
                      "failed_entities",
                      "dry_run",
                      "idempotency_key",
                      "created_at",
                      "processing_started_at",
                      "completed_at"
                    ],
                    "properties": {
                      "id": {
                        "format": "uuid",
                        "type": "string"
                      },
                      "campaign_draft_id": {
                        "anyOf": [
                          {
                            "format": "uuid",
                            "type": "string"
                          },
                          {
                            "type": "null"
                          }
                        ]
                      },
                      "source": {
                        "type": "string"
                      },
                      "status": {
                        "type": "string"
                      },
                      "platform": {
                        "anyOf": [
                          {
                            "type": "string"
                          },
                          {
                            "type": "null"
                          }
                        ]
                      },
                      "canonical_campaign": {
                        "$comment": "json-value",
                        "description": "Arbitrary JSON value with nested arrays and objects."
                      },
                      "total_entities": {
                        "type": "integer"
                      },
                      "completed_entities": {
                        "type": "integer"
                      },
                      "failed_entities": {
                        "type": "integer"
                      },
                      "dry_run": {
                        "type": "boolean"
                      },
                      "idempotency_key": {
                        "anyOf": [
                          {
                            "type": "string"
                          },
                          {
                            "type": "null"
                          }
                        ]
                      },
                      "created_at": {
                        "format": "date-time",
                        "type": "string"
                      },
                      "processing_started_at": {
                        "anyOf": [
                          {
                            "format": "date-time",
                            "type": "string"
                          },
                          {
                            "type": "null"
                          }
                        ]
                      },
                      "completed_at": {
                        "anyOf": [
                          {
                            "format": "date-time",
                            "type": "string"
                          },
                          {
                            "type": "null"
                          }
                        ]
                      },
                      "logs": {
                        "type": "array",
                        "items": {
                          "additionalProperties": false,
                          "type": "object",
                          "required": [
                            "id",
                            "publish_job_id",
                            "entity_type",
                            "entity_name",
                            "status",
                            "attempt",
                            "error_message",
                            "meta_entity_id",
                            "created_at"
                          ],
                          "properties": {
                            "id": {
                              "format": "uuid",
                              "type": "string"
                            },
                            "publish_job_id": {
                              "format": "uuid",
                              "type": "string"
                            },
                            "entity_type": {
                              "type": "string"
                            },
                            "entity_name": {
                              "type": "string"
                            },
                            "status": {
                              "type": "string"
                            },
                            "attempt": {
                              "type": "integer"
                            },
                            "error_message": {
                              "anyOf": [
                                {
                                  "type": "string"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "meta_entity_id": {
                              "anyOf": [
                                {
                                  "type": "string"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "created_at": {
                              "format": "date-time",
                              "type": "string"
                            }
                          }
                        }
                      }
                    },
                    "title": "PublicPublishJobResponse"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "error_code": {
                      "type": "string"
                    },
                    "detail": {}
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/campaign-drafts/{id}/save-template": {
      "post": {
        "operationId": "saveCampaignDraftAsTemplate",
        "summary": "Save campaign draft as template",
        "tags": [
          "campaigns"
        ],
        "description": "Saves the current state of a campaign draft as a reusable template.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "name"
                ],
                "properties": {
                  "name": {
                    "minLength": 1,
                    "maxLength": 500,
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "201": {
            "description": "Resource created",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "id",
                    "name",
                    "source",
                    "canonical_campaign",
                    "created_at",
                    "updated_at"
                  ],
                  "properties": {
                    "id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "name": {
                      "type": "string"
                    },
                    "source": {
                      "type": "string"
                    },
                    "canonical_campaign": {
                      "$comment": "json-value",
                      "description": "Arbitrary JSON value with nested arrays and objects."
                    },
                    "created_at": {
                      "format": "date-time",
                      "type": "string"
                    },
                    "updated_at": {
                      "anyOf": [
                        {
                          "format": "date-time",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "error_code": {
                      "type": "string"
                    },
                    "detail": {}
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "error_code": {
                      "type": "string"
                    },
                    "detail": {}
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/campaign-drafts/from-template": {
      "post": {
        "operationId": "createCampaignDraftFromTemplate",
        "summary": "Create campaign draft from template",
        "tags": [
          "campaigns"
        ],
        "description": "Creates a new campaign draft pre-populated with the canonical campaign structure from an existing template.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "template_id",
                  "name"
                ],
                "properties": {
                  "template_id": {
                    "format": "uuid",
                    "type": "string"
                  },
                  "name": {
                    "minLength": 1,
                    "maxLength": 500,
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "201": {
            "description": "Resource created",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "id",
                    "account_id",
                    "name",
                    "source",
                    "status",
                    "platform",
                    "current_step",
                    "canonical_campaign",
                    "created_at",
                    "updated_at"
                  ],
                  "properties": {
                    "id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "account_id": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "name": {
                      "type": "string"
                    },
                    "source": {
                      "type": "string"
                    },
                    "status": {
                      "type": "string"
                    },
                    "platform": {
                      "type": "string"
                    },
                    "current_step": {
                      "type": "integer"
                    },
                    "canonical_campaign": {
                      "$comment": "json-value",
                      "description": "Arbitrary JSON value with nested arrays and objects."
                    },
                    "created_at": {
                      "format": "date-time",
                      "type": "string"
                    },
                    "updated_at": {
                      "anyOf": [
                        {
                          "format": "date-time",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "error_code": {
                      "type": "string"
                    },
                    "detail": {}
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "error_code": {
                      "type": "string"
                    },
                    "detail": {}
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/campaigns/{campaignId}/name": {
      "patch": {
        "operationId": "renameCampaign",
        "summary": "Rename a campaign in-place",
        "tags": [
          "campaigns"
        ],
        "description": "Updates only the `name` field of a Meta campaign (Graph API POST /<campaign_id>). Intended for the Ads Manager list quick-rename affordance — campaign structure is untouched, so the call is safe to wire to optimistic updates on the frontend.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "name",
                  "account_id"
                ],
                "properties": {
                  "name": {
                    "minLength": 1,
                    "maxLength": 400,
                    "type": "string"
                  },
                  "account_id": {
                    "minLength": 1,
                    "type": "string"
                  },
                  "platform": {
                    "type": "string",
                    "enum": [
                      "meta"
                    ]
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "schema": {
              "minLength": 1,
              "type": "string"
            },
            "in": "path",
            "name": "campaignId",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "campaign_id",
                    "name"
                  ],
                  "properties": {
                    "campaign_id": {
                      "type": "string"
                    },
                    "name": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/campaign-templates": {
      "get": {
        "operationId": "listCampaignTemplates",
        "summary": "List campaign templates",
        "tags": [
          "campaigns"
        ],
        "description": "Returns all campaign templates accessible to the authenticated user.",
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "items"
                  ],
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "additionalProperties": false,
                        "type": "object",
                        "required": [
                          "id",
                          "name",
                          "source",
                          "canonical_campaign",
                          "created_at",
                          "updated_at"
                        ],
                        "properties": {
                          "id": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "name": {
                            "type": "string"
                          },
                          "source": {
                            "type": "string"
                          },
                          "canonical_campaign": {
                            "$comment": "json-value",
                            "description": "Arbitrary JSON value with nested arrays and objects."
                          },
                          "created_at": {
                            "format": "date-time",
                            "type": "string"
                          },
                          "updated_at": {
                            "anyOf": [
                              {
                                "format": "date-time",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          }
                        },
                        "title": "PublicCampaignTemplateResponse"
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "createCampaignTemplate",
        "summary": "Create a campaign template",
        "tags": [
          "campaigns"
        ],
        "description": "Creates a new campaign template with the given name and canonical campaign structure.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "name"
                ],
                "properties": {
                  "name": {
                    "minLength": 1,
                    "maxLength": 500,
                    "type": "string"
                  },
                  "draft_id": {
                    "format": "uuid",
                    "type": "string"
                  },
                  "canonical_campaign": {
                    "additionalProperties": false,
                    "description": "Canonical campaign JSONB shape used by campaign drafts. Fields are optional because drafts are auto-saved while incomplete.",
                    "type": "object",
                    "properties": {
                      "accountId": {
                        "anyOf": [
                          {
                            "type": "string"
                          },
                          {
                            "type": "null"
                          }
                        ]
                      },
                      "adSets": {
                        "anyOf": [
                          {
                            "type": "array",
                            "items": {
                              "additionalProperties": false,
                              "type": "object",
                              "properties": {
                                "ads": {
                                  "anyOf": [
                                    {
                                      "type": "array",
                                      "items": {
                                        "additionalProperties": false,
                                        "type": "object",
                                        "properties": {
                                          "advantageCreative": {
                                            "anyOf": [
                                              {
                                                "type": "boolean"
                                              },
                                              {
                                                "type": "null"
                                              }
                                            ]
                                          },
                                          "callToAction": {
                                            "anyOf": [
                                              {
                                                "type": "string"
                                              },
                                              {
                                                "type": "null"
                                              }
                                            ]
                                          },
                                          "creativeFormat": {
                                            "anyOf": [
                                              {
                                                "anyOf": [
                                                  {
                                                    "type": "string",
                                                    "enum": [
                                                      "SINGLE_IMAGE"
                                                    ]
                                                  },
                                                  {
                                                    "type": "string",
                                                    "enum": [
                                                      "SINGLE_VIDEO"
                                                    ]
                                                  },
                                                  {
                                                    "type": "string",
                                                    "enum": [
                                                      "CAROUSEL"
                                                    ]
                                                  },
                                                  {
                                                    "type": "string",
                                                    "enum": [
                                                      "EXISTING_POST"
                                                    ]
                                                  },
                                                  {
                                                    "type": "string",
                                                    "enum": [
                                                      "CATALOG"
                                                    ]
                                                  },
                                                  {
                                                    "type": "string",
                                                    "enum": [
                                                      "FLEXIBLE"
                                                    ]
                                                  }
                                                ]
                                              },
                                              {
                                                "type": "null"
                                              }
                                            ]
                                          },
                                          "description": {
                                            "anyOf": [
                                              {
                                                "type": "string"
                                              },
                                              {
                                                "type": "null"
                                              }
                                            ]
                                          },
                                          "descriptionVariations": {
                                            "anyOf": [
                                              {
                                                "type": "array",
                                                "items": {
                                                  "type": "string"
                                                }
                                              },
                                              {
                                                "type": "null"
                                              }
                                            ]
                                          },
                                          "dynamicCreative": {
                                            "anyOf": [
                                              {
                                                "type": "boolean"
                                              },
                                              {
                                                "type": "null"
                                              }
                                            ]
                                          },
                                          "existingPostId": {
                                            "anyOf": [
                                              {
                                                "type": "string"
                                              },
                                              {
                                                "type": "null"
                                              }
                                            ]
                                          },
                                          "existingPostPreview": {
                                            "anyOf": [
                                              {
                                                "additionalProperties": false,
                                                "type": "object",
                                                "properties": {
                                                  "imageUrl": {
                                                    "anyOf": [
                                                      {
                                                        "type": "string"
                                                      },
                                                      {
                                                        "type": "null"
                                                      }
                                                    ]
                                                  },
                                                  "message": {
                                                    "anyOf": [
                                                      {
                                                        "type": "string"
                                                      },
                                                      {
                                                        "type": "null"
                                                      }
                                                    ]
                                                  }
                                                }
                                              },
                                              {
                                                "type": "null"
                                              }
                                            ]
                                          },
                                          "googleDescriptions": {
                                            "anyOf": [
                                              {
                                                "type": "array",
                                                "items": {
                                                  "type": "string"
                                                }
                                              },
                                              {
                                                "type": "null"
                                              }
                                            ]
                                          },
                                          "googleDisplayPath1": {
                                            "anyOf": [
                                              {
                                                "type": "string"
                                              },
                                              {
                                                "type": "null"
                                              }
                                            ]
                                          },
                                          "googleDisplayPath2": {
                                            "anyOf": [
                                              {
                                                "type": "string"
                                              },
                                              {
                                                "type": "null"
                                              }
                                            ]
                                          },
                                          "googleHeadlines": {
                                            "anyOf": [
                                              {
                                                "type": "array",
                                                "items": {
                                                  "type": "string"
                                                }
                                              },
                                              {
                                                "type": "null"
                                              }
                                            ]
                                          },
                                          "googleLogoAsset": {
                                            "anyOf": [
                                              {
                                                "additionalProperties": false,
                                                "type": "object",
                                                "properties": {
                                                  "aiGenerated": {
                                                    "anyOf": [
                                                      {
                                                        "type": "boolean"
                                                      },
                                                      {
                                                        "type": "null"
                                                      }
                                                    ]
                                                  },
                                                  "cardDescription": {
                                                    "anyOf": [
                                                      {
                                                        "type": "string"
                                                      },
                                                      {
                                                        "type": "null"
                                                      }
                                                    ]
                                                  },
                                                  "cardHeadline": {
                                                    "anyOf": [
                                                      {
                                                        "type": "string"
                                                      },
                                                      {
                                                        "type": "null"
                                                      }
                                                    ]
                                                  },
                                                  "crops": {
                                                    "anyOf": [
                                                      {
                                                        "additionalProperties": false,
                                                        "type": "object",
                                                        "properties": {
                                                          "100x100": {
                                                            "anyOf": [
                                                              {
                                                                "minItems": 2,
                                                                "maxItems": 2,
                                                                "type": "array",
                                                                "items": {
                                                                  "minItems": 2,
                                                                  "maxItems": 2,
                                                                  "type": "array",
                                                                  "items": {
                                                                    "type": "number"
                                                                  }
                                                                }
                                                              },
                                                              {
                                                                "type": "null"
                                                              }
                                                            ]
                                                          },
                                                          "191x100": {
                                                            "anyOf": [
                                                              {
                                                                "minItems": 2,
                                                                "maxItems": 2,
                                                                "type": "array",
                                                                "items": {
                                                                  "minItems": 2,
                                                                  "maxItems": 2,
                                                                  "type": "array",
                                                                  "items": {
                                                                    "type": "number"
                                                                  }
                                                                }
                                                              },
                                                              {
                                                                "type": "null"
                                                              }
                                                            ]
                                                          },
                                                          "400x500": {
                                                            "anyOf": [
                                                              {
                                                                "minItems": 2,
                                                                "maxItems": 2,
                                                                "type": "array",
                                                                "items": {
                                                                  "minItems": 2,
                                                                  "maxItems": 2,
                                                                  "type": "array",
                                                                  "items": {
                                                                    "type": "number"
                                                                  }
                                                                }
                                                              },
                                                              {
                                                                "type": "null"
                                                              }
                                                            ]
                                                          }
                                                        }
                                                      },
                                                      {
                                                        "type": "null"
                                                      }
                                                    ]
                                                  },
                                                  "duration": {
                                                    "anyOf": [
                                                      {
                                                        "type": "number"
                                                      },
                                                      {
                                                        "type": "null"
                                                      }
                                                    ]
                                                  },
                                                  "fileSizeBytes": {
                                                    "anyOf": [
                                                      {
                                                        "type": "number"
                                                      },
                                                      {
                                                        "type": "null"
                                                      }
                                                    ]
                                                  },
                                                  "height": {
                                                    "anyOf": [
                                                      {
                                                        "type": "number"
                                                      },
                                                      {
                                                        "type": "null"
                                                      }
                                                    ]
                                                  },
                                                  "metaHash": {
                                                    "anyOf": [
                                                      {
                                                        "type": "string"
                                                      },
                                                      {
                                                        "type": "null"
                                                      }
                                                    ]
                                                  },
                                                  "metaVideoId": {
                                                    "anyOf": [
                                                      {
                                                        "type": "string"
                                                      },
                                                      {
                                                        "type": "null"
                                                      }
                                                    ]
                                                  },
                                                  "snapchatMediaId": {
                                                    "anyOf": [
                                                      {
                                                        "type": "string"
                                                      },
                                                      {
                                                        "type": "null"
                                                      }
                                                    ]
                                                  },
                                                  "sourceUrl": {
                                                    "anyOf": [
                                                      {
                                                        "type": "string"
                                                      },
                                                      {
                                                        "type": "null"
                                                      }
                                                    ]
                                                  },
                                                  "thumbnailUrl": {
                                                    "anyOf": [
                                                      {
                                                        "type": "string"
                                                      },
                                                      {
                                                        "type": "null"
                                                      }
                                                    ]
                                                  },
                                                  "tiktokVideoId": {
                                                    "anyOf": [
                                                      {
                                                        "type": "string"
                                                      },
                                                      {
                                                        "type": "null"
                                                      }
                                                    ]
                                                  },
                                                  "type": {
                                                    "anyOf": [
                                                      {
                                                        "anyOf": [
                                                          {
                                                            "type": "string",
                                                            "enum": [
                                                              "image"
                                                            ]
                                                          },
                                                          {
                                                            "type": "string",
                                                            "enum": [
                                                              "video"
                                                            ]
                                                          }
                                                        ]
                                                      },
                                                      {
                                                        "type": "null"
                                                      }
                                                    ]
                                                  },
                                                  "videoId": {
                                                    "anyOf": [
                                                      {
                                                        "type": "string"
                                                      },
                                                      {
                                                        "type": "null"
                                                      }
                                                    ]
                                                  },
                                                  "width": {
                                                    "anyOf": [
                                                      {
                                                        "type": "number"
                                                      },
                                                      {
                                                        "type": "null"
                                                      }
                                                    ]
                                                  }
                                                }
                                              },
                                              {
                                                "type": "null"
                                              }
                                            ]
                                          },
                                          "googleYoutubeUrl": {
                                            "anyOf": [
                                              {
                                                "type": "string"
                                              },
                                              {
                                                "type": "null"
                                              }
                                            ]
                                          },
                                          "headline": {
                                            "anyOf": [
                                              {
                                                "type": "string"
                                              },
                                              {
                                                "type": "null"
                                              }
                                            ]
                                          },
                                          "headlineVariations": {
                                            "anyOf": [
                                              {
                                                "type": "array",
                                                "items": {
                                                  "type": "string"
                                                }
                                              },
                                              {
                                                "type": "null"
                                              }
                                            ]
                                          },
                                          "id": {
                                            "anyOf": [
                                              {
                                                "type": "string"
                                              },
                                              {
                                                "type": "null"
                                              }
                                            ]
                                          },
                                          "media": {
                                            "anyOf": [
                                              {
                                                "type": "array",
                                                "items": {
                                                  "additionalProperties": false,
                                                  "type": "object",
                                                  "properties": {
                                                    "aiGenerated": {
                                                      "anyOf": [
                                                        {
                                                          "type": "boolean"
                                                        },
                                                        {
                                                          "type": "null"
                                                        }
                                                      ]
                                                    },
                                                    "cardDescription": {
                                                      "anyOf": [
                                                        {
                                                          "type": "string"
                                                        },
                                                        {
                                                          "type": "null"
                                                        }
                                                      ]
                                                    },
                                                    "cardHeadline": {
                                                      "anyOf": [
                                                        {
                                                          "type": "string"
                                                        },
                                                        {
                                                          "type": "null"
                                                        }
                                                      ]
                                                    },
                                                    "crops": {
                                                      "anyOf": [
                                                        {
                                                          "additionalProperties": false,
                                                          "type": "object",
                                                          "properties": {
                                                            "100x100": {
                                                              "anyOf": [
                                                                {
                                                                  "minItems": 2,
                                                                  "maxItems": 2,
                                                                  "type": "array",
                                                                  "items": {
                                                                    "minItems": 2,
                                                                    "maxItems": 2,
                                                                    "type": "array",
                                                                    "items": {
                                                                      "type": "number"
                                                                    }
                                                                  }
                                                                },
                                                                {
                                                                  "type": "null"
                                                                }
                                                              ]
                                                            },
                                                            "191x100": {
                                                              "anyOf": [
                                                                {
                                                                  "minItems": 2,
                                                                  "maxItems": 2,
                                                                  "type": "array",
                                                                  "items": {
                                                                    "minItems": 2,
                                                                    "maxItems": 2,
                                                                    "type": "array",
                                                                    "items": {
                                                                      "type": "number"
                                                                    }
                                                                  }
                                                                },
                                                                {
                                                                  "type": "null"
                                                                }
                                                              ]
                                                            },
                                                            "400x500": {
                                                              "anyOf": [
                                                                {
                                                                  "minItems": 2,
                                                                  "maxItems": 2,
                                                                  "type": "array",
                                                                  "items": {
                                                                    "minItems": 2,
                                                                    "maxItems": 2,
                                                                    "type": "array",
                                                                    "items": {
                                                                      "type": "number"
                                                                    }
                                                                  }
                                                                },
                                                                {
                                                                  "type": "null"
                                                                }
                                                              ]
                                                            }
                                                          }
                                                        },
                                                        {
                                                          "type": "null"
                                                        }
                                                      ]
                                                    },
                                                    "duration": {
                                                      "anyOf": [
                                                        {
                                                          "type": "number"
                                                        },
                                                        {
                                                          "type": "null"
                                                        }
                                                      ]
                                                    },
                                                    "fileSizeBytes": {
                                                      "anyOf": [
                                                        {
                                                          "type": "number"
                                                        },
                                                        {
                                                          "type": "null"
                                                        }
                                                      ]
                                                    },
                                                    "height": {
                                                      "anyOf": [
                                                        {
                                                          "type": "number"
                                                        },
                                                        {
                                                          "type": "null"
                                                        }
                                                      ]
                                                    },
                                                    "metaHash": {
                                                      "anyOf": [
                                                        {
                                                          "type": "string"
                                                        },
                                                        {
                                                          "type": "null"
                                                        }
                                                      ]
                                                    },
                                                    "metaVideoId": {
                                                      "anyOf": [
                                                        {
                                                          "type": "string"
                                                        },
                                                        {
                                                          "type": "null"
                                                        }
                                                      ]
                                                    },
                                                    "snapchatMediaId": {
                                                      "anyOf": [
                                                        {
                                                          "type": "string"
                                                        },
                                                        {
                                                          "type": "null"
                                                        }
                                                      ]
                                                    },
                                                    "sourceUrl": {
                                                      "anyOf": [
                                                        {
                                                          "type": "string"
                                                        },
                                                        {
                                                          "type": "null"
                                                        }
                                                      ]
                                                    },
                                                    "thumbnailUrl": {
                                                      "anyOf": [
                                                        {
                                                          "type": "string"
                                                        },
                                                        {
                                                          "type": "null"
                                                        }
                                                      ]
                                                    },
                                                    "tiktokVideoId": {
                                                      "anyOf": [
                                                        {
                                                          "type": "string"
                                                        },
                                                        {
                                                          "type": "null"
                                                        }
                                                      ]
                                                    },
                                                    "type": {
                                                      "anyOf": [
                                                        {
                                                          "anyOf": [
                                                            {
                                                              "type": "string",
                                                              "enum": [
                                                                "image"
                                                              ]
                                                            },
                                                            {
                                                              "type": "string",
                                                              "enum": [
                                                                "video"
                                                              ]
                                                            }
                                                          ]
                                                        },
                                                        {
                                                          "type": "null"
                                                        }
                                                      ]
                                                    },
                                                    "videoId": {
                                                      "anyOf": [
                                                        {
                                                          "type": "string"
                                                        },
                                                        {
                                                          "type": "null"
                                                        }
                                                      ]
                                                    },
                                                    "width": {
                                                      "anyOf": [
                                                        {
                                                          "type": "number"
                                                        },
                                                        {
                                                          "type": "null"
                                                        }
                                                      ]
                                                    }
                                                  }
                                                }
                                              },
                                              {
                                                "type": "null"
                                              }
                                            ]
                                          },
                                          "multiAdvertiser": {
                                            "anyOf": [
                                              {
                                                "type": "boolean"
                                              },
                                              {
                                                "type": "null"
                                              }
                                            ]
                                          },
                                          "multilanguage": {
                                            "anyOf": [
                                              {
                                                "type": "boolean"
                                              },
                                              {
                                                "type": "null"
                                              }
                                            ]
                                          },
                                          "name": {
                                            "anyOf": [
                                              {
                                                "type": "string"
                                              },
                                              {
                                                "type": "null"
                                              }
                                            ]
                                          },
                                          "pageId": {
                                            "anyOf": [
                                              {
                                                "type": "string"
                                              },
                                              {
                                                "type": "null"
                                              }
                                            ]
                                          },
                                          "placementAssets": {
                                            "anyOf": [
                                              {
                                                "additionalProperties": false,
                                                "type": "object",
                                                "properties": {
                                                  "feed": {
                                                    "anyOf": [
                                                      {
                                                        "additionalProperties": false,
                                                        "type": "object",
                                                        "properties": {
                                                          "aiGenerated": {
                                                            "anyOf": [
                                                              {
                                                                "type": "boolean"
                                                              },
                                                              {
                                                                "type": "null"
                                                              }
                                                            ]
                                                          },
                                                          "cardDescription": {
                                                            "anyOf": [
                                                              {
                                                                "type": "string"
                                                              },
                                                              {
                                                                "type": "null"
                                                              }
                                                            ]
                                                          },
                                                          "cardHeadline": {
                                                            "anyOf": [
                                                              {
                                                                "type": "string"
                                                              },
                                                              {
                                                                "type": "null"
                                                              }
                                                            ]
                                                          },
                                                          "crops": {
                                                            "anyOf": [
                                                              {
                                                                "additionalProperties": false,
                                                                "type": "object",
                                                                "properties": {
                                                                  "100x100": {
                                                                    "anyOf": [
                                                                      {
                                                                        "minItems": 2,
                                                                        "maxItems": 2,
                                                                        "type": "array",
                                                                        "items": {
                                                                          "minItems": 2,
                                                                          "maxItems": 2,
                                                                          "type": "array",
                                                                          "items": {
                                                                            "type": "number"
                                                                          }
                                                                        }
                                                                      },
                                                                      {
                                                                        "type": "null"
                                                                      }
                                                                    ]
                                                                  },
                                                                  "191x100": {
                                                                    "anyOf": [
                                                                      {
                                                                        "minItems": 2,
                                                                        "maxItems": 2,
                                                                        "type": "array",
                                                                        "items": {
                                                                          "minItems": 2,
                                                                          "maxItems": 2,
                                                                          "type": "array",
                                                                          "items": {
                                                                            "type": "number"
                                                                          }
                                                                        }
                                                                      },
                                                                      {
                                                                        "type": "null"
                                                                      }
                                                                    ]
                                                                  },
                                                                  "400x500": {
                                                                    "anyOf": [
                                                                      {
                                                                        "minItems": 2,
                                                                        "maxItems": 2,
                                                                        "type": "array",
                                                                        "items": {
                                                                          "minItems": 2,
                                                                          "maxItems": 2,
                                                                          "type": "array",
                                                                          "items": {
                                                                            "type": "number"
                                                                          }
                                                                        }
                                                                      },
                                                                      {
                                                                        "type": "null"
                                                                      }
                                                                    ]
                                                                  }
                                                                }
                                                              },
                                                              {
                                                                "type": "null"
                                                              }
                                                            ]
                                                          },
                                                          "duration": {
                                                            "anyOf": [
                                                              {
                                                                "type": "number"
                                                              },
                                                              {
                                                                "type": "null"
                                                              }
                                                            ]
                                                          },
                                                          "fileSizeBytes": {
                                                            "anyOf": [
                                                              {
                                                                "type": "number"
                                                              },
                                                              {
                                                                "type": "null"
                                                              }
                                                            ]
                                                          },
                                                          "height": {
                                                            "anyOf": [
                                                              {
                                                                "type": "number"
                                                              },
                                                              {
                                                                "type": "null"
                                                              }
                                                            ]
                                                          },
                                                          "metaHash": {
                                                            "anyOf": [
                                                              {
                                                                "type": "string"
                                                              },
                                                              {
                                                                "type": "null"
                                                              }
                                                            ]
                                                          },
                                                          "metaVideoId": {
                                                            "anyOf": [
                                                              {
                                                                "type": "string"
                                                              },
                                                              {
                                                                "type": "null"
                                                              }
                                                            ]
                                                          },
                                                          "snapchatMediaId": {
                                                            "anyOf": [
                                                              {
                                                                "type": "string"
                                                              },
                                                              {
                                                                "type": "null"
                                                              }
                                                            ]
                                                          },
                                                          "sourceUrl": {
                                                            "anyOf": [
                                                              {
                                                                "type": "string"
                                                              },
                                                              {
                                                                "type": "null"
                                                              }
                                                            ]
                                                          },
                                                          "thumbnailUrl": {
                                                            "anyOf": [
                                                              {
                                                                "type": "string"
                                                              },
                                                              {
                                                                "type": "null"
                                                              }
                                                            ]
                                                          },
                                                          "tiktokVideoId": {
                                                            "anyOf": [
                                                              {
                                                                "type": "string"
                                                              },
                                                              {
                                                                "type": "null"
                                                              }
                                                            ]
                                                          },
                                                          "type": {
                                                            "anyOf": [
                                                              {
                                                                "anyOf": [
                                                                  {
                                                                    "type": "string",
                                                                    "enum": [
                                                                      "image"
                                                                    ]
                                                                  },
                                                                  {
                                                                    "type": "string",
                                                                    "enum": [
                                                                      "video"
                                                                    ]
                                                                  }
                                                                ]
                                                              },
                                                              {
                                                                "type": "null"
                                                              }
                                                            ]
                                                          },
                                                          "videoId": {
                                                            "anyOf": [
                                                              {
                                                                "type": "string"
                                                              },
                                                              {
                                                                "type": "null"
                                                              }
                                                            ]
                                                          },
                                                          "width": {
                                                            "anyOf": [
                                                              {
                                                                "type": "number"
                                                              },
                                                              {
                                                                "type": "null"
                                                              }
                                                            ]
                                                          }
                                                        }
                                                      },
                                                      {
                                                        "type": "null"
                                                      }
                                                    ]
                                                  },
                                                  "story": {
                                                    "anyOf": [
                                                      {
                                                        "additionalProperties": false,
                                                        "type": "object",
                                                        "properties": {
                                                          "aiGenerated": {
                                                            "anyOf": [
                                                              {
                                                                "type": "boolean"
                                                              },
                                                              {
                                                                "type": "null"
                                                              }
                                                            ]
                                                          },
                                                          "cardDescription": {
                                                            "anyOf": [
                                                              {
                                                                "type": "string"
                                                              },
                                                              {
                                                                "type": "null"
                                                              }
                                                            ]
                                                          },
                                                          "cardHeadline": {
                                                            "anyOf": [
                                                              {
                                                                "type": "string"
                                                              },
                                                              {
                                                                "type": "null"
                                                              }
                                                            ]
                                                          },
                                                          "crops": {
                                                            "anyOf": [
                                                              {
                                                                "additionalProperties": false,
                                                                "type": "object",
                                                                "properties": {
                                                                  "100x100": {
                                                                    "anyOf": [
                                                                      {
                                                                        "minItems": 2,
                                                                        "maxItems": 2,
                                                                        "type": "array",
                                                                        "items": {
                                                                          "minItems": 2,
                                                                          "maxItems": 2,
                                                                          "type": "array",
                                                                          "items": {
                                                                            "type": "number"
                                                                          }
                                                                        }
                                                                      },
                                                                      {
                                                                        "type": "null"
                                                                      }
                                                                    ]
                                                                  },
                                                                  "191x100": {
                                                                    "anyOf": [
                                                                      {
                                                                        "minItems": 2,
                                                                        "maxItems": 2,
                                                                        "type": "array",
                                                                        "items": {
                                                                          "minItems": 2,
                                                                          "maxItems": 2,
                                                                          "type": "array",
                                                                          "items": {
                                                                            "type": "number"
                                                                          }
                                                                        }
                                                                      },
                                                                      {
                                                                        "type": "null"
                                                                      }
                                                                    ]
                                                                  },
                                                                  "400x500": {
                                                                    "anyOf": [
                                                                      {
                                                                        "minItems": 2,
                                                                        "maxItems": 2,
                                                                        "type": "array",
                                                                        "items": {
                                                                          "minItems": 2,
                                                                          "maxItems": 2,
                                                                          "type": "array",
                                                                          "items": {
                                                                            "type": "number"
                                                                          }
                                                                        }
                                                                      },
                                                                      {
                                                                        "type": "null"
                                                                      }
                                                                    ]
                                                                  }
                                                                }
                                                              },
                                                              {
                                                                "type": "null"
                                                              }
                                                            ]
                                                          },
                                                          "duration": {
                                                            "anyOf": [
                                                              {
                                                                "type": "number"
                                                              },
                                                              {
                                                                "type": "null"
                                                              }
                                                            ]
                                                          },
                                                          "fileSizeBytes": {
                                                            "anyOf": [
                                                              {
                                                                "type": "number"
                                                              },
                                                              {
                                                                "type": "null"
                                                              }
                                                            ]
                                                          },
                                                          "height": {
                                                            "anyOf": [
                                                              {
                                                                "type": "number"
                                                              },
                                                              {
                                                                "type": "null"
                                                              }
                                                            ]
                                                          },
                                                          "metaHash": {
                                                            "anyOf": [
                                                              {
                                                                "type": "string"
                                                              },
                                                              {
                                                                "type": "null"
                                                              }
                                                            ]
                                                          },
                                                          "metaVideoId": {
                                                            "anyOf": [
                                                              {
                                                                "type": "string"
                                                              },
                                                              {
                                                                "type": "null"
                                                              }
                                                            ]
                                                          },
                                                          "snapchatMediaId": {
                                                            "anyOf": [
                                                              {
                                                                "type": "string"
                                                              },
                                                              {
                                                                "type": "null"
                                                              }
                                                            ]
                                                          },
                                                          "sourceUrl": {
                                                            "anyOf": [
                                                              {
                                                                "type": "string"
                                                              },
                                                              {
                                                                "type": "null"
                                                              }
                                                            ]
                                                          },
                                                          "thumbnailUrl": {
                                                            "anyOf": [
                                                              {
                                                                "type": "string"
                                                              },
                                                              {
                                                                "type": "null"
                                                              }
                                                            ]
                                                          },
                                                          "tiktokVideoId": {
                                                            "anyOf": [
                                                              {
                                                                "type": "string"
                                                              },
                                                              {
                                                                "type": "null"
                                                              }
                                                            ]
                                                          },
                                                          "type": {
                                                            "anyOf": [
                                                              {
                                                                "anyOf": [
                                                                  {
                                                                    "type": "string",
                                                                    "enum": [
                                                                      "image"
                                                                    ]
                                                                  },
                                                                  {
                                                                    "type": "string",
                                                                    "enum": [
                                                                      "video"
                                                                    ]
                                                                  }
                                                                ]
                                                              },
                                                              {
                                                                "type": "null"
                                                              }
                                                            ]
                                                          },
                                                          "videoId": {
                                                            "anyOf": [
                                                              {
                                                                "type": "string"
                                                              },
                                                              {
                                                                "type": "null"
                                                              }
                                                            ]
                                                          },
                                                          "width": {
                                                            "anyOf": [
                                                              {
                                                                "type": "number"
                                                              },
                                                              {
                                                                "type": "null"
                                                              }
                                                            ]
                                                          }
                                                        }
                                                      },
                                                      {
                                                        "type": "null"
                                                      }
                                                    ]
                                                  }
                                                }
                                              },
                                              {
                                                "type": "null"
                                              }
                                            ]
                                          },
                                          "placementCustomization": {
                                            "anyOf": [
                                              {
                                                "type": "boolean"
                                              },
                                              {
                                                "type": "null"
                                              }
                                            ]
                                          },
                                          "platformId": {
                                            "anyOf": [
                                              {
                                                "type": "string"
                                              },
                                              {
                                                "type": "null"
                                              }
                                            ]
                                          },
                                          "primaryText": {
                                            "anyOf": [
                                              {
                                                "type": "string"
                                              },
                                              {
                                                "type": "null"
                                              }
                                            ]
                                          },
                                          "primaryTextVariations": {
                                            "anyOf": [
                                              {
                                                "type": "array",
                                                "items": {
                                                  "type": "string"
                                                }
                                              },
                                              {
                                                "type": "null"
                                              }
                                            ]
                                          },
                                          "secondaryDescription": {
                                            "anyOf": [
                                              {
                                                "type": "string"
                                              },
                                              {
                                                "type": "null"
                                              }
                                            ]
                                          },
                                          "secondaryHeadline": {
                                            "anyOf": [
                                              {
                                                "type": "string"
                                              },
                                              {
                                                "type": "null"
                                              }
                                            ]
                                          },
                                          "secondaryLanguages": {
                                            "anyOf": [
                                              {
                                                "type": "array",
                                                "items": {
                                                  "type": "string"
                                                }
                                              },
                                              {
                                                "type": "null"
                                              }
                                            ]
                                          },
                                          "secondaryMedia": {
                                            "anyOf": [
                                              {
                                                "type": "array",
                                                "items": {
                                                  "additionalProperties": false,
                                                  "type": "object",
                                                  "properties": {
                                                    "aiGenerated": {
                                                      "anyOf": [
                                                        {
                                                          "type": "boolean"
                                                        },
                                                        {
                                                          "type": "null"
                                                        }
                                                      ]
                                                    },
                                                    "cardDescription": {
                                                      "anyOf": [
                                                        {
                                                          "type": "string"
                                                        },
                                                        {
                                                          "type": "null"
                                                        }
                                                      ]
                                                    },
                                                    "cardHeadline": {
                                                      "anyOf": [
                                                        {
                                                          "type": "string"
                                                        },
                                                        {
                                                          "type": "null"
                                                        }
                                                      ]
                                                    },
                                                    "crops": {
                                                      "anyOf": [
                                                        {
                                                          "additionalProperties": false,
                                                          "type": "object",
                                                          "properties": {
                                                            "100x100": {
                                                              "anyOf": [
                                                                {
                                                                  "minItems": 2,
                                                                  "maxItems": 2,
                                                                  "type": "array",
                                                                  "items": {
                                                                    "minItems": 2,
                                                                    "maxItems": 2,
                                                                    "type": "array",
                                                                    "items": {
                                                                      "type": "number"
                                                                    }
                                                                  }
                                                                },
                                                                {
                                                                  "type": "null"
                                                                }
                                                              ]
                                                            },
                                                            "191x100": {
                                                              "anyOf": [
                                                                {
                                                                  "minItems": 2,
                                                                  "maxItems": 2,
                                                                  "type": "array",
                                                                  "items": {
                                                                    "minItems": 2,
                                                                    "maxItems": 2,
                                                                    "type": "array",
                                                                    "items": {
                                                                      "type": "number"
                                                                    }
                                                                  }
                                                                },
                                                                {
                                                                  "type": "null"
                                                                }
                                                              ]
                                                            },
                                                            "400x500": {
                                                              "anyOf": [
                                                                {
                                                                  "minItems": 2,
                                                                  "maxItems": 2,
                                                                  "type": "array",
                                                                  "items": {
                                                                    "minItems": 2,
                                                                    "maxItems": 2,
                                                                    "type": "array",
                                                                    "items": {
                                                                      "type": "number"
                                                                    }
                                                                  }
                                                                },
                                                                {
                                                                  "type": "null"
                                                                }
                                                              ]
                                                            }
                                                          }
                                                        },
                                                        {
                                                          "type": "null"
                                                        }
                                                      ]
                                                    },
                                                    "duration": {
                                                      "anyOf": [
                                                        {
                                                          "type": "number"
                                                        },
                                                        {
                                                          "type": "null"
                                                        }
                                                      ]
                                                    },
                                                    "fileSizeBytes": {
                                                      "anyOf": [
                                                        {
                                                          "type": "number"
                                                        },
                                                        {
                                                          "type": "null"
                                                        }
                                                      ]
                                                    },
                                                    "height": {
                                                      "anyOf": [
                                                        {
                                                          "type": "number"
                                                        },
                                                        {
                                                          "type": "null"
                                                        }
                                                      ]
                                                    },
                                                    "metaHash": {
                                                      "anyOf": [
                                                        {
                                                          "type": "string"
                                                        },
                                                        {
                                                          "type": "null"
                                                        }
                                                      ]
                                                    },
                                                    "metaVideoId": {
                                                      "anyOf": [
                                                        {
                                                          "type": "string"
                                                        },
                                                        {
                                                          "type": "null"
                                                        }
                                                      ]
                                                    },
                                                    "snapchatMediaId": {
                                                      "anyOf": [
                                                        {
                                                          "type": "string"
                                                        },
                                                        {
                                                          "type": "null"
                                                        }
                                                      ]
                                                    },
                                                    "sourceUrl": {
                                                      "anyOf": [
                                                        {
                                                          "type": "string"
                                                        },
                                                        {
                                                          "type": "null"
                                                        }
                                                      ]
                                                    },
                                                    "thumbnailUrl": {
                                                      "anyOf": [
                                                        {
                                                          "type": "string"
                                                        },
                                                        {
                                                          "type": "null"
                                                        }
                                                      ]
                                                    },
                                                    "tiktokVideoId": {
                                                      "anyOf": [
                                                        {
                                                          "type": "string"
                                                        },
                                                        {
                                                          "type": "null"
                                                        }
                                                      ]
                                                    },
                                                    "type": {
                                                      "anyOf": [
                                                        {
                                                          "anyOf": [
                                                            {
                                                              "type": "string",
                                                              "enum": [
                                                                "image"
                                                              ]
                                                            },
                                                            {
                                                              "type": "string",
                                                              "enum": [
                                                                "video"
                                                              ]
                                                            }
                                                          ]
                                                        },
                                                        {
                                                          "type": "null"
                                                        }
                                                      ]
                                                    },
                                                    "videoId": {
                                                      "anyOf": [
                                                        {
                                                          "type": "string"
                                                        },
                                                        {
                                                          "type": "null"
                                                        }
                                                      ]
                                                    },
                                                    "width": {
                                                      "anyOf": [
                                                        {
                                                          "type": "number"
                                                        },
                                                        {
                                                          "type": "null"
                                                        }
                                                      ]
                                                    }
                                                  }
                                                }
                                              },
                                              {
                                                "type": "null"
                                              }
                                            ]
                                          },
                                          "secondaryPrimaryText": {
                                            "anyOf": [
                                              {
                                                "type": "string"
                                              },
                                              {
                                                "type": "null"
                                              }
                                            ]
                                          },
                                          "secondaryUrl": {
                                            "anyOf": [
                                              {
                                                "type": "string"
                                              },
                                              {
                                                "type": "null"
                                              }
                                            ]
                                          },
                                          "snapchatAdDisclaimer": {
                                            "anyOf": [
                                              {
                                                "type": "string"
                                              },
                                              {
                                                "type": "null"
                                              }
                                            ]
                                          },
                                          "snapchatAdFavoriting": {
                                            "anyOf": [
                                              {
                                                "type": "boolean"
                                              },
                                              {
                                                "type": "null"
                                              }
                                            ]
                                          },
                                          "snapchatAdType": {
                                            "anyOf": [
                                              {
                                                "type": "string"
                                              },
                                              {
                                                "type": "null"
                                              }
                                            ]
                                          },
                                          "snapchatAppIconMediaId": {
                                            "anyOf": [
                                              {
                                                "type": "string"
                                              },
                                              {
                                                "type": "null"
                                              }
                                            ]
                                          },
                                          "snapchatBrandName": {
                                            "anyOf": [
                                              {
                                                "type": "string"
                                              },
                                              {
                                                "type": "null"
                                              }
                                            ]
                                          },
                                          "snapchatDeepLinkUri": {
                                            "anyOf": [
                                              {
                                                "type": "string"
                                              },
                                              {
                                                "type": "null"
                                              }
                                            ]
                                          },
                                          "snapchatMessageText": {
                                            "anyOf": [
                                              {
                                                "type": "string"
                                              },
                                              {
                                                "type": "null"
                                              }
                                            ]
                                          },
                                          "snapchatPhoneNumberId": {
                                            "anyOf": [
                                              {
                                                "type": "string"
                                              },
                                              {
                                                "type": "null"
                                              }
                                            ]
                                          },
                                          "snapchatShareable": {
                                            "anyOf": [
                                              {
                                                "type": "boolean"
                                              },
                                              {
                                                "type": "null"
                                              }
                                            ]
                                          },
                                          "snapchatSmartPrefetching": {
                                            "anyOf": [
                                              {
                                                "type": "boolean"
                                              },
                                              {
                                                "type": "null"
                                              }
                                            ]
                                          },
                                          "status": {
                                            "anyOf": [
                                              {
                                                "anyOf": [
                                                  {
                                                    "type": "string",
                                                    "enum": [
                                                      "ACTIVE"
                                                    ]
                                                  },
                                                  {
                                                    "type": "string",
                                                    "enum": [
                                                      "PAUSED"
                                                    ]
                                                  }
                                                ]
                                              },
                                              {
                                                "type": "null"
                                              }
                                            ]
                                          },
                                          "taboolaCta": {
                                            "anyOf": [
                                              {
                                                "type": "string"
                                              },
                                              {
                                                "type": "null"
                                              }
                                            ]
                                          },
                                          "taboolaHeadlines": {
                                            "anyOf": [
                                              {
                                                "type": "array",
                                                "items": {
                                                  "type": "string"
                                                }
                                              },
                                              {
                                                "type": "null"
                                              }
                                            ]
                                          },
                                          "targetLanguage": {
                                            "anyOf": [
                                              {
                                                "type": "string"
                                              },
                                              {
                                                "type": "null"
                                              }
                                            ]
                                          },
                                          "unmatchedAudienceVideo": {
                                            "anyOf": [
                                              {
                                                "anyOf": [
                                                  {
                                                    "type": "string",
                                                    "enum": [
                                                      "safe"
                                                    ]
                                                  },
                                                  {
                                                    "type": "string",
                                                    "enum": [
                                                      "targeted"
                                                    ]
                                                  }
                                                ]
                                              },
                                              {
                                                "type": "null"
                                              }
                                            ]
                                          },
                                          "url": {
                                            "anyOf": [
                                              {
                                                "type": "string"
                                              },
                                              {
                                                "type": "null"
                                              }
                                            ]
                                          },
                                          "urlParameters": {
                                            "anyOf": [
                                              {
                                                "type": "string"
                                              },
                                              {
                                                "type": "null"
                                              }
                                            ]
                                          }
                                        }
                                      }
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "attribution": {
                                  "anyOf": [
                                    {
                                      "additionalProperties": false,
                                      "type": "object",
                                      "properties": {
                                        "clickWindow": {
                                          "anyOf": [
                                            {
                                              "anyOf": [
                                                {
                                                  "type": "number",
                                                  "enum": [
                                                    1
                                                  ]
                                                },
                                                {
                                                  "type": "number",
                                                  "enum": [
                                                    7
                                                  ]
                                                }
                                              ]
                                            },
                                            {
                                              "type": "null"
                                            }
                                          ]
                                        },
                                        "viewWindow": {
                                          "anyOf": [
                                            {
                                              "anyOf": [
                                                {
                                                  "type": "number",
                                                  "enum": [
                                                    0
                                                  ]
                                                },
                                                {
                                                  "type": "number",
                                                  "enum": [
                                                    1
                                                  ]
                                                }
                                              ]
                                            },
                                            {
                                              "type": "null"
                                            }
                                          ]
                                        }
                                      }
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "bidAmount": {
                                  "anyOf": [
                                    {
                                      "type": "number"
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "billingEvent": {
                                  "anyOf": [
                                    {
                                      "type": "string"
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "budget": {
                                  "anyOf": [
                                    {
                                      "type": "number"
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "budgetType": {
                                  "anyOf": [
                                    {
                                      "anyOf": [
                                        {
                                          "type": "string",
                                          "enum": [
                                            "DAILY"
                                          ]
                                        },
                                        {
                                          "type": "string",
                                          "enum": [
                                            "LIFETIME"
                                          ]
                                        }
                                      ]
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "customAudiences": {
                                  "anyOf": [
                                    {
                                      "type": "array",
                                      "items": {
                                        "type": "string"
                                      }
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "destinationType": {
                                  "anyOf": [
                                    {
                                      "type": "string"
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "dsaFields": {
                                  "anyOf": [
                                    {
                                      "additionalProperties": false,
                                      "type": "object",
                                      "properties": {
                                        "beneficiary": {
                                          "anyOf": [
                                            {
                                              "type": "string"
                                            },
                                            {
                                              "type": "null"
                                            }
                                          ]
                                        },
                                        "payer": {
                                          "anyOf": [
                                            {
                                              "type": "string"
                                            },
                                            {
                                              "type": "null"
                                            }
                                          ]
                                        }
                                      }
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "endDate": {
                                  "anyOf": [
                                    {
                                      "type": "string"
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "endTime": {
                                  "anyOf": [
                                    {
                                      "type": "string"
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "excludedAudiences": {
                                  "anyOf": [
                                    {
                                      "type": "array",
                                      "items": {
                                        "type": "string"
                                      }
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "id": {
                                  "anyOf": [
                                    {
                                      "type": "string"
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "keywords": {
                                  "anyOf": [
                                    {
                                      "type": "string"
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "metaLeadFormId": {
                                  "anyOf": [
                                    {
                                      "type": "string"
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "name": {
                                  "anyOf": [
                                    {
                                      "type": "string"
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "optimizationGoal": {
                                  "anyOf": [
                                    {
                                      "type": "string"
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "placements": {
                                  "anyOf": [
                                    {
                                      "additionalProperties": false,
                                      "type": "object",
                                      "properties": {
                                        "audienceNetworkPositions": {
                                          "anyOf": [
                                            {
                                              "type": "array",
                                              "items": {
                                                "type": "string"
                                              }
                                            },
                                            {
                                              "type": "null"
                                            }
                                          ]
                                        },
                                        "automatic": {
                                          "anyOf": [
                                            {
                                              "type": "boolean"
                                            },
                                            {
                                              "type": "null"
                                            }
                                          ]
                                        },
                                        "facebookPositions": {
                                          "anyOf": [
                                            {
                                              "type": "array",
                                              "items": {
                                                "type": "string"
                                              }
                                            },
                                            {
                                              "type": "null"
                                            }
                                          ]
                                        },
                                        "instagramPositions": {
                                          "anyOf": [
                                            {
                                              "type": "array",
                                              "items": {
                                                "type": "string"
                                              }
                                            },
                                            {
                                              "type": "null"
                                            }
                                          ]
                                        },
                                        "messengerPositions": {
                                          "anyOf": [
                                            {
                                              "type": "array",
                                              "items": {
                                                "type": "string"
                                              }
                                            },
                                            {
                                              "type": "null"
                                            }
                                          ]
                                        },
                                        "publisherPlatforms": {
                                          "anyOf": [
                                            {
                                              "type": "array",
                                              "items": {
                                                "anyOf": [
                                                  {
                                                    "type": "string",
                                                    "enum": [
                                                      "facebook"
                                                    ]
                                                  },
                                                  {
                                                    "type": "string",
                                                    "enum": [
                                                      "instagram"
                                                    ]
                                                  },
                                                  {
                                                    "type": "string",
                                                    "enum": [
                                                      "audience_network"
                                                    ]
                                                  },
                                                  {
                                                    "type": "string",
                                                    "enum": [
                                                      "messenger"
                                                    ]
                                                  },
                                                  {
                                                    "type": "string",
                                                    "enum": [
                                                      "threads"
                                                    ]
                                                  }
                                                ]
                                              }
                                            },
                                            {
                                              "type": "null"
                                            }
                                          ]
                                        },
                                        "snapchatBrandSuitability": {
                                          "anyOf": [
                                            {
                                              "type": "string"
                                            },
                                            {
                                              "type": "null"
                                            }
                                          ]
                                        },
                                        "snapchatConfig": {
                                          "anyOf": [
                                            {
                                              "type": "string"
                                            },
                                            {
                                              "type": "null"
                                            }
                                          ]
                                        },
                                        "snapchatCustomType": {
                                          "anyOf": [
                                            {
                                              "type": "string"
                                            },
                                            {
                                              "type": "null"
                                            }
                                          ]
                                        },
                                        "snapchatPositions": {
                                          "anyOf": [
                                            {
                                              "type": "array",
                                              "items": {
                                                "type": "string"
                                              }
                                            },
                                            {
                                              "type": "null"
                                            }
                                          ]
                                        },
                                        "threadsPositions": {
                                          "anyOf": [
                                            {
                                              "type": "array",
                                              "items": {
                                                "type": "string"
                                              }
                                            },
                                            {
                                              "type": "null"
                                            }
                                          ]
                                        }
                                      }
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "platformId": {
                                  "anyOf": [
                                    {
                                      "type": "string"
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "promotedObject": {
                                  "anyOf": [
                                    {
                                      "additionalProperties": false,
                                      "type": "object",
                                      "properties": {
                                        "appId": {
                                          "anyOf": [
                                            {
                                              "type": "string"
                                            },
                                            {
                                              "type": "null"
                                            }
                                          ]
                                        },
                                        "catalogId": {
                                          "anyOf": [
                                            {
                                              "type": "string"
                                            },
                                            {
                                              "type": "null"
                                            }
                                          ]
                                        },
                                        "customEventType": {
                                          "anyOf": [
                                            {
                                              "type": "string"
                                            },
                                            {
                                              "type": "null"
                                            }
                                          ]
                                        },
                                        "objectStoreUrl": {
                                          "anyOf": [
                                            {
                                              "type": "string"
                                            },
                                            {
                                              "type": "null"
                                            }
                                          ]
                                        },
                                        "pageId": {
                                          "anyOf": [
                                            {
                                              "type": "string"
                                            },
                                            {
                                              "type": "null"
                                            }
                                          ]
                                        },
                                        "pixelId": {
                                          "anyOf": [
                                            {
                                              "type": "string"
                                            },
                                            {
                                              "type": "null"
                                            }
                                          ]
                                        },
                                        "productSetId": {
                                          "anyOf": [
                                            {
                                              "type": "string"
                                            },
                                            {
                                              "type": "null"
                                            }
                                          ]
                                        }
                                      }
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "roasFloor": {
                                  "anyOf": [
                                    {
                                      "type": "number"
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "snapchatAppId": {
                                  "anyOf": [
                                    {
                                      "type": "string"
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "snapchatAudienceType": {
                                  "anyOf": [
                                    {
                                      "anyOf": [
                                        {
                                          "type": "string",
                                          "enum": [
                                            "PROSPECTING"
                                          ]
                                        },
                                        {
                                          "type": "string",
                                          "enum": [
                                            "RETARGETING"
                                          ]
                                        }
                                      ]
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "snapchatCatalogId": {
                                  "anyOf": [
                                    {
                                      "type": "string"
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "snapchatConversionLocation": {
                                  "anyOf": [
                                    {
                                      "type": "string"
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "snapchatLeadFormId": {
                                  "anyOf": [
                                    {
                                      "type": "string"
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "snapchatPixelId": {
                                  "anyOf": [
                                    {
                                      "type": "string"
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "snapchatProductSetId": {
                                  "anyOf": [
                                    {
                                      "type": "string"
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "spendPercent": {
                                  "anyOf": [
                                    {
                                      "minimum": 1,
                                      "maximum": 100,
                                      "type": "number"
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "startDate": {
                                  "anyOf": [
                                    {
                                      "type": "string"
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "startTime": {
                                  "anyOf": [
                                    {
                                      "type": "string"
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "status": {
                                  "anyOf": [
                                    {
                                      "anyOf": [
                                        {
                                          "type": "string",
                                          "enum": [
                                            "ACTIVE"
                                          ]
                                        },
                                        {
                                          "type": "string",
                                          "enum": [
                                            "PAUSED"
                                          ]
                                        }
                                      ]
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "targeting": {
                                  "anyOf": [
                                    {
                                      "additionalProperties": false,
                                      "type": "object",
                                      "properties": {
                                        "advantageAge": {
                                          "anyOf": [
                                            {
                                              "type": "boolean"
                                            },
                                            {
                                              "type": "null"
                                            }
                                          ]
                                        },
                                        "advantageAudience": {
                                          "anyOf": [
                                            {
                                              "type": "boolean"
                                            },
                                            {
                                              "type": "null"
                                            }
                                          ]
                                        },
                                        "advantageDetailedTargeting": {
                                          "anyOf": [
                                            {
                                              "type": "boolean"
                                            },
                                            {
                                              "type": "null"
                                            }
                                          ]
                                        },
                                        "advantageGender": {
                                          "anyOf": [
                                            {
                                              "type": "boolean"
                                            },
                                            {
                                              "type": "null"
                                            }
                                          ]
                                        },
                                        "advantageLookalike": {
                                          "anyOf": [
                                            {
                                              "type": "boolean"
                                            },
                                            {
                                              "type": "null"
                                            }
                                          ]
                                        },
                                        "ageMax": {
                                          "anyOf": [
                                            {
                                              "type": "number"
                                            },
                                            {
                                              "type": "null"
                                            }
                                          ]
                                        },
                                        "ageMin": {
                                          "anyOf": [
                                            {
                                              "type": "number"
                                            },
                                            {
                                              "type": "null"
                                            }
                                          ]
                                        },
                                        "countries": {
                                          "anyOf": [
                                            {
                                              "type": "array",
                                              "items": {
                                                "type": "string"
                                              }
                                            },
                                            {
                                              "type": "null"
                                            }
                                          ]
                                        },
                                        "devicePlatforms": {
                                          "anyOf": [
                                            {
                                              "type": "array",
                                              "items": {
                                                "anyOf": [
                                                  {
                                                    "type": "string",
                                                    "enum": [
                                                      "mobile"
                                                    ]
                                                  },
                                                  {
                                                    "type": "string",
                                                    "enum": [
                                                      "desktop"
                                                    ]
                                                  }
                                                ]
                                              }
                                            },
                                            {
                                              "type": "null"
                                            }
                                          ]
                                        },
                                        "genders": {
                                          "anyOf": [
                                            {
                                              "type": "array",
                                              "items": {
                                                "type": "number"
                                              }
                                            },
                                            {
                                              "type": "null"
                                            }
                                          ]
                                        },
                                        "locales": {
                                          "anyOf": [
                                            {
                                              "type": "array",
                                              "items": {
                                                "type": "number"
                                              }
                                            },
                                            {
                                              "type": "null"
                                            }
                                          ]
                                        },
                                        "locations": {
                                          "anyOf": [
                                            {
                                              "type": "array",
                                              "items": {
                                                "additionalProperties": false,
                                                "type": "object",
                                                "required": [
                                                  "countryCode",
                                                  "key",
                                                  "name",
                                                  "type"
                                                ],
                                                "properties": {
                                                  "countryCode": {
                                                    "type": "string"
                                                  },
                                                  "distanceUnit": {
                                                    "anyOf": [
                                                      {
                                                        "type": "string"
                                                      },
                                                      {
                                                        "type": "null"
                                                      }
                                                    ]
                                                  },
                                                  "key": {
                                                    "type": "string"
                                                  },
                                                  "name": {
                                                    "type": "string"
                                                  },
                                                  "radius": {
                                                    "anyOf": [
                                                      {
                                                        "minimum": 10,
                                                        "maximum": 80,
                                                        "type": "number"
                                                      },
                                                      {
                                                        "type": "null"
                                                      }
                                                    ]
                                                  },
                                                  "region": {
                                                    "anyOf": [
                                                      {
                                                        "type": "string"
                                                      },
                                                      {
                                                        "type": "null"
                                                      }
                                                    ]
                                                  },
                                                  "type": {
                                                    "anyOf": [
                                                      {
                                                        "type": "string",
                                                        "enum": [
                                                          "region"
                                                        ]
                                                      },
                                                      {
                                                        "type": "string",
                                                        "enum": [
                                                          "city"
                                                        ]
                                                      }
                                                    ]
                                                  }
                                                }
                                              }
                                            },
                                            {
                                              "type": "null"
                                            }
                                          ]
                                        },
                                        "operatingSystems": {
                                          "anyOf": [
                                            {
                                              "type": "array",
                                              "items": {
                                                "type": "string"
                                              }
                                            },
                                            {
                                              "type": "null"
                                            }
                                          ]
                                        }
                                      }
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                }
                              }
                            }
                          },
                          {
                            "type": "null"
                          }
                        ]
                      },
                      "campaign": {
                        "anyOf": [
                          {
                            "additionalProperties": false,
                            "type": "object",
                            "properties": {
                              "acceleratedDelivery": {
                                "anyOf": [
                                  {
                                    "type": "boolean"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "advantagePlus": {
                                "anyOf": [
                                  {
                                    "type": "boolean"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "bidStrategy": {
                                "anyOf": [
                                  {
                                    "type": "string"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "budget": {
                                "anyOf": [
                                  {
                                    "type": "number"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "budgetLevel": {
                                "anyOf": [
                                  {
                                    "anyOf": [
                                      {
                                        "type": "string",
                                        "enum": [
                                          "CBO"
                                        ]
                                      },
                                      {
                                        "type": "string",
                                        "enum": [
                                          "ABO"
                                        ]
                                      }
                                    ]
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "budgetType": {
                                "anyOf": [
                                  {
                                    "anyOf": [
                                      {
                                        "type": "string",
                                        "enum": [
                                          "DAILY"
                                        ]
                                      },
                                      {
                                        "type": "string",
                                        "enum": [
                                          "LIFETIME"
                                        ]
                                      }
                                    ]
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "buyingType": {
                                "anyOf": [
                                  {
                                    "anyOf": [
                                      {
                                        "type": "string",
                                        "enum": [
                                          "AUCTION"
                                        ]
                                      },
                                      {
                                        "type": "string",
                                        "enum": [
                                          "RESERVED"
                                        ]
                                      }
                                    ]
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "customerAcquisition": {
                                "anyOf": [
                                  {
                                    "type": "boolean"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "googleGoal": {
                                "anyOf": [
                                  {
                                    "anyOf": [
                                      {
                                        "type": "string",
                                        "enum": [
                                          "SALES"
                                        ]
                                      },
                                      {
                                        "type": "string",
                                        "enum": [
                                          "LEADS"
                                        ]
                                      },
                                      {
                                        "type": "string",
                                        "enum": [
                                          "WEBSITE_TRAFFIC"
                                        ]
                                      },
                                      {
                                        "type": "string",
                                        "enum": [
                                          "APP_PROMOTION"
                                        ]
                                      },
                                      {
                                        "type": "string",
                                        "enum": [
                                          "AWARENESS"
                                        ]
                                      },
                                      {
                                        "type": "string",
                                        "enum": [
                                          "LOCAL_STORE"
                                        ]
                                      },
                                      {
                                        "type": "string",
                                        "enum": [
                                          "NO_GOAL"
                                        ]
                                      }
                                    ]
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "googleMerchantId": {
                                "anyOf": [
                                  {
                                    "type": "string"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "metaLeadFormId": {
                                "anyOf": [
                                  {
                                    "type": "string"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "metaTokenId": {
                                "anyOf": [
                                  {
                                    "type": "string"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "name": {
                                "anyOf": [
                                  {
                                    "type": "string"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "objective": {
                                "anyOf": [
                                  {
                                    "type": "string"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "outbrainBudgetPacing": {
                                "anyOf": [
                                  {
                                    "anyOf": [
                                      {
                                        "type": "string",
                                        "enum": [
                                          "DAILY"
                                        ]
                                      },
                                      {
                                        "type": "string",
                                        "enum": [
                                          "MONTHLY"
                                        ]
                                      },
                                      {
                                        "type": "string",
                                        "enum": [
                                          "ENTIRE"
                                        ]
                                      }
                                    ]
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "outbrainConversionGoalId": {
                                "anyOf": [
                                  {
                                    "type": "string"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "outbrainCpcCents": {
                                "anyOf": [
                                  {
                                    "type": "number"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "outbrainCurrency": {
                                "anyOf": [
                                  {
                                    "type": "string"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "outbrainDailyBudgetCents": {
                                "anyOf": [
                                  {
                                    "type": "number"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "outbrainDayparting": {
                                "anyOf": [
                                  {
                                    "additionalProperties": false,
                                    "type": "object",
                                    "properties": {
                                      "FRIDAY": {
                                        "anyOf": [
                                          {
                                            "type": "array",
                                            "items": {
                                              "minimum": 0,
                                              "maximum": 23,
                                              "type": "integer"
                                            }
                                          },
                                          {
                                            "type": "null"
                                          }
                                        ]
                                      },
                                      "MONDAY": {
                                        "anyOf": [
                                          {
                                            "type": "array",
                                            "items": {
                                              "minimum": 0,
                                              "maximum": 23,
                                              "type": "integer"
                                            }
                                          },
                                          {
                                            "type": "null"
                                          }
                                        ]
                                      },
                                      "SATURDAY": {
                                        "anyOf": [
                                          {
                                            "type": "array",
                                            "items": {
                                              "minimum": 0,
                                              "maximum": 23,
                                              "type": "integer"
                                            }
                                          },
                                          {
                                            "type": "null"
                                          }
                                        ]
                                      },
                                      "SUNDAY": {
                                        "anyOf": [
                                          {
                                            "type": "array",
                                            "items": {
                                              "minimum": 0,
                                              "maximum": 23,
                                              "type": "integer"
                                            }
                                          },
                                          {
                                            "type": "null"
                                          }
                                        ]
                                      },
                                      "THURSDAY": {
                                        "anyOf": [
                                          {
                                            "type": "array",
                                            "items": {
                                              "minimum": 0,
                                              "maximum": 23,
                                              "type": "integer"
                                            }
                                          },
                                          {
                                            "type": "null"
                                          }
                                        ]
                                      },
                                      "TUESDAY": {
                                        "anyOf": [
                                          {
                                            "type": "array",
                                            "items": {
                                              "minimum": 0,
                                              "maximum": 23,
                                              "type": "integer"
                                            }
                                          },
                                          {
                                            "type": "null"
                                          }
                                        ]
                                      },
                                      "WEDNESDAY": {
                                        "anyOf": [
                                          {
                                            "type": "array",
                                            "items": {
                                              "minimum": 0,
                                              "maximum": 23,
                                              "type": "integer"
                                            }
                                          },
                                          {
                                            "type": "null"
                                          }
                                        ]
                                      }
                                    }
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "outbrainEndDate": {
                                "anyOf": [
                                  {
                                    "type": "string"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "outbrainStartDate": {
                                "anyOf": [
                                  {
                                    "type": "string"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "outbrainTargeting": {
                                "anyOf": [
                                  {
                                    "additionalProperties": false,
                                    "type": "object",
                                    "properties": {
                                      "browsers": {
                                        "anyOf": [
                                          {
                                            "type": "array",
                                            "items": {
                                              "type": "string"
                                            }
                                          },
                                          {
                                            "type": "null"
                                          }
                                        ]
                                      },
                                      "countries": {
                                        "anyOf": [
                                          {
                                            "type": "array",
                                            "items": {
                                              "type": "string"
                                            }
                                          },
                                          {
                                            "type": "null"
                                          }
                                        ]
                                      },
                                      "custom_audiences": {
                                        "anyOf": [
                                          {
                                            "type": "array",
                                            "items": {
                                              "type": "string"
                                            }
                                          },
                                          {
                                            "type": "null"
                                          }
                                        ]
                                      },
                                      "iab_categories": {
                                        "anyOf": [
                                          {
                                            "type": "array",
                                            "items": {
                                              "type": "string"
                                            }
                                          },
                                          {
                                            "type": "null"
                                          }
                                        ]
                                      },
                                      "languages": {
                                        "anyOf": [
                                          {
                                            "type": "array",
                                            "items": {
                                              "type": "string"
                                            }
                                          },
                                          {
                                            "type": "null"
                                          }
                                        ]
                                      },
                                      "operating_systems": {
                                        "anyOf": [
                                          {
                                            "type": "array",
                                            "items": {
                                              "type": "string"
                                            }
                                          },
                                          {
                                            "type": "null"
                                          }
                                        ]
                                      },
                                      "platforms": {
                                        "anyOf": [
                                          {
                                            "type": "array",
                                            "items": {
                                              "type": "string"
                                            }
                                          },
                                          {
                                            "type": "null"
                                          }
                                        ]
                                      },
                                      "sections": {
                                        "anyOf": [
                                          {
                                            "additionalProperties": false,
                                            "type": "object",
                                            "properties": {
                                              "exclude": {
                                                "anyOf": [
                                                  {
                                                    "type": "array",
                                                    "items": {
                                                      "type": "string"
                                                    }
                                                  },
                                                  {
                                                    "type": "null"
                                                  }
                                                ]
                                              },
                                              "include": {
                                                "anyOf": [
                                                  {
                                                    "type": "array",
                                                    "items": {
                                                      "type": "string"
                                                    }
                                                  },
                                                  {
                                                    "type": "null"
                                                  }
                                                ]
                                              }
                                            }
                                          },
                                          {
                                            "type": "null"
                                          }
                                        ]
                                      }
                                    }
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "reachGoals": {
                                "anyOf": [
                                  {
                                    "additionalProperties": false,
                                    "type": "object",
                                    "properties": {
                                      "phoneCall": {
                                        "anyOf": [
                                          {
                                            "type": "boolean"
                                          },
                                          {
                                            "type": "null"
                                          }
                                        ]
                                      },
                                      "storeVisit": {
                                        "anyOf": [
                                          {
                                            "type": "boolean"
                                          },
                                          {
                                            "type": "null"
                                          }
                                        ]
                                      },
                                      "websiteVisit": {
                                        "anyOf": [
                                          {
                                            "type": "boolean"
                                          },
                                          {
                                            "type": "null"
                                          }
                                        ]
                                      }
                                    }
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "snapchatDynamicAds": {
                                "anyOf": [
                                  {
                                    "type": "boolean"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "snapchatLifetimeSpendCap": {
                                "anyOf": [
                                  {
                                    "type": "number"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "snapchatMobileApp": {
                                "anyOf": [
                                  {
                                    "additionalProperties": false,
                                    "type": "object",
                                    "properties": {
                                      "android_app_url": {
                                        "anyOf": [
                                          {
                                            "type": "string"
                                          },
                                          {
                                            "type": "null"
                                          }
                                        ]
                                      },
                                      "app_name": {
                                        "anyOf": [
                                          {
                                            "type": "string"
                                          },
                                          {
                                            "type": "null"
                                          }
                                        ]
                                      },
                                      "ios_app_id": {
                                        "anyOf": [
                                          {
                                            "type": "string"
                                          },
                                          {
                                            "type": "null"
                                          }
                                        ]
                                      }
                                    }
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "snapchatPromotionType": {
                                "anyOf": [
                                  {
                                    "anyOf": [
                                      {
                                        "type": "string",
                                        "enum": [
                                          "APP_INSTALL"
                                        ]
                                      },
                                      {
                                        "type": "string",
                                        "enum": [
                                          "APP_REENGAGEMENT"
                                        ]
                                      }
                                    ]
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "snapchatPublicProfileId": {
                                "anyOf": [
                                  {
                                    "type": "string"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "specialAdCategories": {
                                "anyOf": [
                                  {
                                    "type": "array",
                                    "items": {
                                      "anyOf": [
                                        {
                                          "type": "string",
                                          "enum": [
                                            "NONE"
                                          ]
                                        },
                                        {
                                          "type": "string",
                                          "enum": [
                                            "HOUSING"
                                          ]
                                        },
                                        {
                                          "type": "string",
                                          "enum": [
                                            "EMPLOYMENT"
                                          ]
                                        },
                                        {
                                          "type": "string",
                                          "enum": [
                                            "CREDIT"
                                          ]
                                        },
                                        {
                                          "type": "string",
                                          "enum": [
                                            "ISSUES_ELECTIONS_POLITICS"
                                          ]
                                        },
                                        {
                                          "type": "string",
                                          "enum": [
                                            "ONLINE_GAMBLING_AND_GAMING"
                                          ]
                                        }
                                      ]
                                    }
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "status": {
                                "anyOf": [
                                  {
                                    "anyOf": [
                                      {
                                        "type": "string",
                                        "enum": [
                                          "ACTIVE"
                                        ]
                                      },
                                      {
                                        "type": "string",
                                        "enum": [
                                          "PAUSED"
                                        ]
                                      }
                                    ]
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "taboolaBidStrategy": {
                                "anyOf": [
                                  {
                                    "anyOf": [
                                      {
                                        "type": "string",
                                        "enum": [
                                          "FIXED"
                                        ]
                                      },
                                      {
                                        "type": "string",
                                        "enum": [
                                          "TARGET_CPA"
                                        ]
                                      }
                                    ]
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "taboolaBrandingText": {
                                "anyOf": [
                                  {
                                    "type": "string"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "taboolaCpaGoal": {
                                "anyOf": [
                                  {
                                    "type": "number"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "taboolaCpc": {
                                "anyOf": [
                                  {
                                    "type": "number"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "taboolaDailyCap": {
                                "anyOf": [
                                  {
                                    "type": "number"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "taboolaPricingModel": {
                                "anyOf": [
                                  {
                                    "type": "string"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "taboolaSpendingLimit": {
                                "anyOf": [
                                  {
                                    "type": "number"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "taboolaSpendingLimitType": {
                                "anyOf": [
                                  {
                                    "anyOf": [
                                      {
                                        "type": "string",
                                        "enum": [
                                          "MONTHLY"
                                        ]
                                      },
                                      {
                                        "type": "string",
                                        "enum": [
                                          "ENTIRE"
                                        ]
                                      }
                                    ]
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "tiktokAppId": {
                                "anyOf": [
                                  {
                                    "type": "string"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "tiktokBidAmount": {
                                "anyOf": [
                                  {
                                    "type": "number"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "tiktokBidType": {
                                "anyOf": [
                                  {
                                    "anyOf": [
                                      {
                                        "type": "string",
                                        "enum": [
                                          "BID_TYPE_CUSTOM"
                                        ]
                                      },
                                      {
                                        "type": "string",
                                        "enum": [
                                          "BID_TYPE_NO_BID"
                                        ]
                                      }
                                    ]
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "tiktokBillingEvent": {
                                "anyOf": [
                                  {
                                    "anyOf": [
                                      {
                                        "type": "string",
                                        "enum": [
                                          "CPM"
                                        ]
                                      },
                                      {
                                        "type": "string",
                                        "enum": [
                                          "OCPM"
                                        ]
                                      },
                                      {
                                        "type": "string",
                                        "enum": [
                                          "CPC"
                                        ]
                                      },
                                      {
                                        "type": "string",
                                        "enum": [
                                          "CPV"
                                        ]
                                      }
                                    ]
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "tiktokCatalogId": {
                                "anyOf": [
                                  {
                                    "type": "string"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "tiktokIdentityId": {
                                "anyOf": [
                                  {
                                    "type": "string"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "tiktokIdentityType": {
                                "anyOf": [
                                  {
                                    "anyOf": [
                                      {
                                        "type": "string",
                                        "enum": [
                                          "TT_USER"
                                        ]
                                      },
                                      {
                                        "type": "string",
                                        "enum": [
                                          "CUSTOMIZED_USER"
                                        ]
                                      },
                                      {
                                        "type": "string",
                                        "enum": [
                                          "BC_AUTH_TT"
                                        ]
                                      }
                                    ]
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "tiktokItemId": {
                                "anyOf": [
                                  {
                                    "type": "string"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "tiktokLeadFormId": {
                                "anyOf": [
                                  {
                                    "type": "string"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "tiktokOptimizeGoal": {
                                "anyOf": [
                                  {
                                    "type": "string"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "tiktokPixelEvent": {
                                "anyOf": [
                                  {
                                    "type": "string"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "tiktokPixelId": {
                                "anyOf": [
                                  {
                                    "type": "string"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "tiktokRoasBid": {
                                "anyOf": [
                                  {
                                    "type": "number"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              }
                            }
                          },
                          {
                            "type": "null"
                          }
                        ]
                      },
                      "currency": {
                        "anyOf": [
                          {
                            "type": "string"
                          },
                          {
                            "type": "null"
                          }
                        ]
                      },
                      "editWarning": {
                        "anyOf": [
                          {
                            "additionalProperties": false,
                            "type": "object",
                            "properties": {
                              "kind": {
                                "anyOf": [
                                  {
                                    "anyOf": [
                                      {
                                        "type": "string",
                                        "enum": [
                                          "none"
                                        ]
                                      },
                                      {
                                        "type": "string",
                                        "enum": [
                                          "learning_reset"
                                        ]
                                      },
                                      {
                                        "type": "string",
                                        "enum": [
                                          "recreate"
                                        ]
                                      },
                                      {
                                        "type": "string",
                                        "enum": [
                                          "re_review"
                                        ]
                                      },
                                      {
                                        "type": "string",
                                        "enum": [
                                          "id_change"
                                        ]
                                      }
                                    ]
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "reason": {
                                "anyOf": [
                                  {
                                    "type": "string"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              }
                            }
                          },
                          {
                            "type": "null"
                          }
                        ]
                      },
                      "id": {
                        "anyOf": [
                          {
                            "type": "string"
                          },
                          {
                            "type": "null"
                          }
                        ]
                      },
                      "platformId": {
                        "anyOf": [
                          {
                            "type": "string"
                          },
                          {
                            "type": "null"
                          }
                        ]
                      },
                      "publishMode": {
                        "anyOf": [
                          {
                            "anyOf": [
                              {
                                "type": "string",
                                "enum": [
                                  "create_all"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "ads_only"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "add_adset"
                                ]
                              }
                            ]
                          },
                          {
                            "type": "null"
                          }
                        ]
                      },
                      "sessionId": {
                        "anyOf": [
                          {
                            "type": "string"
                          },
                          {
                            "type": "null"
                          }
                        ]
                      }
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "201": {
            "description": "Resource created",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "id",
                    "name",
                    "source",
                    "canonical_campaign",
                    "created_at",
                    "updated_at"
                  ],
                  "properties": {
                    "id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "name": {
                      "type": "string"
                    },
                    "source": {
                      "type": "string"
                    },
                    "canonical_campaign": {
                      "$comment": "json-value",
                      "description": "Arbitrary JSON value with nested arrays and objects."
                    },
                    "created_at": {
                      "format": "date-time",
                      "type": "string"
                    },
                    "updated_at": {
                      "anyOf": [
                        {
                          "format": "date-time",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/campaign-templates/{id}": {
      "get": {
        "operationId": "getCampaignTemplate",
        "summary": "Get campaign template by ID",
        "tags": [
          "campaigns"
        ],
        "description": "Retrieves a single campaign template by its UUID.",
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "id",
                    "name",
                    "source",
                    "canonical_campaign",
                    "created_at",
                    "updated_at"
                  ],
                  "properties": {
                    "id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "name": {
                      "type": "string"
                    },
                    "source": {
                      "type": "string"
                    },
                    "canonical_campaign": {
                      "$comment": "json-value",
                      "description": "Arbitrary JSON value with nested arrays and objects."
                    },
                    "created_at": {
                      "format": "date-time",
                      "type": "string"
                    },
                    "updated_at": {
                      "anyOf": [
                        {
                          "format": "date-time",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      },
      "delete": {
        "operationId": "deleteCampaignTemplate",
        "summary": "Delete campaign template",
        "tags": [
          "campaigns"
        ],
        "description": "Soft-deletes a campaign template by its UUID.",
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "message"
                  ],
                  "properties": {
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/catalogs/{catalogId}/feeds": {
      "get": {
        "operationId": "getApiV1CatalogsByCatalogIdFeeds",
        "summary": "Get product feeds for a catalog",
        "tags": [
          "catalog-feeds"
        ],
        "description": "Lists product feeds for a catalog the caller can access, returning feed identity, schedule metadata, and latest upload status when Meta provides it.",
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "in": "path",
            "name": "catalogId",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "items"
                  ],
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "id",
                          "name"
                        ],
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "name": {
                            "type": "string"
                          },
                          "schedule": {
                            "type": "object",
                            "properties": {
                              "url": {
                                "type": "string"
                              },
                              "interval": {
                                "type": "string"
                              },
                              "hour": {
                                "type": "number"
                              }
                            }
                          },
                          "latest_upload": {
                            "type": "object",
                            "properties": {
                              "end_time": {
                                "type": "string"
                              },
                              "status": {
                                "type": "string"
                              }
                            }
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "postApiV1CatalogsByCatalogIdFeeds",
        "summary": "Create a product feed",
        "tags": [
          "catalog-feeds"
        ],
        "description": "Creates a Meta product feed under the selected catalog, optionally configuring the scheduled fetch URL, interval, and fetch hour.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "name"
                ],
                "properties": {
                  "name": {
                    "minLength": 1,
                    "maxLength": 200,
                    "type": "string"
                  },
                  "schedule_url": {
                    "format": "uri",
                    "type": "string"
                  },
                  "interval": {
                    "anyOf": [
                      {
                        "type": "string",
                        "enum": [
                          "HOURLY"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "DAILY"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "WEEKLY"
                        ]
                      }
                    ]
                  },
                  "hour": {
                    "minimum": 0,
                    "maximum": 23,
                    "type": "integer"
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "in": "path",
            "name": "catalogId",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "id",
                    "message"
                  ],
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/catalogs/{catalogId}/feeds/{feedId}": {
      "put": {
        "operationId": "putApiV1CatalogsByCatalogIdFeedsByFeedId",
        "summary": "Update a product feed",
        "tags": [
          "catalog-feeds"
        ],
        "description": "Updates mutable metadata for an existing product feed in a catalog the caller can access; currently supports renaming the feed.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "properties": {
                  "name": {
                    "minLength": 1,
                    "maxLength": 200,
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "in": "path",
            "name": "catalogId",
            "required": true
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "path",
            "name": "feedId",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "message"
                  ],
                  "properties": {
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      },
      "delete": {
        "operationId": "deleteApiV1CatalogsByCatalogIdFeedsByFeedId",
        "summary": "Delete a product feed",
        "tags": [
          "catalog-feeds"
        ],
        "description": "Deletes the selected Meta product feed after verifying catalog access and an authorized token for the catalog business.",
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "in": "path",
            "name": "catalogId",
            "required": true
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "path",
            "name": "feedId",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "message"
                  ],
                  "properties": {
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/catalogs/{catalogId}/feeds/{feedId}/upload": {
      "post": {
        "operationId": "postApiV1CatalogsByCatalogIdFeedsByFeedIdUpload",
        "summary": "Upload to a product feed",
        "tags": [
          "catalog-feeds"
        ],
        "description": "Starts a Meta feed upload from a publicly reachable file URL for the selected feed and returns the upload session id.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "url"
                ],
                "properties": {
                  "url": {
                    "format": "uri",
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "in": "path",
            "name": "catalogId",
            "required": true
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "path",
            "name": "feedId",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "id",
                    "message"
                  ],
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/catalogs/{catalogId}/feeds/{feedId}/uploads": {
      "get": {
        "operationId": "getApiV1CatalogsByCatalogIdFeedsByFeedIdUploads",
        "summary": "Get feed uploads",
        "tags": [
          "catalog-feeds"
        ],
        "description": "Lists upload sessions for the selected product feed, including upload status, source URL, and completion time when available.",
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "in": "path",
            "name": "catalogId",
            "required": true
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "path",
            "name": "feedId",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "items"
                  ],
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "id"
                        ],
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "end_time": {
                            "type": "string"
                          },
                          "status": {
                            "type": "string"
                          },
                          "url": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/catalogs/{catalogId}/feeds/{feedId}/uploads/{uploadId}/errors": {
      "get": {
        "operationId": "getApiV1CatalogsByCatalogIdFeedsByFeedIdUploadsByUploadIdErrors",
        "summary": "Get per-row errors for a feed upload session",
        "tags": [
          "catalog-feeds"
        ],
        "description": "Returns import validation errors for a feed upload session, including severity, row number, retailer id, and the Meta error message when available.",
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "in": "path",
            "name": "catalogId",
            "required": true
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "path",
            "name": "feedId",
            "required": true
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "path",
            "name": "uploadId",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "items"
                  ],
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "id"
                        ],
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "severity": {
                            "type": "string"
                          },
                          "summary": {
                            "type": "string"
                          },
                          "description": {
                            "type": "string"
                          },
                          "row_number": {
                            "type": "number"
                          },
                          "retailer_id": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/catalogs/{catalogId}/products": {
      "get": {
        "operationId": "listCatalogProducts",
        "summary": "List products in a catalog",
        "tags": [
          "catalog-products"
        ],
        "description": "Returns products from Meta Graph API for the given catalog (cursor-paginated). Shape mirrors Meta Graph v25.0 projected fields; additional fields are preserved as pass-through.",
        "parameters": [
          {
            "schema": {
              "minimum": 1,
              "maximum": 200,
              "default": 50,
              "type": "integer"
            },
            "in": "query",
            "name": "limit",
            "required": false
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "after",
            "required": false
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "path",
            "name": "catalogId",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data"
                  ],
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "id"
                        ],
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "name": {
                            "type": "string"
                          },
                          "price": {
                            "type": "string"
                          },
                          "sale_price": {
                            "type": "string"
                          },
                          "currency": {
                            "type": "string"
                          },
                          "availability": {
                            "type": "string"
                          },
                          "condition": {
                            "type": "string"
                          },
                          "image_url": {
                            "type": "string"
                          },
                          "url": {
                            "type": "string"
                          },
                          "brand": {
                            "type": "string"
                          },
                          "category": {
                            "type": "string"
                          },
                          "product_type": {
                            "type": "string"
                          },
                          "retailer_id": {
                            "type": "string"
                          },
                          "custom_label_0": {
                            "type": "string"
                          },
                          "custom_label_1": {
                            "type": "string"
                          },
                          "custom_label_2": {
                            "type": "string"
                          },
                          "custom_label_3": {
                            "type": "string"
                          },
                          "custom_label_4": {
                            "type": "string"
                          },
                          "description": {
                            "type": "string"
                          },
                          "review_status": {
                            "type": "string"
                          },
                          "rejection_reasons": {
                            "type": "array",
                            "items": {
                              "$comment": "json-value",
                              "description": "Arbitrary JSON value with nested arrays and objects."
                            }
                          },
                          "visibility": {
                            "type": "string"
                          },
                          "item_group_id": {
                            "type": "string"
                          },
                          "additional_image_urls": {
                            "type": "array",
                            "items": {
                              "type": "string"
                            }
                          },
                          "video": {
                            "anyOf": [
                              {
                                "type": "null"
                              },
                              {
                                "type": "object",
                                "required": [
                                  "id"
                                ],
                                "properties": {
                                  "id": {
                                    "type": "string"
                                  },
                                  "url": {
                                    "type": "string"
                                  }
                                }
                              }
                            ]
                          }
                        }
                      }
                    },
                    "paging": {
                      "type": "object",
                      "properties": {
                        "cursors": {
                          "type": "object",
                          "properties": {
                            "after": {
                              "type": "string"
                            },
                            "before": {
                              "type": "string"
                            }
                          }
                        },
                        "next": {
                          "type": "string"
                        },
                        "previous": {
                          "type": "string"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "postApiV1CatalogsByCatalogIdProducts",
        "summary": "Create a product in catalog",
        "tags": [
          "catalog-products"
        ],
        "description": "Creates a product item in the selected Meta catalog. Price fields are normalized before submission and item_group_id is sent as retailer_product_group_id.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "retailer_id",
                  "name",
                  "availability",
                  "price",
                  "currency",
                  "image_url"
                ],
                "properties": {
                  "retailer_id": {
                    "minLength": 1,
                    "maxLength": 500,
                    "type": "string"
                  },
                  "name": {
                    "minLength": 1,
                    "maxLength": 500,
                    "type": "string"
                  },
                  "availability": {
                    "anyOf": [
                      {
                        "type": "string",
                        "enum": [
                          "in stock"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "out of stock"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "available for order"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "discontinued"
                        ]
                      }
                    ]
                  },
                  "price": {
                    "anyOf": [
                      {
                        "minLength": 1,
                        "maxLength": 50,
                        "type": "string"
                      },
                      {
                        "minimum": 0,
                        "type": "integer"
                      }
                    ]
                  },
                  "currency": {
                    "minLength": 3,
                    "maxLength": 3,
                    "type": "string"
                  },
                  "image_url": {
                    "minLength": 1,
                    "maxLength": 2000,
                    "pattern": "\\S",
                    "type": "string"
                  },
                  "url": {
                    "maxLength": 2000,
                    "type": "string"
                  },
                  "description": {
                    "maxLength": 5000,
                    "type": "string"
                  },
                  "brand": {
                    "maxLength": 200,
                    "type": "string"
                  },
                  "category": {
                    "maxLength": 500,
                    "type": "string"
                  },
                  "condition": {
                    "anyOf": [
                      {
                        "type": "string",
                        "enum": [
                          "new"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "refurbished"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "used"
                        ]
                      }
                    ]
                  },
                  "sale_price": {
                    "anyOf": [
                      {
                        "maxLength": 50,
                        "type": "string"
                      },
                      {
                        "minimum": 0,
                        "type": "integer"
                      }
                    ]
                  },
                  "custom_label_0": {
                    "maxLength": 100,
                    "type": "string"
                  },
                  "custom_label_1": {
                    "maxLength": 100,
                    "type": "string"
                  },
                  "custom_label_2": {
                    "maxLength": 100,
                    "type": "string"
                  },
                  "custom_label_3": {
                    "maxLength": 100,
                    "type": "string"
                  },
                  "custom_label_4": {
                    "maxLength": 100,
                    "type": "string"
                  },
                  "item_group_id": {
                    "maxLength": 100,
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "in": "path",
            "name": "catalogId",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "201": {
            "description": "Resource created",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "id"
                  ],
                  "properties": {
                    "id": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/catalogs/{catalogId}/products/{productId}": {
      "get": {
        "operationId": "getCatalogProduct",
        "summary": "Get single product details",
        "tags": [
          "catalog-products"
        ],
        "description": "Fetches a single product node from Meta Graph API. Known fields are typed against Meta Graph v25.0; additional fields are preserved (pass-through).",
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "in": "path",
            "name": "catalogId",
            "required": true
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "path",
            "name": "productId",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": {
                    "$comment": "json-value",
                    "description": "Arbitrary JSON value with nested arrays and objects."
                  },
                  "type": "object",
                  "required": [
                    "id"
                  ],
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "name": {
                      "type": "string"
                    },
                    "price": {
                      "type": "string"
                    },
                    "sale_price": {
                      "type": "string"
                    },
                    "currency": {
                      "type": "string"
                    },
                    "availability": {
                      "type": "string"
                    },
                    "condition": {
                      "type": "string"
                    },
                    "image_url": {
                      "type": "string"
                    },
                    "url": {
                      "type": "string"
                    },
                    "brand": {
                      "type": "string"
                    },
                    "category": {
                      "type": "string"
                    },
                    "product_type": {
                      "type": "string"
                    },
                    "retailer_id": {
                      "type": "string"
                    },
                    "custom_label_0": {
                      "type": "string"
                    },
                    "custom_label_1": {
                      "type": "string"
                    },
                    "custom_label_2": {
                      "type": "string"
                    },
                    "custom_label_3": {
                      "type": "string"
                    },
                    "custom_label_4": {
                      "type": "string"
                    },
                    "description": {
                      "type": "string"
                    },
                    "review_status": {
                      "type": "string"
                    },
                    "rejection_reasons": {
                      "type": "array",
                      "items": {
                        "$comment": "json-value",
                        "description": "Arbitrary JSON value with nested arrays and objects."
                      }
                    },
                    "visibility": {
                      "type": "string"
                    },
                    "item_group_id": {
                      "type": "string"
                    },
                    "additional_image_urls": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "video": {
                      "anyOf": [
                        {
                          "type": "null"
                        },
                        {
                          "type": "object",
                          "required": [
                            "id"
                          ],
                          "properties": {
                            "id": {
                              "type": "string"
                            },
                            "url": {
                              "type": "string"
                            }
                          }
                        }
                      ]
                    },
                    "video_urls": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "videos": {
                      "type": "object",
                      "properties": {
                        "data": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "required": [
                              "id"
                            ],
                            "properties": {
                              "id": {
                                "type": "string"
                              },
                              "source": {
                                "type": "string"
                              },
                              "updated_time": {
                                "type": "string"
                              }
                            }
                          }
                        },
                        "paging": {
                          "description": "JSON object with nested arrays and objects.",
                          "type": "object",
                          "additionalProperties": {
                            "$comment": "json-value",
                            "description": "Arbitrary JSON value with nested arrays and objects."
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      },
      "put": {
        "operationId": "putApiV1CatalogsByCatalogIdProductsByProductId",
        "summary": "Update a product",
        "tags": [
          "catalog-products"
        ],
        "description": "Updates mutable fields on an existing Meta catalog product. Price fields are normalized before submission and item_group_id is sent as retailer_product_group_id. `image_url`, if provided, must be non-empty - a catalog product must always keep an image, so clearing it is rejected.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "retailer_id"
                ],
                "properties": {
                  "retailer_id": {
                    "minLength": 1,
                    "maxLength": 500,
                    "type": "string"
                  },
                  "name": {
                    "minLength": 1,
                    "maxLength": 500,
                    "type": "string"
                  },
                  "availability": {
                    "anyOf": [
                      {
                        "type": "string",
                        "enum": [
                          "in stock"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "out of stock"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "available for order"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "discontinued"
                        ]
                      }
                    ]
                  },
                  "price": {
                    "maxLength": 50,
                    "type": "string"
                  },
                  "currency": {
                    "minLength": 3,
                    "maxLength": 3,
                    "type": "string"
                  },
                  "image_url": {
                    "minLength": 1,
                    "maxLength": 2000,
                    "pattern": "\\S",
                    "type": "string"
                  },
                  "url": {
                    "maxLength": 2000,
                    "type": "string"
                  },
                  "description": {
                    "maxLength": 5000,
                    "type": "string"
                  },
                  "brand": {
                    "maxLength": 200,
                    "type": "string"
                  },
                  "category": {
                    "maxLength": 500,
                    "type": "string"
                  },
                  "condition": {
                    "anyOf": [
                      {
                        "type": "string",
                        "enum": [
                          "new"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "refurbished"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "used"
                        ]
                      }
                    ]
                  },
                  "sale_price": {
                    "maxLength": 50,
                    "type": "string"
                  },
                  "custom_label_0": {
                    "maxLength": 100,
                    "type": "string"
                  },
                  "custom_label_1": {
                    "maxLength": 100,
                    "type": "string"
                  },
                  "custom_label_2": {
                    "maxLength": 100,
                    "type": "string"
                  },
                  "custom_label_3": {
                    "maxLength": 100,
                    "type": "string"
                  },
                  "custom_label_4": {
                    "maxLength": 100,
                    "type": "string"
                  },
                  "item_group_id": {
                    "maxLength": 100,
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "in": "path",
            "name": "catalogId",
            "required": true
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "path",
            "name": "productId",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "success"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      },
      "delete": {
        "operationId": "deleteApiV1CatalogsByCatalogIdProductsByProductId",
        "summary": "Delete a product from catalog",
        "tags": [
          "catalog-products"
        ],
        "description": "Deletes the selected product item from the Meta catalog after verifying catalog access and token authorization.",
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "in": "path",
            "name": "catalogId",
            "required": true
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "path",
            "name": "productId",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "success"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/catalogs/{catalogId}/products/{productId}/request-review": {
      "post": {
        "operationId": "postApiV1CatalogsByCatalogIdProductsByProductIdRequestReview",
        "summary": "Request re-review for a rejected product",
        "tags": [
          "catalog-products"
        ],
        "description": "Triggers Meta re-review for a rejected product by resending the current product name as a minimal update payload.",
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "in": "path",
            "name": "catalogId",
            "required": true
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "path",
            "name": "productId",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "success"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/catalogs/{catalogId}/products/{productId}/archive": {
      "post": {
        "operationId": "postApiV1CatalogsByCatalogIdProductsByProductIdArchive",
        "summary": "Archive a product (sets visibility=staging)",
        "tags": [
          "catalog-products"
        ],
        "description": "Archives the selected product by setting Meta product visibility to staging while preserving existing product and ad set associations.",
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "in": "path",
            "name": "catalogId",
            "required": true
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "path",
            "name": "productId",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "success"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/catalogs/{catalogId}/products/{productId}/unarchive": {
      "post": {
        "operationId": "postApiV1CatalogsByCatalogIdProductsByProductIdUnarchive",
        "summary": "Unarchive a product (sets visibility=published)",
        "tags": [
          "catalog-products"
        ],
        "description": "Unarchives the selected product by setting Meta product visibility back to published for an accessible catalog.",
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "in": "path",
            "name": "catalogId",
            "required": true
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "path",
            "name": "productId",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "success"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/catalogs/{catalogId}/products/{productId}/videos": {
      "patch": {
        "operationId": "patchApiV1CatalogsByCatalogIdProductsByProductIdVideos",
        "summary": "Update product-level video URLs (max 20)",
        "tags": [
          "catalog-products"
        ],
        "description": "Replaces product-level video URLs on the selected Meta catalog product with up to 20 absolute URL values. Meta requires the product to already have an image before it will accept a non-empty list - returns 400 `video_requires_image` otherwise (clearing the list back to empty is always allowed).",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "video_urls"
                ],
                "properties": {
                  "video_urls": {
                    "maxItems": 20,
                    "type": "array",
                    "items": {
                      "format": "uri",
                      "maxLength": 2048,
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "in": "path",
            "name": "catalogId",
            "required": true
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "path",
            "name": "productId",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "success"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/catalogs/{catalogId}/products/media/image": {
      "post": {
        "operationId": "postApiV1CatalogsByCatalogIdProductsMediaImage",
        "summary": "Upload a product image and get back its public URL",
        "tags": [
          "catalog-products"
        ],
        "description": "Stores a JPG/PNG/WebP file (max 10MB) in durable storage and returns its public URL. Does not modify the product — save the URL via PUT /catalogs/:catalogId/products/:productId (image_url) afterwards.",
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "in": "path",
            "name": "catalogId",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "url"
                  ],
                  "properties": {
                    "url": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "413": {
            "description": "Payload too large",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        },
        "requestBody": {
          "content": {
            "multipart/form-data": {
              "schema": {
                "type": "object",
                "required": [
                  "file"
                ],
                "properties": {
                  "file": {
                    "type": "string",
                    "format": "binary",
                    "description": "JPEG, PNG, or WebP product image (max 10MB)."
                  }
                },
                "additionalProperties": false
              }
            }
          }
        }
      }
    },
    "/api/v1/catalogs/{catalogId}/products/media/video": {
      "post": {
        "operationId": "postApiV1CatalogsByCatalogIdProductsMediaVideo",
        "summary": "Upload a product video and get back its public URL",
        "tags": [
          "catalog-products"
        ],
        "description": "Stores an MP4/MOV file (max 100MB) in durable storage and returns its public URL. Does not modify the product — save the URL via PATCH /catalogs/:catalogId/products/:productId/videos afterwards.",
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "in": "path",
            "name": "catalogId",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "url"
                  ],
                  "properties": {
                    "url": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "413": {
            "description": "Payload too large",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        },
        "requestBody": {
          "content": {
            "multipart/form-data": {
              "schema": {
                "type": "object",
                "required": [
                  "file"
                ],
                "properties": {
                  "file": {
                    "type": "string",
                    "format": "binary",
                    "description": "MP4 or MOV product video (max 100MB)."
                  }
                },
                "additionalProperties": false
              }
            }
          }
        }
      }
    },
    "/api/v1/catalogs/{catalogId}/product-groups/{groupId}/variants": {
      "get": {
        "operationId": "getApiV1CatalogsByCatalogIdProductGroupsByGroupIdVariants",
        "summary": "List products sharing the same item_group_id (variants)",
        "tags": [
          "catalog-products"
        ],
        "description": "Lists lightweight product variants in the catalog that share the supplied item_group_id or retailer_product_group_id.",
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "in": "path",
            "name": "catalogId",
            "required": true
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "path",
            "name": "groupId",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "items"
                  ],
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "id",
                          "retailer_id"
                        ],
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "retailer_id": {
                            "type": "string"
                          },
                          "name": {
                            "type": "string"
                          },
                          "image_url": {
                            "type": "string"
                          },
                          "price": {
                            "type": "string"
                          },
                          "currency": {
                            "type": "string"
                          },
                          "availability": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/catalogs/{catalogId}/products/batch": {
      "post": {
        "operationId": "postApiV1CatalogsByCatalogIdProductsBatch",
        "summary": "Batch product operations",
        "tags": [
          "catalog-products"
        ],
        "description": "Dispatches asynchronous product operations for the selected Meta catalog and returns a batch run id with the initial RUNNING status. Each operation's `data.image_url`, if provided, must be non-empty. CREATE operations must also include a non-empty `data.image_url` - a catalog product must always have an image.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "operations"
                ],
                "properties": {
                  "operations": {
                    "minItems": 1,
                    "maxItems": 50000,
                    "type": "array",
                    "items": {
                      "additionalProperties": false,
                      "type": "object",
                      "required": [
                        "method",
                        "retailer_id"
                      ],
                      "properties": {
                        "method": {
                          "anyOf": [
                            {
                              "type": "string",
                              "enum": [
                                "CREATE"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "UPDATE"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "DELETE"
                              ]
                            }
                          ]
                        },
                        "retailer_id": {
                          "minLength": 1,
                          "maxLength": 500,
                          "type": "string"
                        },
                        "data": {
                          "additionalProperties": false,
                          "type": "object",
                          "properties": {
                            "name": {
                              "maxLength": 500,
                              "type": "string"
                            },
                            "availability": {
                              "maxLength": 50,
                              "type": "string"
                            },
                            "price": {
                              "maxLength": 50,
                              "type": "string"
                            },
                            "currency": {
                              "maxLength": 3,
                              "type": "string"
                            },
                            "image_url": {
                              "minLength": 1,
                              "maxLength": 2000,
                              "pattern": "\\S",
                              "type": "string"
                            },
                            "url": {
                              "maxLength": 2000,
                              "type": "string"
                            },
                            "description": {
                              "maxLength": 5000,
                              "type": "string"
                            },
                            "brand": {
                              "maxLength": 200,
                              "type": "string"
                            },
                            "category": {
                              "maxLength": 500,
                              "type": "string"
                            },
                            "condition": {
                              "maxLength": 50,
                              "type": "string"
                            },
                            "sale_price": {
                              "maxLength": 50,
                              "type": "string"
                            },
                            "custom_label_0": {
                              "maxLength": 100,
                              "type": "string"
                            },
                            "custom_label_1": {
                              "maxLength": 100,
                              "type": "string"
                            },
                            "custom_label_2": {
                              "maxLength": 100,
                              "type": "string"
                            },
                            "custom_label_3": {
                              "maxLength": 100,
                              "type": "string"
                            },
                            "custom_label_4": {
                              "maxLength": 100,
                              "type": "string"
                            }
                          }
                        }
                      }
                    }
                  },
                  "allow_upsert": {
                    "type": "boolean"
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "in": "path",
            "name": "catalogId",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "202": {
            "description": "Accepted - processing asynchronously",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "batch_run_id",
                    "status",
                    "operations_count"
                  ],
                  "properties": {
                    "batch_run_id": {
                      "type": "string"
                    },
                    "status": {
                      "type": "string"
                    },
                    "operations_count": {
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/catalogs/{catalogId}/products/batch/{batchRunId}": {
      "get": {
        "operationId": "getApiV1CatalogsByCatalogIdProductsBatchByBatchRunId",
        "summary": "Get batch operation status",
        "tags": [
          "catalog-products"
        ],
        "description": "Returns the latest status for a catalog product batch run accessible to the caller, including task counts, latest metadata, and error details.",
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "in": "path",
            "name": "catalogId",
            "required": true
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "path",
            "name": "batchRunId",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "batch_run_id",
                    "status",
                    "total_tasks",
                    "completed_tasks",
                    "failed_tasks",
                    "metadata",
                    "error",
                    "created_at",
                    "updated_at"
                  ],
                  "properties": {
                    "batch_run_id": {
                      "type": "string"
                    },
                    "status": {
                      "type": "string"
                    },
                    "total_tasks": {
                      "type": "integer"
                    },
                    "completed_tasks": {
                      "type": "integer"
                    },
                    "failed_tasks": {
                      "type": "integer"
                    },
                    "metadata": {
                      "anyOf": [
                        {
                          "type": "null"
                        },
                        {
                          "description": "JSON object with nested arrays and objects.",
                          "type": "object",
                          "additionalProperties": {
                            "$comment": "json-value",
                            "description": "Arbitrary JSON value with nested arrays and objects."
                          }
                        }
                      ]
                    },
                    "error": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "created_at": {
                      "type": "string"
                    },
                    "updated_at": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/catalog": {
      "get": {
        "operationId": "getApiV1Catalog",
        "summary": "List unified catalog variants",
        "tags": [
          "catalog"
        ],
        "description": "Lists team-scoped unified catalog variants with optional campaign, order, search, status, availability, and stock filters.",
        "parameters": [
          {
            "schema": {
              "minLength": 1,
              "maxLength": 100,
              "type": "string"
            },
            "in": "query",
            "name": "campaign_id",
            "required": false
          },
          {
            "schema": {
              "minLength": 1,
              "maxLength": 1000,
              "type": "string"
            },
            "in": "query",
            "name": "campaign_ids",
            "required": false
          },
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "query",
            "name": "id",
            "required": false
          },
          {
            "schema": {
              "minimum": 1,
              "maximum": 200,
              "type": "integer"
            },
            "in": "query",
            "name": "limit",
            "required": false
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "cursor",
            "required": false
          },
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "query",
            "name": "order_id",
            "required": false
          },
          {
            "schema": {
              "minLength": 1,
              "maxLength": 2000,
              "type": "string"
            },
            "in": "query",
            "name": "order_ids",
            "required": false
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "q",
            "required": false
          },
          {
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "enum": [
                    "active"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "needs_review"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "inactive"
                  ]
                }
              ]
            },
            "in": "query",
            "name": "status",
            "required": false
          },
          {
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "enum": [
                    "available"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "unavailable"
                  ]
                }
              ]
            },
            "in": "query",
            "name": "availability",
            "required": false
          },
          {
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "enum": [
                    "in_stock"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "low_stock"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "out_of_stock"
                  ]
                }
              ]
            },
            "in": "query",
            "name": "stock",
            "required": false
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "items",
                    "next_cursor"
                  ],
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "additionalProperties": false,
                        "type": "object",
                        "required": [
                          "canonical_barcode",
                          "canonical_brand",
                          "canonical_gtin",
                          "canonical_option_values",
                          "canonical_sku",
                          "canonical_title",
                          "created_at",
                          "deleted_at",
                          "id",
                          "merged_into_id",
                          "needs_review",
                          "product_master_id",
                          "status",
                          "team_id",
                          "updated_at",
                          "availability",
                          "compare_at_price_amount",
                          "cost_amount",
                          "cost_currency",
                          "description",
                          "description_html",
                          "image_urls",
                          "price_amount",
                          "price_currency",
                          "primary_image_url",
                          "resolved",
                          "sources",
                          "stock_policy",
                          "stock_total",
                          "tags",
                          "weight_grams"
                        ],
                        "properties": {
                          "canonical_barcode": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "canonical_brand": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "canonical_gtin": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "canonical_option_values": {
                            "anyOf": [
                              {
                                "$comment": "json-value",
                                "description": "Arbitrary JSON value with nested arrays and objects."
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "canonical_sku": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "canonical_title": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "created_at": {
                            "format": "date-time",
                            "type": "string"
                          },
                          "deleted_at": {
                            "anyOf": [
                              {
                                "format": "date-time",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "id": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "merged_into_id": {
                            "anyOf": [
                              {
                                "format": "uuid",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "needs_review": {
                            "type": "boolean"
                          },
                          "product_master_id": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "status": {
                            "type": "string"
                          },
                          "team_id": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "updated_at": {
                            "format": "date-time",
                            "type": "string"
                          },
                          "availability": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "compare_at_price_amount": {
                            "anyOf": [
                              {
                                "type": "number"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "cost_amount": {
                            "anyOf": [
                              {
                                "type": "number"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "cost_currency": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "description": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "description_html": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "image_urls": {
                            "type": "array",
                            "items": {
                              "type": "string"
                            }
                          },
                          "price_amount": {
                            "anyOf": [
                              {
                                "type": "number"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "price_currency": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "primary_image_url": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "resolved": {
                            "anyOf": [
                              {
                                "additionalProperties": false,
                                "type": "object",
                                "required": [
                                  "field_provenance",
                                  "policy_snapshot_id",
                                  "resolved_at",
                                  "resolved_brand",
                                  "resolved_category_path",
                                  "resolved_description",
                                  "resolved_image_url",
                                  "resolved_tags",
                                  "resolved_title",
                                  "team_id",
                                  "variant_master_id"
                                ],
                                "properties": {
                                  "field_provenance": {
                                    "$comment": "json-value",
                                    "description": "Arbitrary JSON value with nested arrays and objects."
                                  },
                                  "policy_snapshot_id": {
                                    "anyOf": [
                                      {
                                        "format": "uuid",
                                        "type": "string"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "resolved_at": {
                                    "format": "date-time",
                                    "type": "string"
                                  },
                                  "resolved_brand": {
                                    "anyOf": [
                                      {
                                        "type": "string"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "resolved_category_path": {
                                    "type": "array",
                                    "items": {
                                      "type": "string"
                                    }
                                  },
                                  "resolved_description": {
                                    "anyOf": [
                                      {
                                        "type": "string"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "resolved_image_url": {
                                    "anyOf": [
                                      {
                                        "type": "string"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "resolved_tags": {
                                    "type": "array",
                                    "items": {
                                      "type": "string"
                                    }
                                  },
                                  "resolved_title": {
                                    "anyOf": [
                                      {
                                        "type": "string"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "team_id": {
                                    "format": "uuid",
                                    "type": "string"
                                  },
                                  "variant_master_id": {
                                    "format": "uuid",
                                    "type": "string"
                                  }
                                }
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "sources": {
                            "type": "array",
                            "items": {
                              "additionalProperties": false,
                              "type": "object",
                              "required": [
                                "catalog_source_id",
                                "display_name",
                                "external_id",
                                "external_product_id",
                                "external_variant_id",
                                "type"
                              ],
                              "properties": {
                                "catalog_source_id": {
                                  "format": "uuid",
                                  "type": "string"
                                },
                                "display_name": {
                                  "anyOf": [
                                    {
                                      "type": "string"
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "external_id": {
                                  "anyOf": [
                                    {
                                      "type": "string"
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "external_product_id": {
                                  "anyOf": [
                                    {
                                      "type": "string"
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "external_variant_id": {
                                  "type": "string"
                                },
                                "type": {
                                  "type": "string"
                                }
                              }
                            }
                          },
                          "stock_policy": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "stock_total": {
                            "anyOf": [
                              {
                                "type": "integer"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "tags": {
                            "type": "array",
                            "items": {
                              "type": "string"
                            }
                          },
                          "weight_grams": {
                            "anyOf": [
                              {
                                "type": "number"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          }
                        }
                      }
                    },
                    "next_cursor": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ]
      }
    },
    "/api/v1/catalog/spot-products": {
      "post": {
        "operationId": "postApiV1CatalogSpotProducts",
        "summary": "Create a manual spot product",
        "tags": [
          "catalog"
        ],
        "description": "Creates a lightweight manual Store product and a matching Creative Hub product context for AI creative workflows.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "name"
                ],
                "properties": {
                  "description": {
                    "anyOf": [
                      {
                        "maxLength": 5000,
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "image_url": {
                    "anyOf": [
                      {
                        "maxLength": 2048,
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "images": {
                    "maxItems": 8,
                    "type": "array",
                    "items": {
                      "maxLength": 2048,
                      "type": "string"
                    }
                  },
                  "name": {
                    "minLength": 1,
                    "maxLength": 200,
                    "type": "string"
                  },
                  "price": {
                    "anyOf": [
                      {
                        "maxLength": 60,
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Resource created",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "creative_product_id",
                    "product_master_id",
                    "variant_master_id"
                  ],
                  "properties": {
                    "creative_product_id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "product_master_id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "variant_master_id": {
                      "format": "uuid",
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "Service unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ]
      }
    },
    "/api/v1/catalog/spot-products/import-url": {
      "post": {
        "operationId": "postApiV1CatalogSpotProductsImportUrl",
        "summary": "Import a Store spot product from a product URL",
        "tags": [
          "catalog"
        ],
        "description": "Scrapes a product URL and creates an editable manual Store product plus matching Creative Hub product context.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "url"
                ],
                "properties": {
                  "url": {
                    "minLength": 4,
                    "maxLength": 2048,
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Resource created",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "creative_product_id",
                    "product_master_id",
                    "variant_master_id"
                  ],
                  "properties": {
                    "creative_product_id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "product_master_id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "variant_master_id": {
                      "format": "uuid",
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "422": {
            "description": "Unprocessable entity - semantic validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "Service unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ]
      }
    },
    "/api/v1/catalog/spot-products/import-feed": {
      "post": {
        "operationId": "postApiV1CatalogSpotProductsImportFeed",
        "summary": "Import editable Store spot products from CSV",
        "tags": [
          "catalog"
        ],
        "description": "Imports CSV rows into editable manual Store products. Supported headers: name, description, image_url, price, external_ref.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "csv"
                ],
                "properties": {
                  "csv": {
                    "minLength": 1,
                    "maxLength": 2000000,
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Resource created",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "imported",
                    "items"
                  ],
                  "properties": {
                    "imported": {
                      "minimum": 0,
                      "type": "integer"
                    },
                    "items": {
                      "type": "array",
                      "items": {
                        "additionalProperties": false,
                        "type": "object",
                        "required": [
                          "creative_product_id",
                          "product_master_id",
                          "variant_master_id"
                        ],
                        "properties": {
                          "creative_product_id": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "product_master_id": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "variant_master_id": {
                            "format": "uuid",
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "Service unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ]
      }
    },
    "/api/v1/catalog/spot-products/{variant_master_id}": {
      "patch": {
        "operationId": "patchApiV1CatalogSpotProductsByVariantMasterId",
        "summary": "Update an editable Store spot product",
        "tags": [
          "catalog"
        ],
        "description": "Updates product attributes only for manual Store products. Products linked to Shopify, WooCommerce, or another external provider are read-only here.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "properties": {
                  "description": {
                    "anyOf": [
                      {
                        "maxLength": 5000,
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "image_url": {
                    "anyOf": [
                      {
                        "maxLength": 2048,
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "images": {
                    "maxItems": 8,
                    "type": "array",
                    "items": {
                      "maxLength": 2048,
                      "type": "string"
                    }
                  },
                  "name": {
                    "minLength": 1,
                    "maxLength": 200,
                    "type": "string"
                  },
                  "price": {
                    "anyOf": [
                      {
                        "maxLength": 60,
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "variant_master_id",
            "required": true
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "creative_product_id",
                    "product_master_id",
                    "variant_master_id"
                  ],
                  "properties": {
                    "creative_product_id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "product_master_id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "variant_master_id": {
                      "format": "uuid",
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "Service unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ]
      }
    },
    "/api/v1/catalog/{variant_master_id}": {
      "get": {
        "operationId": "getApiV1CatalogByVariantMasterId",
        "summary": "Get unified catalog variant detail",
        "tags": [
          "catalog"
        ],
        "description": "Returns one team-scoped unified catalog variant with resolved fields, source links, related orders, resolved offers, and optional point-in-time catalog events.",
        "parameters": [
          {
            "schema": {
              "format": "date-time",
              "type": "string"
            },
            "in": "query",
            "name": "as_of",
            "required": false
          },
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "variant_master_id",
            "required": true
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "as_of_events",
                    "resolved",
                    "resolved_offers",
                    "variant"
                  ],
                  "properties": {
                    "as_of_events": {
                      "type": "array",
                      "items": {
                        "additionalProperties": false,
                        "type": "object",
                        "required": [
                          "catalog_source_id",
                          "entity_id",
                          "entity_type",
                          "event_type",
                          "external_entity_id",
                          "id",
                          "occurred_at",
                          "payload_json",
                          "recorded_at",
                          "schema_version",
                          "team_id"
                        ],
                        "properties": {
                          "catalog_source_id": {
                            "anyOf": [
                              {
                                "format": "uuid",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "entity_id": {
                            "anyOf": [
                              {
                                "format": "uuid",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "entity_type": {
                            "type": "string"
                          },
                          "event_type": {
                            "type": "string"
                          },
                          "external_entity_id": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "id": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "occurred_at": {
                            "format": "date-time",
                            "type": "string"
                          },
                          "payload_json": {
                            "$comment": "json-value",
                            "description": "Arbitrary JSON value with nested arrays and objects."
                          },
                          "recorded_at": {
                            "format": "date-time",
                            "type": "string"
                          },
                          "schema_version": {
                            "type": "string"
                          },
                          "team_id": {
                            "format": "uuid",
                            "type": "string"
                          }
                        }
                      }
                    },
                    "resolved": {
                      "anyOf": [
                        {
                          "additionalProperties": false,
                          "type": "object",
                          "required": [
                            "field_provenance",
                            "policy_snapshot_id",
                            "resolved_at",
                            "resolved_brand",
                            "resolved_category_path",
                            "resolved_description",
                            "resolved_image_url",
                            "resolved_tags",
                            "resolved_title",
                            "team_id",
                            "variant_master_id"
                          ],
                          "properties": {
                            "field_provenance": {
                              "$comment": "json-value",
                              "description": "Arbitrary JSON value with nested arrays and objects."
                            },
                            "policy_snapshot_id": {
                              "anyOf": [
                                {
                                  "format": "uuid",
                                  "type": "string"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "resolved_at": {
                              "format": "date-time",
                              "type": "string"
                            },
                            "resolved_brand": {
                              "anyOf": [
                                {
                                  "type": "string"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "resolved_category_path": {
                              "type": "array",
                              "items": {
                                "type": "string"
                              }
                            },
                            "resolved_description": {
                              "anyOf": [
                                {
                                  "type": "string"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "resolved_image_url": {
                              "anyOf": [
                                {
                                  "type": "string"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "resolved_tags": {
                              "type": "array",
                              "items": {
                                "type": "string"
                              }
                            },
                            "resolved_title": {
                              "anyOf": [
                                {
                                  "type": "string"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "team_id": {
                              "format": "uuid",
                              "type": "string"
                            },
                            "variant_master_id": {
                              "format": "uuid",
                              "type": "string"
                            }
                          }
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "resolved_offers": {
                      "type": "array",
                      "items": {
                        "additionalProperties": false,
                        "type": "object",
                        "required": [
                          "field_provenance",
                          "id",
                          "locale",
                          "market_id",
                          "policy_snapshot_id",
                          "resolved_at",
                          "resolved_availability",
                          "resolved_compare_at_price_amount",
                          "resolved_cost_amount",
                          "resolved_cost_currency",
                          "resolved_price_amount",
                          "resolved_price_currency",
                          "resolved_stock_total",
                          "team_id",
                          "variant_master_id"
                        ],
                        "properties": {
                          "field_provenance": {
                            "$comment": "json-value",
                            "description": "Arbitrary JSON value with nested arrays and objects."
                          },
                          "id": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "locale": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "market_id": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "policy_snapshot_id": {
                            "anyOf": [
                              {
                                "format": "uuid",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "resolved_at": {
                            "format": "date-time",
                            "type": "string"
                          },
                          "resolved_availability": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "resolved_compare_at_price_amount": {
                            "anyOf": [
                              {
                                "anyOf": [
                                  {
                                    "type": "number"
                                  },
                                  {
                                    "type": "string"
                                  }
                                ]
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "resolved_cost_amount": {
                            "anyOf": [
                              {
                                "anyOf": [
                                  {
                                    "type": "number"
                                  },
                                  {
                                    "type": "string"
                                  }
                                ]
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "resolved_cost_currency": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "resolved_price_amount": {
                            "anyOf": [
                              {
                                "anyOf": [
                                  {
                                    "type": "number"
                                  },
                                  {
                                    "type": "string"
                                  }
                                ]
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "resolved_price_currency": {
                            "type": "string"
                          },
                          "resolved_stock_total": {
                            "anyOf": [
                              {
                                "type": "integer"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "team_id": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "variant_master_id": {
                            "format": "uuid",
                            "type": "string"
                          }
                        }
                      }
                    },
                    "variant": {
                      "additionalProperties": false,
                      "type": "object",
                      "required": [
                        "canonical_barcode",
                        "canonical_brand",
                        "canonical_gtin",
                        "canonical_option_values",
                        "canonical_sku",
                        "canonical_title",
                        "created_at",
                        "deleted_at",
                        "id",
                        "merged_into_id",
                        "needs_review",
                        "product_master_id",
                        "status",
                        "team_id",
                        "updated_at",
                        "availability",
                        "available_for_sale",
                        "compare_at_price_amount",
                        "cost_amount",
                        "cost_currency",
                        "description",
                        "description_html",
                        "image_urls",
                        "price_amount",
                        "price_currency",
                        "primary_image_url",
                        "related_orders",
                        "sources",
                        "stock_policy",
                        "stock_total",
                        "tags",
                        "weight_grams"
                      ],
                      "properties": {
                        "canonical_barcode": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "canonical_brand": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "canonical_gtin": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "canonical_option_values": {
                          "anyOf": [
                            {
                              "$comment": "json-value",
                              "description": "Arbitrary JSON value with nested arrays and objects."
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "canonical_sku": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "canonical_title": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "created_at": {
                          "format": "date-time",
                          "type": "string"
                        },
                        "deleted_at": {
                          "anyOf": [
                            {
                              "format": "date-time",
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "id": {
                          "format": "uuid",
                          "type": "string"
                        },
                        "merged_into_id": {
                          "anyOf": [
                            {
                              "format": "uuid",
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "needs_review": {
                          "type": "boolean"
                        },
                        "product_master_id": {
                          "format": "uuid",
                          "type": "string"
                        },
                        "status": {
                          "type": "string"
                        },
                        "team_id": {
                          "format": "uuid",
                          "type": "string"
                        },
                        "updated_at": {
                          "format": "date-time",
                          "type": "string"
                        },
                        "availability": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "available_for_sale": {
                          "anyOf": [
                            {
                              "type": "boolean"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "compare_at_price_amount": {
                          "anyOf": [
                            {
                              "type": "number"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "cost_amount": {
                          "anyOf": [
                            {
                              "type": "number"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "cost_currency": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "description": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "description_html": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "image_urls": {
                          "type": "array",
                          "items": {
                            "type": "string"
                          }
                        },
                        "price_amount": {
                          "anyOf": [
                            {
                              "type": "number"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "price_currency": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "primary_image_url": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "related_orders": {
                          "type": "array",
                          "items": {
                            "additionalProperties": false,
                            "type": "object",
                            "required": [
                              "effective_financial_status",
                              "external_order_id",
                              "financial_status",
                              "fulfillment_status",
                              "line_item_id",
                              "net_amount",
                              "order_id",
                              "order_name",
                              "placed_at",
                              "qty",
                              "sku",
                              "source_type",
                              "total_amount",
                              "total_currency",
                              "total_line_amount",
                              "total_refunded",
                              "unit_price_currency"
                            ],
                            "properties": {
                              "effective_financial_status": {
                                "anyOf": [
                                  {
                                    "type": "string"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "external_order_id": {
                                "type": "string"
                              },
                              "financial_status": {
                                "anyOf": [
                                  {
                                    "type": "string"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "fulfillment_status": {
                                "anyOf": [
                                  {
                                    "type": "string"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "line_item_id": {
                                "type": "string"
                              },
                              "net_amount": {
                                "anyOf": [
                                  {
                                    "type": "number"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "order_id": {
                                "anyOf": [
                                  {
                                    "format": "uuid",
                                    "type": "string"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "order_name": {
                                "anyOf": [
                                  {
                                    "type": "string"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "placed_at": {
                                "anyOf": [
                                  {
                                    "format": "date-time",
                                    "type": "string"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "qty": {
                                "type": "integer"
                              },
                              "sku": {
                                "anyOf": [
                                  {
                                    "type": "string"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "source_type": {
                                "type": "string"
                              },
                              "total_amount": {
                                "anyOf": [
                                  {
                                    "type": "number"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "total_currency": {
                                "anyOf": [
                                  {
                                    "type": "string"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "total_line_amount": {
                                "anyOf": [
                                  {
                                    "type": "number"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "total_refunded": {
                                "anyOf": [
                                  {
                                    "type": "number"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "unit_price_currency": {
                                "anyOf": [
                                  {
                                    "type": "string"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              }
                            }
                          }
                        },
                        "sources": {
                          "type": "array",
                          "items": {
                            "additionalProperties": false,
                            "type": "object",
                            "required": [
                              "catalog_source_id",
                              "display_name",
                              "external_id",
                              "external_product_id",
                              "external_variant_id",
                              "match_confidence",
                              "match_reason",
                              "source_data",
                              "source_link_id",
                              "status",
                              "type"
                            ],
                            "properties": {
                              "catalog_source_id": {
                                "format": "uuid",
                                "type": "string"
                              },
                              "display_name": {
                                "anyOf": [
                                  {
                                    "type": "string"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "external_id": {
                                "anyOf": [
                                  {
                                    "type": "string"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "external_product_id": {
                                "anyOf": [
                                  {
                                    "type": "string"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "external_variant_id": {
                                "type": "string"
                              },
                              "match_confidence": {
                                "anyOf": [
                                  {
                                    "type": "number"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "match_reason": {
                                "type": "string"
                              },
                              "source_data": {
                                "anyOf": [
                                  {
                                    "additionalProperties": false,
                                    "type": "object",
                                    "required": [
                                      "availability",
                                      "available_for_sale",
                                      "barcode",
                                      "brand",
                                      "category_full_name",
                                      "category_name",
                                      "category_path",
                                      "category_source",
                                      "cdm_schema_version",
                                      "compare_at_price_amount",
                                      "cost_amount",
                                      "cost_currency",
                                      "description",
                                      "description_html",
                                      "external_retailer_id",
                                      "google_product_category_id",
                                      "gtin",
                                      "handle",
                                      "height_mm",
                                      "image_urls",
                                      "length_mm",
                                      "locale",
                                      "market_id",
                                      "marketplace_id",
                                      "match_confidence",
                                      "match_reason",
                                      "mpn",
                                      "option_values",
                                      "parent_external_id",
                                      "price_amount",
                                      "price_currency",
                                      "primary_image_url",
                                      "product_type",
                                      "published_at",
                                      "published_scope",
                                      "raw_payload",
                                      "recorded_at",
                                      "selected_option_values",
                                      "sku",
                                      "sku_raw",
                                      "source_created_at",
                                      "source_updated_at",
                                      "status",
                                      "stock_policy",
                                      "stock_total",
                                      "tags",
                                      "tax_included",
                                      "template_suffix",
                                      "title",
                                      "valid_from",
                                      "valid_to",
                                      "variant_type",
                                      "vendor",
                                      "weight_grams",
                                      "width_mm"
                                    ],
                                    "properties": {
                                      "availability": {
                                        "anyOf": [
                                          {
                                            "type": "string"
                                          },
                                          {
                                            "type": "null"
                                          }
                                        ]
                                      },
                                      "available_for_sale": {
                                        "anyOf": [
                                          {
                                            "type": "boolean"
                                          },
                                          {
                                            "type": "null"
                                          }
                                        ]
                                      },
                                      "barcode": {
                                        "anyOf": [
                                          {
                                            "type": "string"
                                          },
                                          {
                                            "type": "null"
                                          }
                                        ]
                                      },
                                      "brand": {
                                        "anyOf": [
                                          {
                                            "type": "string"
                                          },
                                          {
                                            "type": "null"
                                          }
                                        ]
                                      },
                                      "category_full_name": {
                                        "anyOf": [
                                          {
                                            "type": "string"
                                          },
                                          {
                                            "type": "null"
                                          }
                                        ]
                                      },
                                      "category_name": {
                                        "anyOf": [
                                          {
                                            "type": "string"
                                          },
                                          {
                                            "type": "null"
                                          }
                                        ]
                                      },
                                      "category_path": {
                                        "type": "array",
                                        "items": {
                                          "type": "string"
                                        }
                                      },
                                      "category_source": {
                                        "anyOf": [
                                          {
                                            "type": "string"
                                          },
                                          {
                                            "type": "null"
                                          }
                                        ]
                                      },
                                      "cdm_schema_version": {
                                        "type": "string"
                                      },
                                      "compare_at_price_amount": {
                                        "anyOf": [
                                          {
                                            "type": "number"
                                          },
                                          {
                                            "type": "null"
                                          }
                                        ]
                                      },
                                      "cost_amount": {
                                        "anyOf": [
                                          {
                                            "type": "number"
                                          },
                                          {
                                            "type": "null"
                                          }
                                        ]
                                      },
                                      "cost_currency": {
                                        "anyOf": [
                                          {
                                            "type": "string"
                                          },
                                          {
                                            "type": "null"
                                          }
                                        ]
                                      },
                                      "description": {
                                        "anyOf": [
                                          {
                                            "type": "string"
                                          },
                                          {
                                            "type": "null"
                                          }
                                        ]
                                      },
                                      "description_html": {
                                        "anyOf": [
                                          {
                                            "type": "string"
                                          },
                                          {
                                            "type": "null"
                                          }
                                        ]
                                      },
                                      "external_retailer_id": {
                                        "anyOf": [
                                          {
                                            "type": "string"
                                          },
                                          {
                                            "type": "null"
                                          }
                                        ]
                                      },
                                      "google_product_category_id": {
                                        "anyOf": [
                                          {
                                            "type": "string"
                                          },
                                          {
                                            "type": "null"
                                          }
                                        ]
                                      },
                                      "gtin": {
                                        "anyOf": [
                                          {
                                            "type": "string"
                                          },
                                          {
                                            "type": "null"
                                          }
                                        ]
                                      },
                                      "handle": {
                                        "anyOf": [
                                          {
                                            "type": "string"
                                          },
                                          {
                                            "type": "null"
                                          }
                                        ]
                                      },
                                      "height_mm": {
                                        "anyOf": [
                                          {
                                            "type": "number"
                                          },
                                          {
                                            "type": "null"
                                          }
                                        ]
                                      },
                                      "image_urls": {
                                        "type": "array",
                                        "items": {
                                          "type": "string"
                                        }
                                      },
                                      "length_mm": {
                                        "anyOf": [
                                          {
                                            "type": "number"
                                          },
                                          {
                                            "type": "null"
                                          }
                                        ]
                                      },
                                      "locale": {
                                        "anyOf": [
                                          {
                                            "type": "string"
                                          },
                                          {
                                            "type": "null"
                                          }
                                        ]
                                      },
                                      "market_id": {
                                        "anyOf": [
                                          {
                                            "type": "string"
                                          },
                                          {
                                            "type": "null"
                                          }
                                        ]
                                      },
                                      "marketplace_id": {
                                        "anyOf": [
                                          {
                                            "type": "string"
                                          },
                                          {
                                            "type": "null"
                                          }
                                        ]
                                      },
                                      "match_confidence": {
                                        "anyOf": [
                                          {
                                            "type": "number"
                                          },
                                          {
                                            "type": "null"
                                          }
                                        ]
                                      },
                                      "match_reason": {
                                        "type": "string"
                                      },
                                      "mpn": {
                                        "anyOf": [
                                          {
                                            "type": "string"
                                          },
                                          {
                                            "type": "null"
                                          }
                                        ]
                                      },
                                      "option_values": {
                                        "anyOf": [
                                          {
                                            "$comment": "json-value",
                                            "description": "Arbitrary JSON value with nested arrays and objects."
                                          },
                                          {
                                            "type": "null"
                                          }
                                        ]
                                      },
                                      "parent_external_id": {
                                        "anyOf": [
                                          {
                                            "type": "string"
                                          },
                                          {
                                            "type": "null"
                                          }
                                        ]
                                      },
                                      "price_amount": {
                                        "anyOf": [
                                          {
                                            "type": "number"
                                          },
                                          {
                                            "type": "null"
                                          }
                                        ]
                                      },
                                      "price_currency": {
                                        "anyOf": [
                                          {
                                            "type": "string"
                                          },
                                          {
                                            "type": "null"
                                          }
                                        ]
                                      },
                                      "primary_image_url": {
                                        "anyOf": [
                                          {
                                            "type": "string"
                                          },
                                          {
                                            "type": "null"
                                          }
                                        ]
                                      },
                                      "product_type": {
                                        "anyOf": [
                                          {
                                            "type": "string"
                                          },
                                          {
                                            "type": "null"
                                          }
                                        ]
                                      },
                                      "published_at": {
                                        "anyOf": [
                                          {
                                            "format": "date-time",
                                            "type": "string"
                                          },
                                          {
                                            "type": "null"
                                          }
                                        ]
                                      },
                                      "published_scope": {
                                        "anyOf": [
                                          {
                                            "type": "string"
                                          },
                                          {
                                            "type": "null"
                                          }
                                        ]
                                      },
                                      "raw_payload": {
                                        "anyOf": [
                                          {
                                            "$comment": "json-value",
                                            "description": "Arbitrary JSON value with nested arrays and objects."
                                          },
                                          {
                                            "type": "null"
                                          }
                                        ]
                                      },
                                      "recorded_at": {
                                        "format": "date-time",
                                        "type": "string"
                                      },
                                      "selected_option_values": {
                                        "anyOf": [
                                          {
                                            "$comment": "json-value",
                                            "description": "Arbitrary JSON value with nested arrays and objects."
                                          },
                                          {
                                            "type": "null"
                                          }
                                        ]
                                      },
                                      "sku": {
                                        "anyOf": [
                                          {
                                            "type": "string"
                                          },
                                          {
                                            "type": "null"
                                          }
                                        ]
                                      },
                                      "sku_raw": {
                                        "anyOf": [
                                          {
                                            "type": "string"
                                          },
                                          {
                                            "type": "null"
                                          }
                                        ]
                                      },
                                      "source_created_at": {
                                        "anyOf": [
                                          {
                                            "format": "date-time",
                                            "type": "string"
                                          },
                                          {
                                            "type": "null"
                                          }
                                        ]
                                      },
                                      "source_updated_at": {
                                        "anyOf": [
                                          {
                                            "format": "date-time",
                                            "type": "string"
                                          },
                                          {
                                            "type": "null"
                                          }
                                        ]
                                      },
                                      "status": {
                                        "anyOf": [
                                          {
                                            "type": "string"
                                          },
                                          {
                                            "type": "null"
                                          }
                                        ]
                                      },
                                      "stock_policy": {
                                        "anyOf": [
                                          {
                                            "type": "string"
                                          },
                                          {
                                            "type": "null"
                                          }
                                        ]
                                      },
                                      "stock_total": {
                                        "anyOf": [
                                          {
                                            "type": "integer"
                                          },
                                          {
                                            "type": "null"
                                          }
                                        ]
                                      },
                                      "tags": {
                                        "type": "array",
                                        "items": {
                                          "type": "string"
                                        }
                                      },
                                      "tax_included": {
                                        "anyOf": [
                                          {
                                            "type": "boolean"
                                          },
                                          {
                                            "type": "null"
                                          }
                                        ]
                                      },
                                      "template_suffix": {
                                        "anyOf": [
                                          {
                                            "type": "string"
                                          },
                                          {
                                            "type": "null"
                                          }
                                        ]
                                      },
                                      "title": {
                                        "anyOf": [
                                          {
                                            "type": "string"
                                          },
                                          {
                                            "type": "null"
                                          }
                                        ]
                                      },
                                      "valid_from": {
                                        "format": "date-time",
                                        "type": "string"
                                      },
                                      "valid_to": {
                                        "anyOf": [
                                          {
                                            "format": "date-time",
                                            "type": "string"
                                          },
                                          {
                                            "type": "null"
                                          }
                                        ]
                                      },
                                      "variant_type": {
                                        "anyOf": [
                                          {
                                            "type": "string"
                                          },
                                          {
                                            "type": "null"
                                          }
                                        ]
                                      },
                                      "vendor": {
                                        "anyOf": [
                                          {
                                            "type": "string"
                                          },
                                          {
                                            "type": "null"
                                          }
                                        ]
                                      },
                                      "weight_grams": {
                                        "anyOf": [
                                          {
                                            "type": "number"
                                          },
                                          {
                                            "type": "null"
                                          }
                                        ]
                                      },
                                      "width_mm": {
                                        "anyOf": [
                                          {
                                            "type": "number"
                                          },
                                          {
                                            "type": "null"
                                          }
                                        ]
                                      }
                                    }
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "source_link_id": {
                                "format": "uuid",
                                "type": "string"
                              },
                              "status": {
                                "anyOf": [
                                  {
                                    "type": "string"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "type": {
                                "type": "string"
                              }
                            }
                          }
                        },
                        "stock_policy": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "stock_total": {
                          "anyOf": [
                            {
                              "type": "integer"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "tags": {
                          "type": "array",
                          "items": {
                            "type": "string"
                          }
                        },
                        "weight_grams": {
                          "anyOf": [
                            {
                              "type": "number"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ]
      }
    },
    "/api/v1/catalog/{variant_master_id}/events": {
      "get": {
        "operationId": "getApiV1CatalogByVariantMasterIdEvents",
        "summary": "List catalog events for a variant",
        "tags": [
          "catalog"
        ],
        "description": "Returns recent catalog events for a variant and for currently linked source products visible to the caller team.",
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "variant_master_id",
            "required": true
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "items"
                  ],
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "additionalProperties": false,
                        "type": "object",
                        "required": [
                          "catalog_source_id",
                          "entity_id",
                          "entity_type",
                          "event_type",
                          "external_entity_id",
                          "id",
                          "occurred_at",
                          "payload_json",
                          "recorded_at",
                          "schema_version",
                          "team_id"
                        ],
                        "properties": {
                          "catalog_source_id": {
                            "anyOf": [
                              {
                                "format": "uuid",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "entity_id": {
                            "anyOf": [
                              {
                                "format": "uuid",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "entity_type": {
                            "type": "string"
                          },
                          "event_type": {
                            "type": "string"
                          },
                          "external_entity_id": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "id": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "occurred_at": {
                            "format": "date-time",
                            "type": "string"
                          },
                          "payload_json": {
                            "$comment": "json-value",
                            "description": "Arbitrary JSON value with nested arrays and objects."
                          },
                          "recorded_at": {
                            "format": "date-time",
                            "type": "string"
                          },
                          "schema_version": {
                            "type": "string"
                          },
                          "team_id": {
                            "format": "uuid",
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ]
      }
    },
    "/api/v1/campaigns/{campaign_id}/products": {
      "get": {
        "operationId": "getApiV1CampaignsByCampaignIdProducts",
        "summary": "List product performance for a campaign",
        "tags": [
          "catalog"
        ],
        "description": "Returns campaign-level product daily statistics for the current team, ordered by most recent stat date.",
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "in": "path",
            "name": "campaign_id",
            "required": true
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "items"
                  ],
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "additionalProperties": false,
                        "type": "object",
                        "required": [
                          "campaign_id",
                          "computed_at",
                          "date",
                          "fx_rate_date",
                          "fx_source",
                          "refunded_amount",
                          "reporting_currency",
                          "revenue_amount",
                          "revenue_currency",
                          "roas",
                          "spend_amount",
                          "team_id",
                          "units_sold",
                          "variant_master_id"
                        ],
                        "properties": {
                          "campaign_id": {
                            "type": "string"
                          },
                          "computed_at": {
                            "format": "date-time",
                            "type": "string"
                          },
                          "date": {
                            "format": "date",
                            "type": "string"
                          },
                          "fx_rate_date": {
                            "anyOf": [
                              {
                                "format": "date",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "fx_source": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "refunded_amount": {
                            "anyOf": [
                              {
                                "type": "number"
                              },
                              {
                                "type": "string"
                              }
                            ]
                          },
                          "reporting_currency": {
                            "type": "string"
                          },
                          "revenue_amount": {
                            "anyOf": [
                              {
                                "type": "number"
                              },
                              {
                                "type": "string"
                              }
                            ]
                          },
                          "revenue_currency": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "roas": {
                            "anyOf": [
                              {
                                "anyOf": [
                                  {
                                    "type": "number"
                                  },
                                  {
                                    "type": "string"
                                  }
                                ]
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "spend_amount": {
                            "anyOf": [
                              {
                                "type": "number"
                              },
                              {
                                "type": "string"
                              }
                            ]
                          },
                          "team_id": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "units_sold": {
                            "type": "integer"
                          },
                          "variant_master_id": {
                            "format": "uuid",
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ]
      }
    },
    "/api/v1/catalog-v2/match-suggestions": {
      "get": {
        "operationId": "getApiV1CatalogV2MatchSuggestions",
        "summary": "List catalog match suggestions",
        "tags": [
          "catalog"
        ],
        "description": "Lists pending, approved, or rejected cross-source variant match suggestions with candidate/source snapshots and field diffs.",
        "parameters": [
          {
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "enum": [
                    "pending"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "approved"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "rejected"
                  ]
                }
              ]
            },
            "in": "query",
            "name": "status",
            "required": false
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "items"
                  ],
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "additionalProperties": false,
                        "type": "object",
                        "required": [
                          "candidate_product_master_id",
                          "candidate_snapshot",
                          "candidate_variant",
                          "candidate_variant_master_id",
                          "catalog_source_id",
                          "confidence",
                          "created_at",
                          "decided_at",
                          "decided_by",
                          "external_product_id",
                          "external_variant_id",
                          "field_diffs",
                          "id",
                          "match_reasons",
                          "score",
                          "source",
                          "source_snapshot",
                          "source_variant",
                          "status",
                          "team_id",
                          "updated_at"
                        ],
                        "properties": {
                          "candidate_product_master_id": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "candidate_snapshot": {
                            "additionalProperties": false,
                            "type": "object",
                            "required": [
                              "barcode",
                              "brand",
                              "gtin",
                              "option_values",
                              "sku",
                              "title"
                            ],
                            "properties": {
                              "barcode": {
                                "anyOf": [
                                  {
                                    "type": "string"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "brand": {
                                "anyOf": [
                                  {
                                    "type": "string"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "gtin": {
                                "anyOf": [
                                  {
                                    "type": "string"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "option_values": {
                                "anyOf": [
                                  {
                                    "$comment": "json-value",
                                    "description": "Arbitrary JSON value with nested arrays and objects."
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "sku": {
                                "anyOf": [
                                  {
                                    "type": "string"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "title": {
                                "anyOf": [
                                  {
                                    "type": "string"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              }
                            }
                          },
                          "candidate_variant": {
                            "additionalProperties": false,
                            "type": "object",
                            "required": [
                              "canonical_barcode",
                              "canonical_brand",
                              "canonical_gtin",
                              "canonical_option_values",
                              "canonical_sku",
                              "canonical_title",
                              "id",
                              "image_urls",
                              "primary_image_url",
                              "product_master_id",
                              "updated_at"
                            ],
                            "properties": {
                              "canonical_barcode": {
                                "anyOf": [
                                  {
                                    "type": "string"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "canonical_brand": {
                                "anyOf": [
                                  {
                                    "type": "string"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "canonical_gtin": {
                                "anyOf": [
                                  {
                                    "type": "string"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "canonical_option_values": {
                                "anyOf": [
                                  {
                                    "$comment": "json-value",
                                    "description": "Arbitrary JSON value with nested arrays and objects."
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "canonical_sku": {
                                "anyOf": [
                                  {
                                    "type": "string"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "canonical_title": {
                                "anyOf": [
                                  {
                                    "type": "string"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "id": {
                                "format": "uuid",
                                "type": "string"
                              },
                              "image_urls": {
                                "type": "array",
                                "items": {
                                  "type": "string"
                                }
                              },
                              "primary_image_url": {
                                "anyOf": [
                                  {
                                    "type": "string"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "product_master_id": {
                                "format": "uuid",
                                "type": "string"
                              },
                              "updated_at": {
                                "format": "date-time",
                                "type": "string"
                              }
                            }
                          },
                          "candidate_variant_master_id": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "catalog_source_id": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "confidence": {
                            "anyOf": [
                              {
                                "type": "string",
                                "enum": [
                                  "very_high"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "high"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "medium"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "low"
                                ]
                              }
                            ]
                          },
                          "created_at": {
                            "format": "date-time",
                            "type": "string"
                          },
                          "decided_at": {
                            "anyOf": [
                              {
                                "format": "date-time",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "decided_by": {
                            "type": "null"
                          },
                          "external_product_id": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "external_variant_id": {
                            "type": "string"
                          },
                          "field_diffs": {
                            "additionalProperties": false,
                            "type": "object",
                            "required": [
                              "barcode",
                              "brand",
                              "gtin",
                              "option_values",
                              "sku",
                              "title"
                            ],
                            "properties": {
                              "barcode": {
                                "additionalProperties": false,
                                "type": "object",
                                "required": [
                                  "candidate",
                                  "source"
                                ],
                                "properties": {
                                  "candidate": {
                                    "anyOf": [
                                      {
                                        "$comment": "json-value",
                                        "description": "Arbitrary JSON value with nested arrays and objects."
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "source": {
                                    "anyOf": [
                                      {
                                        "$comment": "json-value",
                                        "description": "Arbitrary JSON value with nested arrays and objects."
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  }
                                }
                              },
                              "brand": {
                                "additionalProperties": false,
                                "type": "object",
                                "required": [
                                  "candidate",
                                  "source"
                                ],
                                "properties": {
                                  "candidate": {
                                    "anyOf": [
                                      {
                                        "$comment": "json-value",
                                        "description": "Arbitrary JSON value with nested arrays and objects."
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "source": {
                                    "anyOf": [
                                      {
                                        "$comment": "json-value",
                                        "description": "Arbitrary JSON value with nested arrays and objects."
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  }
                                }
                              },
                              "gtin": {
                                "additionalProperties": false,
                                "type": "object",
                                "required": [
                                  "candidate",
                                  "source"
                                ],
                                "properties": {
                                  "candidate": {
                                    "anyOf": [
                                      {
                                        "$comment": "json-value",
                                        "description": "Arbitrary JSON value with nested arrays and objects."
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "source": {
                                    "anyOf": [
                                      {
                                        "$comment": "json-value",
                                        "description": "Arbitrary JSON value with nested arrays and objects."
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  }
                                }
                              },
                              "option_values": {
                                "additionalProperties": false,
                                "type": "object",
                                "required": [
                                  "candidate",
                                  "source"
                                ],
                                "properties": {
                                  "candidate": {
                                    "anyOf": [
                                      {
                                        "$comment": "json-value",
                                        "description": "Arbitrary JSON value with nested arrays and objects."
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "source": {
                                    "anyOf": [
                                      {
                                        "$comment": "json-value",
                                        "description": "Arbitrary JSON value with nested arrays and objects."
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  }
                                }
                              },
                              "sku": {
                                "additionalProperties": false,
                                "type": "object",
                                "required": [
                                  "candidate",
                                  "source"
                                ],
                                "properties": {
                                  "candidate": {
                                    "anyOf": [
                                      {
                                        "$comment": "json-value",
                                        "description": "Arbitrary JSON value with nested arrays and objects."
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "source": {
                                    "anyOf": [
                                      {
                                        "$comment": "json-value",
                                        "description": "Arbitrary JSON value with nested arrays and objects."
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  }
                                }
                              },
                              "title": {
                                "additionalProperties": false,
                                "type": "object",
                                "required": [
                                  "candidate",
                                  "source"
                                ],
                                "properties": {
                                  "candidate": {
                                    "anyOf": [
                                      {
                                        "$comment": "json-value",
                                        "description": "Arbitrary JSON value with nested arrays and objects."
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "source": {
                                    "anyOf": [
                                      {
                                        "$comment": "json-value",
                                        "description": "Arbitrary JSON value with nested arrays and objects."
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  }
                                }
                              }
                            }
                          },
                          "id": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "match_reasons": {
                            "type": "array",
                            "items": {
                              "type": "string"
                            }
                          },
                          "score": {
                            "type": "number"
                          },
                          "source": {
                            "anyOf": [
                              {
                                "additionalProperties": false,
                                "type": "object",
                                "required": [
                                  "display_name",
                                  "external_id",
                                  "id",
                                  "status",
                                  "type"
                                ],
                                "properties": {
                                  "display_name": {
                                    "anyOf": [
                                      {
                                        "type": "string"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "external_id": {
                                    "type": "string"
                                  },
                                  "id": {
                                    "format": "uuid",
                                    "type": "string"
                                  },
                                  "status": {
                                    "type": "string"
                                  },
                                  "type": {
                                    "type": "string"
                                  }
                                }
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "source_snapshot": {
                            "additionalProperties": false,
                            "type": "object",
                            "required": [
                              "barcode",
                              "brand",
                              "gtin",
                              "option_values",
                              "sku",
                              "title"
                            ],
                            "properties": {
                              "barcode": {
                                "anyOf": [
                                  {
                                    "type": "string"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "brand": {
                                "anyOf": [
                                  {
                                    "type": "string"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "gtin": {
                                "anyOf": [
                                  {
                                    "type": "string"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "option_values": {
                                "anyOf": [
                                  {
                                    "$comment": "json-value",
                                    "description": "Arbitrary JSON value with nested arrays and objects."
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "sku": {
                                "anyOf": [
                                  {
                                    "type": "string"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "title": {
                                "anyOf": [
                                  {
                                    "type": "string"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              }
                            }
                          },
                          "source_variant": {
                            "additionalProperties": false,
                            "type": "object",
                            "required": [
                              "barcode",
                              "brand",
                              "catalog_source_id",
                              "external_id",
                              "gtin",
                              "image_urls",
                              "option_values",
                              "parent_external_id",
                              "primary_image_url",
                              "sku",
                              "title"
                            ],
                            "properties": {
                              "barcode": {
                                "anyOf": [
                                  {
                                    "type": "string"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "brand": {
                                "anyOf": [
                                  {
                                    "type": "string"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "catalog_source_id": {
                                "format": "uuid",
                                "type": "string"
                              },
                              "external_id": {
                                "type": "string"
                              },
                              "gtin": {
                                "anyOf": [
                                  {
                                    "type": "string"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "image_urls": {
                                "type": "array",
                                "items": {
                                  "type": "string"
                                }
                              },
                              "option_values": {
                                "anyOf": [
                                  {
                                    "$comment": "json-value",
                                    "description": "Arbitrary JSON value with nested arrays and objects."
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "parent_external_id": {
                                "anyOf": [
                                  {
                                    "type": "string"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "primary_image_url": {
                                "anyOf": [
                                  {
                                    "type": "string"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "sku": {
                                "anyOf": [
                                  {
                                    "type": "string"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "title": {
                                "anyOf": [
                                  {
                                    "type": "string"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              }
                            }
                          },
                          "status": {
                            "anyOf": [
                              {
                                "type": "string",
                                "enum": [
                                  "pending"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "approved"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "rejected"
                                ]
                              }
                            ]
                          },
                          "team_id": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "updated_at": {
                            "format": "date-time",
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ]
      }
    },
    "/api/v1/catalog-v2/match-suggestions/{id}/accept": {
      "post": {
        "operationId": "postApiV1CatalogV2MatchSuggestionsByIdAccept",
        "summary": "Accept a catalog match suggestion",
        "tags": [
          "catalog"
        ],
        "description": "Approves a pending source-link match suggestion and clears review state when no pending suggestions remain for the variant.",
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "suggestion"
                  ],
                  "properties": {
                    "suggestion": {
                      "additionalProperties": false,
                      "type": "object",
                      "required": [
                        "id",
                        "status"
                      ],
                      "properties": {
                        "id": {
                          "format": "uuid",
                          "type": "string"
                        },
                        "status": {
                          "anyOf": [
                            {
                              "type": "string",
                              "enum": [
                                "approved"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "rejected"
                              ]
                            }
                          ]
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ]
      }
    },
    "/api/v1/catalog-v2/match-suggestions/{id}/reject": {
      "post": {
        "operationId": "postApiV1CatalogV2MatchSuggestionsByIdReject",
        "summary": "Reject a catalog match suggestion",
        "tags": [
          "catalog"
        ],
        "description": "Rejects a pending source-link match suggestion, unlinks it, and clears review state when appropriate.",
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "suggestion"
                  ],
                  "properties": {
                    "suggestion": {
                      "additionalProperties": false,
                      "type": "object",
                      "required": [
                        "id",
                        "status"
                      ],
                      "properties": {
                        "id": {
                          "format": "uuid",
                          "type": "string"
                        },
                        "status": {
                          "anyOf": [
                            {
                              "type": "string",
                              "enum": [
                                "approved"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "rejected"
                              ]
                            }
                          ]
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ]
      }
    },
    "/api/v1/catalog-v2/match-suggestions/{id}/create-separate": {
      "post": {
        "operationId": "postApiV1CatalogV2MatchSuggestionsByIdCreateSeparate",
        "summary": "Create a separate variant from a match suggestion",
        "tags": [
          "catalog"
        ],
        "description": "Turns a pending source variant into a new canonical product/variant and records the original suggestion as separated.",
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "variant"
                  ],
                  "properties": {
                    "variant": {
                      "additionalProperties": false,
                      "type": "object",
                      "required": [
                        "canonical_barcode",
                        "canonical_brand",
                        "canonical_gtin",
                        "canonical_option_values",
                        "canonical_sku",
                        "canonical_title",
                        "created_at",
                        "deleted_at",
                        "id",
                        "merged_into_id",
                        "needs_review",
                        "product_master_id",
                        "status",
                        "team_id",
                        "updated_at"
                      ],
                      "properties": {
                        "canonical_barcode": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "canonical_brand": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "canonical_gtin": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "canonical_option_values": {
                          "anyOf": [
                            {
                              "$comment": "json-value",
                              "description": "Arbitrary JSON value with nested arrays and objects."
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "canonical_sku": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "canonical_title": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "created_at": {
                          "format": "date-time",
                          "type": "string"
                        },
                        "deleted_at": {
                          "anyOf": [
                            {
                              "format": "date-time",
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "id": {
                          "format": "uuid",
                          "type": "string"
                        },
                        "merged_into_id": {
                          "anyOf": [
                            {
                              "format": "uuid",
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "needs_review": {
                          "type": "boolean"
                        },
                        "product_master_id": {
                          "format": "uuid",
                          "type": "string"
                        },
                        "status": {
                          "type": "string"
                        },
                        "team_id": {
                          "format": "uuid",
                          "type": "string"
                        },
                        "updated_at": {
                          "format": "date-time",
                          "type": "string"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ]
      }
    },
    "/api/v1/catalog-v2/match-suggestions/bulk/auto-resolve-safe": {
      "post": {
        "operationId": "postApiV1CatalogV2MatchSuggestionsBulkAutoResolveSafe",
        "summary": "Auto-resolve safe catalog match suggestions",
        "tags": [
          "catalog"
        ],
        "description": "Approves selected pending match suggestions whose confidence is at least 0.95, or returns a dry-run preview.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "suggestion_ids"
                ],
                "properties": {
                  "dry_run": {
                    "type": "boolean"
                  },
                  "suggestion_ids": {
                    "type": "array",
                    "items": {
                      "format": "uuid",
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "preview",
                    "resolved_count"
                  ],
                  "properties": {
                    "preview": {
                      "additionalProperties": false,
                      "type": "object",
                      "required": [
                        "auto_link",
                        "conflicts",
                        "selected",
                        "still_need_review"
                      ],
                      "properties": {
                        "auto_link": {
                          "type": "integer"
                        },
                        "conflicts": {
                          "type": "integer"
                        },
                        "selected": {
                          "type": "integer"
                        },
                        "still_need_review": {
                          "type": "integer"
                        }
                      }
                    },
                    "resolved_count": {
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ]
      }
    },
    "/api/v1/catalog-v2/match-suggestions/bulk/reject": {
      "post": {
        "operationId": "postApiV1CatalogV2MatchSuggestionsBulkReject",
        "summary": "Bulk reject catalog match suggestions",
        "tags": [
          "catalog"
        ],
        "description": "Rejects selected pending match suggestions, unlinks them, clears review flags, and records catalog events.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "suggestion_ids"
                ],
                "properties": {
                  "reason": {
                    "type": "string"
                  },
                  "suggestion_ids": {
                    "type": "array",
                    "items": {
                      "format": "uuid",
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "rejected_count"
                  ],
                  "properties": {
                    "rejected_count": {
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ]
      }
    },
    "/api/v1/variants/merge": {
      "post": {
        "operationId": "postApiV1VariantsMerge",
        "summary": "Merge catalog variants",
        "tags": [
          "catalog"
        ],
        "description": "Queues an asynchronous merge of loser variants into a winner variant and supports idempotent retry through the idempotency key header.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "winner_id",
                  "loser_ids",
                  "reason"
                ],
                "properties": {
                  "winner_id": {
                    "format": "uuid",
                    "type": "string"
                  },
                  "loser_ids": {
                    "minItems": 1,
                    "type": "array",
                    "items": {
                      "format": "uuid",
                      "type": "string"
                    }
                  },
                  "reason": {
                    "minLength": 1,
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "id",
                    "status"
                  ],
                  "properties": {
                    "id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "status": {
                      "anyOf": [
                        {
                          "type": "string",
                          "enum": [
                            "queued"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "duplicate"
                          ]
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "202": {
            "description": "Accepted - processing asynchronously",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "id",
                    "status"
                  ],
                  "properties": {
                    "id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "status": {
                      "anyOf": [
                        {
                          "type": "string",
                          "enum": [
                            "queued"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "duplicate"
                          ]
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "Conflict - resource state prevents the operation",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ]
      }
    },
    "/api/v1/variants/{id}/split": {
      "post": {
        "operationId": "postApiV1VariantsByIdSplit",
        "summary": "Split a merged catalog variant",
        "tags": [
          "catalog"
        ],
        "description": "Restores a merged variant to active review state and removes aliases so source links can be reassigned manually.",
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "ok"
                  ],
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ]
      }
    },
    "/api/v1/catalog-v2/source-links/{id}/undo": {
      "post": {
        "operationId": "postApiV1CatalogV2SourceLinksByIdUndo",
        "summary": "Undo a source link removal",
        "tags": [
          "catalog"
        ],
        "description": "Reactivates a previously unlinked source-to-variant link and records the undo action as a catalog event.",
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "source_link"
                  ],
                  "properties": {
                    "source_link": {
                      "additionalProperties": false,
                      "type": "object",
                      "required": [
                        "catalog_source_id",
                        "external_product_id",
                        "external_retailer_id",
                        "external_variant_id",
                        "id",
                        "linked_at",
                        "market_id",
                        "match_confidence",
                        "match_reason",
                        "team_id",
                        "unlinked_at",
                        "variant_master_id"
                      ],
                      "properties": {
                        "catalog_source_id": {
                          "format": "uuid",
                          "type": "string"
                        },
                        "external_product_id": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "external_retailer_id": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "external_variant_id": {
                          "type": "string"
                        },
                        "id": {
                          "format": "uuid",
                          "type": "string"
                        },
                        "linked_at": {
                          "format": "date-time",
                          "type": "string"
                        },
                        "market_id": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "match_confidence": {
                          "anyOf": [
                            {
                              "type": "number"
                            },
                            {
                              "type": "string"
                            }
                          ]
                        },
                        "match_reason": {
                          "type": "string"
                        },
                        "team_id": {
                          "format": "uuid",
                          "type": "string"
                        },
                        "unlinked_at": {
                          "anyOf": [
                            {
                              "format": "date-time",
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "variant_master_id": {
                          "format": "uuid",
                          "type": "string"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "Conflict - resource state prevents the operation",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ]
      }
    },
    "/api/v1/variants/{id}/override": {
      "post": {
        "operationId": "postApiV1VariantsByIdOverride",
        "summary": "Create a variant field override",
        "tags": [
          "catalog"
        ],
        "description": "Stores a manual field override or forced source selection for a team-owned catalog variant.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "field_name",
                  "override_type",
                  "reason"
                ],
                "properties": {
                  "field_name": {
                    "type": "string"
                  },
                  "override_type": {
                    "type": "string"
                  },
                  "override_value": {
                    "$comment": "json-value",
                    "description": "Arbitrary JSON value with nested arrays and objects."
                  },
                  "forced_source_id": {
                    "format": "uuid",
                    "type": "string"
                  },
                  "reason": {
                    "minLength": 1,
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "created_at",
                    "expires_at",
                    "field_name",
                    "forced_source_id",
                    "id",
                    "override_type",
                    "override_value",
                    "reason",
                    "revoked_at",
                    "team_id",
                    "user_id",
                    "variant_master_id"
                  ],
                  "properties": {
                    "created_at": {
                      "format": "date-time",
                      "type": "string"
                    },
                    "expires_at": {
                      "anyOf": [
                        {
                          "format": "date-time",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "field_name": {
                      "type": "string"
                    },
                    "forced_source_id": {
                      "anyOf": [
                        {
                          "format": "uuid",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "override_type": {
                      "type": "string"
                    },
                    "override_value": {
                      "anyOf": [
                        {
                          "$comment": "json-value",
                          "description": "Arbitrary JSON value with nested arrays and objects."
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "reason": {
                      "type": "string"
                    },
                    "revoked_at": {
                      "anyOf": [
                        {
                          "format": "date-time",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "team_id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "user_id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "variant_master_id": {
                      "format": "uuid",
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ]
      }
    },
    "/api/v1/integrations/{id}/progress": {
      "get": {
        "operationId": "getApiV1IntegrationsByIdProgress",
        "summary": "Get catalog integration sync progress",
        "tags": [
          "catalog"
        ],
        "description": "Returns sync progress rows for a catalog source after verifying the caller can read the owning team.",
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "items"
                  ],
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "additionalProperties": false,
                        "type": "object",
                        "required": [
                          "catalog_source_id",
                          "completed_at",
                          "created_at",
                          "id",
                          "items_processed",
                          "items_total",
                          "last_error",
                          "last_line_number",
                          "phase",
                          "started_at",
                          "status",
                          "team_id",
                          "updated_at"
                        ],
                        "properties": {
                          "catalog_source_id": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "completed_at": {
                            "anyOf": [
                              {
                                "format": "date-time",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "created_at": {
                            "format": "date-time",
                            "type": "string"
                          },
                          "id": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "items_processed": {
                            "anyOf": [
                              {
                                "type": "integer"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "items_total": {
                            "anyOf": [
                              {
                                "type": "integer"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "last_error": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "last_line_number": {
                            "anyOf": [
                              {
                                "type": "integer"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "phase": {
                            "type": "string"
                          },
                          "started_at": {
                            "anyOf": [
                              {
                                "format": "date-time",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "status": {
                            "type": "string"
                          },
                          "team_id": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "updated_at": {
                            "format": "date-time",
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ]
      }
    },
    "/api/v1/integrations/shopify/callback": {
      "post": {
        "operationId": "postApiV1IntegrationsShopifyCallback",
        "summary": "Register a Shopify catalog source callback",
        "tags": [
          "catalog"
        ],
        "description": "Creates the Shopify catalog source record for an authorized team after OAuth/callback setup completes.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "team_id",
                  "shop_domain"
                ],
                "properties": {
                  "team_id": {
                    "format": "uuid",
                    "type": "string"
                  },
                  "shop_domain": {
                    "type": "string"
                  },
                  "shopify_config_id": {
                    "format": "uuid",
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Resource created",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "config_json",
                    "connected_at",
                    "created_at",
                    "deleted_at",
                    "disconnected_at",
                    "display_name",
                    "external_id",
                    "id",
                    "shopify_config_id",
                    "status",
                    "team_id",
                    "type",
                    "updated_at",
                    "woocommerce_config_id"
                  ],
                  "properties": {
                    "config_json": {
                      "anyOf": [
                        {
                          "$comment": "json-value",
                          "description": "Arbitrary JSON value with nested arrays and objects."
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "connected_at": {
                      "format": "date-time",
                      "type": "string"
                    },
                    "created_at": {
                      "format": "date-time",
                      "type": "string"
                    },
                    "deleted_at": {
                      "anyOf": [
                        {
                          "format": "date-time",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "disconnected_at": {
                      "anyOf": [
                        {
                          "format": "date-time",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "display_name": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "external_id": {
                      "type": "string"
                    },
                    "id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "shopify_config_id": {
                      "anyOf": [
                        {
                          "format": "uuid",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "status": {
                      "type": "string"
                    },
                    "team_id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "type": {
                      "type": "string"
                    },
                    "updated_at": {
                      "format": "date-time",
                      "type": "string"
                    },
                    "woocommerce_config_id": {
                      "anyOf": [
                        {
                          "format": "uuid",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "Conflict - resource state prevents the operation",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ]
      }
    },
    "/api/v1/catalogs": {
      "get": {
        "operationId": "listCatalogs",
        "summary": "Get catalogs (server-side paginated)",
        "tags": [
          "catalogs"
        ],
        "description": "Returns a server-side paginated, filtered, sorted list of Meta Catalogs. Supports offset pagination, search, and multiple filter dimensions.",
        "parameters": [
          {
            "schema": {
              "minimum": 1,
              "maximum": 100,
              "default": 50,
              "type": "integer"
            },
            "in": "query",
            "name": "limit",
            "required": false
          },
          {
            "schema": {
              "minimum": 0,
              "default": 0,
              "type": "integer"
            },
            "in": "query",
            "name": "offset",
            "required": false
          },
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "query",
            "name": "member_id",
            "required": false
          },
          {
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "enum": [
                    "catalog_name"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "business_name"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "vertical"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "product_count"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "connected"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "created_at"
                  ]
                }
              ]
            },
            "in": "query",
            "name": "sort_by",
            "required": false
          },
          {
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "enum": [
                    "asc"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "desc"
                  ]
                }
              ]
            },
            "in": "query",
            "name": "sort_order",
            "required": false
          },
          {
            "schema": {
              "minLength": 2,
              "maxLength": 200,
              "type": "string"
            },
            "in": "query",
            "name": "search",
            "required": false
          },
          {
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "enum": [
                    "true"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "false"
                  ]
                }
              ]
            },
            "in": "query",
            "name": "connected",
            "required": false
          },
          {
            "schema": {
              "maxLength": 50,
              "type": "string"
            },
            "in": "query",
            "name": "vertical",
            "required": false
          },
          {
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "enum": [
                    "true"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "false"
                  ]
                }
              ]
            },
            "in": "query",
            "name": "is_active",
            "required": false
          },
          {
            "schema": {
              "maxLength": 100,
              "type": "string"
            },
            "in": "query",
            "name": "business_id",
            "required": false
          },
          {
            "schema": {
              "maxLength": 10,
              "type": "string"
            },
            "in": "query",
            "name": "platform",
            "required": false
          },
          {
            "schema": {
              "format": "date-time",
              "type": "string"
            },
            "in": "query",
            "name": "created_from",
            "required": false
          },
          {
            "schema": {
              "format": "date-time",
              "type": "string"
            },
            "in": "query",
            "name": "created_to",
            "required": false
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "items",
                    "total",
                    "counts"
                  ],
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "id",
                          "catalog_id",
                          "catalog_name",
                          "business_id",
                          "business_name",
                          "vertical",
                          "product_count",
                          "connected",
                          "is_active",
                          "created_at",
                          "updated_at"
                        ],
                        "properties": {
                          "id": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "catalog_id": {
                            "type": "string"
                          },
                          "catalog_name": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "business_id": {
                            "type": "string"
                          },
                          "business_name": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "vertical": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "product_count": {
                            "type": "integer"
                          },
                          "connected": {
                            "type": "boolean"
                          },
                          "is_active": {
                            "anyOf": [
                              {
                                "type": "boolean"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "platform": {
                            "type": "string"
                          },
                          "created_at": {
                            "format": "date-time",
                            "type": "string"
                          },
                          "updated_at": {
                            "anyOf": [
                              {
                                "format": "date-time",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "member_name": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "member_email": {
                            "type": "string"
                          }
                        }
                      }
                    },
                    "total": {
                      "type": "integer"
                    },
                    "counts": {
                      "type": "object",
                      "required": [
                        "connected",
                        "disconnected"
                      ],
                      "properties": {
                        "connected": {
                          "type": "integer"
                        },
                        "disconnected": {
                          "type": "integer"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "integer"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "integer"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "integer"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "createCatalog",
        "summary": "Create a new catalog on Meta",
        "tags": [
          "catalogs"
        ],
        "description": "Creates a Meta product catalog under the specified business, stores the catalog locally, and marks it connected for the resolved caller session.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "name",
                  "vertical",
                  "business_id"
                ],
                "properties": {
                  "name": {
                    "minLength": 1,
                    "maxLength": 200,
                    "type": "string"
                  },
                  "vertical": {
                    "anyOf": [
                      {
                        "type": "string",
                        "enum": [
                          "commerce"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "hotels"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "flights"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "destinations"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "vehicles"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "home_listings"
                        ]
                      }
                    ]
                  },
                  "business_id": {
                    "minLength": 1,
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "201": {
            "description": "Resource created",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "catalog_id",
                    "message"
                  ],
                  "properties": {
                    "catalog_id": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "integer"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "integer"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "integer"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "integer"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "Service unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "integer"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/catalogs/businesses": {
      "get": {
        "operationId": "listCatalogBusinesses",
        "summary": "List businesses for catalog filters",
        "tags": [
          "catalogs"
        ],
        "description": "Returns distinct Meta Business Manager ids and names represented by catalogs visible to the caller, respecting admin/team scoping.",
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "items"
                  ],
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "id",
                          "name"
                        ],
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "name": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "integer"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "integer"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "integer"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/catalogs/verticals": {
      "get": {
        "operationId": "listCatalogVerticals",
        "summary": "List verticals for catalog filters",
        "tags": [
          "catalogs"
        ],
        "description": "Returns distinct Meta catalog vertical values visible to the caller so clients can populate catalog filters without scanning the full catalog list.",
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "items"
                  ],
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "integer"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "integer"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "integer"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/catalogs/connect": {
      "post": {
        "operationId": "connectCatalogs",
        "summary": "Connect catalogs",
        "tags": [
          "catalogs"
        ],
        "description": "Sets the connected flag to true for the specified catalogs.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "catalogs"
                ],
                "properties": {
                  "catalogs": {
                    "minItems": 1,
                    "type": "array",
                    "items": {
                      "additionalProperties": false,
                      "type": "object",
                      "required": [
                        "catalog_id",
                        "business_id"
                      ],
                      "properties": {
                        "catalog_id": {
                          "type": "string"
                        },
                        "business_id": {
                          "type": "string"
                        }
                      }
                    }
                  },
                  "sheet_id": {
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "message"
                  ],
                  "properties": {
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "integer"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "integer"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "integer"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "integer"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "Service unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "integer"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/catalogs/disconnect": {
      "post": {
        "operationId": "disconnectCatalogs",
        "summary": "Disconnect catalogs",
        "tags": [
          "catalogs"
        ],
        "description": "Sets the connected flag to false for the specified catalogs.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "catalogs"
                ],
                "properties": {
                  "catalogs": {
                    "minItems": 1,
                    "type": "array",
                    "items": {
                      "additionalProperties": false,
                      "type": "object",
                      "required": [
                        "catalog_id",
                        "business_id"
                      ],
                      "properties": {
                        "catalog_id": {
                          "type": "string"
                        },
                        "business_id": {
                          "type": "string"
                        }
                      }
                    }
                  },
                  "sheet_id": {
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "message"
                  ],
                  "properties": {
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "integer"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "integer"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "integer"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "integer"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/catalogs/{catalogId}/product-sets": {
      "get": {
        "operationId": "listCatalogProductSets",
        "summary": "Get product sets for a catalog",
        "tags": [
          "catalogs"
        ],
        "description": "Returns product sets for the given catalog from Meta API in real-time. Supports pagination via next_page_url.",
        "parameters": [
          {
            "schema": {
              "minimum": 1,
              "maximum": 200,
              "default": 50,
              "type": "integer"
            },
            "in": "query",
            "name": "limit",
            "required": false
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "next_page_url",
            "required": false
          },
          {
            "schema": {
              "minLength": 1,
              "type": "string"
            },
            "in": "path",
            "name": "catalogId",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "items"
                  ],
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "id",
                          "name",
                          "filter",
                          "product_count"
                        ],
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "name": {
                            "type": "string"
                          },
                          "filter": {
                            "anyOf": [
                              {
                                "$comment": "json-value",
                                "description": "Arbitrary JSON value with nested arrays and objects."
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "product_count": {
                            "type": "integer"
                          }
                        }
                      }
                    },
                    "next_page_url": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "integer"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "integer"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "integer"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "integer"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "integer"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "createCatalogProductSet",
        "summary": "Create a product set",
        "tags": [
          "catalogs"
        ],
        "description": "Creates a new product set in the given catalog via Meta API.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "name"
                ],
                "properties": {
                  "name": {
                    "minLength": 1,
                    "maxLength": 500,
                    "type": "string"
                  },
                  "filter": {
                    "description": "JSON object with nested arrays and objects.",
                    "type": "object",
                    "additionalProperties": {
                      "$comment": "json-value",
                      "description": "Arbitrary JSON value with nested arrays and objects."
                    }
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "schema": {
              "minLength": 1,
              "type": "string"
            },
            "in": "path",
            "name": "catalogId",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "201": {
            "description": "Resource created",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "id",
                    "name",
                    "filter",
                    "product_count"
                  ],
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "name": {
                      "type": "string"
                    },
                    "filter": {
                      "anyOf": [
                        {
                          "$comment": "json-value",
                          "description": "Arbitrary JSON value with nested arrays and objects."
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "product_count": {
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "integer"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "integer"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "integer"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "integer"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "integer"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "Service unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "integer"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/catalogs/{catalogId}/product-sets/{setId}/products": {
      "get": {
        "operationId": "listProductSetProducts",
        "summary": "Get products for a product set",
        "tags": [
          "catalogs"
        ],
        "description": "Returns products for the given product set from Meta API in real-time. Supports pagination via next_page_url.",
        "parameters": [
          {
            "schema": {
              "minimum": 1,
              "maximum": 200,
              "default": 50,
              "type": "integer"
            },
            "in": "query",
            "name": "limit",
            "required": false
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "next_page_url",
            "required": false
          },
          {
            "schema": {
              "minLength": 1,
              "type": "string"
            },
            "in": "path",
            "name": "catalogId",
            "required": true
          },
          {
            "schema": {
              "minLength": 1,
              "type": "string"
            },
            "in": "path",
            "name": "setId",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "items"
                  ],
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "id",
                          "retailer_id"
                        ],
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "name": {
                            "type": "string"
                          },
                          "price": {
                            "type": "string"
                          },
                          "sale_price": {
                            "type": "string"
                          },
                          "currency": {
                            "type": "string"
                          },
                          "availability": {
                            "type": "string"
                          },
                          "condition": {
                            "type": "string"
                          },
                          "image_url": {
                            "type": "string"
                          },
                          "url": {
                            "type": "string"
                          },
                          "brand": {
                            "type": "string"
                          },
                          "category": {
                            "type": "string"
                          },
                          "product_type": {
                            "type": "string"
                          },
                          "retailer_id": {
                            "type": "string"
                          },
                          "custom_label_0": {
                            "type": "string"
                          },
                          "custom_label_1": {
                            "type": "string"
                          },
                          "custom_label_2": {
                            "type": "string"
                          },
                          "custom_label_3": {
                            "type": "string"
                          },
                          "custom_label_4": {
                            "type": "string"
                          },
                          "description": {
                            "type": "string"
                          },
                          "review_status": {
                            "type": "string"
                          },
                          "rejection_reasons": {
                            "type": "array",
                            "items": {
                              "$comment": "json-value",
                              "description": "Arbitrary JSON value with nested arrays and objects."
                            }
                          },
                          "visibility": {
                            "type": "string"
                          },
                          "item_group_id": {
                            "type": "string"
                          },
                          "additional_image_urls": {
                            "type": "array",
                            "items": {
                              "type": "string"
                            }
                          },
                          "video": {
                            "anyOf": [
                              {
                                "type": "object",
                                "required": [
                                  "id"
                                ],
                                "properties": {
                                  "id": {
                                    "type": "string"
                                  },
                                  "url": {
                                    "type": "string"
                                  }
                                }
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "in_active_campaign": {
                            "type": "boolean"
                          }
                        }
                      }
                    },
                    "next_page_url": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "integer"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "integer"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "integer"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "integer"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "integer"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/catalogs/{catalogId}/video/{videoId}": {
      "get": {
        "operationId": "getCatalogVideoSource",
        "summary": "Get video source URL",
        "tags": [
          "catalogs"
        ],
        "description": "Returns the playable source URL for a product video from Meta API.",
        "parameters": [
          {
            "schema": {
              "minLength": 1,
              "type": "string"
            },
            "in": "path",
            "name": "catalogId",
            "required": true
          },
          {
            "schema": {
              "minLength": 1,
              "type": "string"
            },
            "in": "path",
            "name": "videoId",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "source"
                  ],
                  "properties": {
                    "source": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "integer"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "integer"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "integer"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "integer"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "integer"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/catalogs/{catalogId}/connect-pixel": {
      "post": {
        "operationId": "connectCatalogPixel",
        "summary": "Connect a pixel to a catalog",
        "tags": [
          "catalogs"
        ],
        "description": "Assigns a Meta Pixel as an external event source for the given catalog.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "pixel_id"
                ],
                "properties": {
                  "pixel_id": {
                    "minLength": 1,
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "schema": {
              "minLength": 1,
              "type": "string"
            },
            "in": "path",
            "name": "catalogId",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "message"
                  ],
                  "properties": {
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "integer"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "integer"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "integer"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "integer"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "integer"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/catalogs/{catalogId}/disconnect-pixel": {
      "post": {
        "operationId": "disconnectCatalogPixel",
        "summary": "Disconnect a pixel from a catalog",
        "tags": [
          "catalogs"
        ],
        "description": "Removes a Meta Pixel as an external event source from the given catalog.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "pixel_id"
                ],
                "properties": {
                  "pixel_id": {
                    "minLength": 1,
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "schema": {
              "minLength": 1,
              "type": "string"
            },
            "in": "path",
            "name": "catalogId",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "message"
                  ],
                  "properties": {
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "integer"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "integer"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "integer"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "integer"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "integer"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/catalogs/{catalogId}/pixels": {
      "get": {
        "operationId": "listCatalogPixels",
        "summary": "Get pixels connected to a catalog",
        "tags": [
          "catalogs"
        ],
        "description": "Returns the list of Meta Pixels (external event sources) connected to the given catalog.",
        "parameters": [
          {
            "schema": {
              "minLength": 1,
              "type": "string"
            },
            "in": "path",
            "name": "catalogId",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "items"
                  ],
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "id",
                          "name"
                        ],
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "name": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "integer"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "integer"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "integer"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "integer"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "integer"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/catalogs/{catalogId}/share-permissions": {
      "post": {
        "operationId": "shareCatalogPermissions",
        "summary": "Share catalog permissions with business users",
        "tags": [
          "catalogs"
        ],
        "description": "Assigns the specified permission level on a catalog to one or more business users.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "business_user_ids",
                  "business_id",
                  "permission_level"
                ],
                "properties": {
                  "business_user_ids": {
                    "minItems": 1,
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  },
                  "business_id": {
                    "type": "string"
                  },
                  "permission_level": {
                    "anyOf": [
                      {
                        "type": "string",
                        "enum": [
                          "FULL"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "ADVERTISE"
                        ]
                      }
                    ]
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "schema": {
              "minLength": 1,
              "type": "string"
            },
            "in": "path",
            "name": "catalogId",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "results",
                    "total_success",
                    "total_failed"
                  ],
                  "properties": {
                    "results": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "asset_id",
                          "business_user_id",
                          "status"
                        ],
                        "properties": {
                          "asset_id": {
                            "type": "string"
                          },
                          "business_user_id": {
                            "type": "string"
                          },
                          "status": {
                            "anyOf": [
                              {
                                "type": "string",
                                "enum": [
                                  "SUCCESS"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "FAILED"
                                ]
                              }
                            ]
                          },
                          "error": {
                            "type": "string"
                          }
                        }
                      }
                    },
                    "total_success": {
                      "type": "integer"
                    },
                    "total_failed": {
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "integer"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "integer"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "integer"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "integer"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "integer"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/catalogs/{catalogId}/products/preview": {
      "post": {
        "operationId": "previewCatalogProducts",
        "summary": "Preview products matching a filter",
        "tags": [
          "catalogs"
        ],
        "description": "Returns up to `limit` products in the catalog matching the given filter, enriched with an in_active_campaign flag.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "properties": {
                  "filter": {
                    "description": "JSON object with nested arrays and objects.",
                    "type": "object",
                    "additionalProperties": {
                      "$comment": "json-value",
                      "description": "Arbitrary JSON value with nested arrays and objects."
                    }
                  },
                  "limit": {
                    "minimum": 1,
                    "maximum": 100,
                    "default": 25,
                    "type": "integer"
                  },
                  "next_page_url": {
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "schema": {
              "minLength": 1,
              "type": "string"
            },
            "in": "path",
            "name": "catalogId",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "items"
                  ],
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "id",
                          "name",
                          "price",
                          "currency",
                          "availability",
                          "image_url",
                          "retailer_id",
                          "in_active_campaign"
                        ],
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "name": {
                            "type": "string"
                          },
                          "price": {
                            "type": "string"
                          },
                          "currency": {
                            "type": "string"
                          },
                          "availability": {
                            "type": "string"
                          },
                          "image_url": {
                            "type": "string"
                          },
                          "retailer_id": {
                            "type": "string"
                          },
                          "in_active_campaign": {
                            "type": "boolean"
                          }
                        }
                      }
                    },
                    "next_page_url": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "integer"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "integer"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "integer"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "integer"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "integer"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/catalogs/{catalogId}/product-sets/{setId}": {
      "get": {
        "operationId": "getCatalogProductSet",
        "summary": "Get product set details",
        "tags": [
          "catalogs"
        ],
        "description": "Returns details (name, filter, product count) for a single product set from Meta API.",
        "parameters": [
          {
            "schema": {
              "minLength": 1,
              "type": "string"
            },
            "in": "path",
            "name": "catalogId",
            "required": true
          },
          {
            "schema": {
              "minLength": 1,
              "type": "string"
            },
            "in": "path",
            "name": "setId",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "id",
                    "name",
                    "filter",
                    "product_count"
                  ],
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "name": {
                      "type": "string"
                    },
                    "filter": {
                      "anyOf": [
                        {
                          "$comment": "json-value",
                          "description": "Arbitrary JSON value with nested arrays and objects."
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "product_count": {
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "integer"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "integer"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "integer"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "integer"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "integer"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      },
      "put": {
        "operationId": "updateCatalogProductSet",
        "summary": "Update a product set",
        "tags": [
          "catalogs"
        ],
        "description": "Updates name and/or filter of an existing product set via Meta API.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "minProperties": 1,
                "type": "object",
                "properties": {
                  "name": {
                    "minLength": 1,
                    "maxLength": 500,
                    "type": "string"
                  },
                  "filter": {
                    "description": "JSON object with nested arrays and objects.",
                    "type": "object",
                    "additionalProperties": {
                      "$comment": "json-value",
                      "description": "Arbitrary JSON value with nested arrays and objects."
                    }
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "schema": {
              "minLength": 1,
              "type": "string"
            },
            "in": "path",
            "name": "catalogId",
            "required": true
          },
          {
            "schema": {
              "minLength": 1,
              "type": "string"
            },
            "in": "path",
            "name": "setId",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "id",
                    "name",
                    "filter",
                    "product_count"
                  ],
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "name": {
                      "type": "string"
                    },
                    "filter": {
                      "anyOf": [
                        {
                          "$comment": "json-value",
                          "description": "Arbitrary JSON value with nested arrays and objects."
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "product_count": {
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "integer"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "integer"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "integer"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "integer"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "integer"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "Service unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "integer"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      },
      "delete": {
        "operationId": "deleteCatalogProductSet",
        "summary": "Delete a product set",
        "tags": [
          "catalogs"
        ],
        "description": "Permanently deletes a product set from the catalog via Meta API.",
        "parameters": [
          {
            "schema": {
              "minLength": 1,
              "type": "string"
            },
            "in": "path",
            "name": "catalogId",
            "required": true
          },
          {
            "schema": {
              "minLength": 1,
              "type": "string"
            },
            "in": "path",
            "name": "setId",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "message"
                  ],
                  "properties": {
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "integer"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "integer"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "integer"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "integer"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "integer"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "Service unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "integer"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/catalogs/{catalogId}": {
      "patch": {
        "operationId": "updateCatalog",
        "summary": "Update a catalog on Meta",
        "tags": [
          "catalogs"
        ],
        "description": "Updates mutable catalog fields on Meta, currently the catalog name, and mirrors the changed name into the local catalog row.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "name"
                ],
                "properties": {
                  "name": {
                    "minLength": 1,
                    "maxLength": 200,
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "schema": {
              "minLength": 1,
              "type": "string"
            },
            "in": "path",
            "name": "catalogId",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "message"
                  ],
                  "properties": {
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "integer"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "integer"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "integer"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "integer"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "integer"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      },
      "delete": {
        "operationId": "deleteCatalog",
        "summary": "Delete a catalog from Meta",
        "tags": [
          "catalogs"
        ],
        "description": "Deletes the catalog from Meta using a team-scoped token and removes or deactivates the local catalog representation when the upstream delete succeeds.",
        "parameters": [
          {
            "schema": {
              "minLength": 1,
              "type": "string"
            },
            "in": "path",
            "name": "catalogId",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "message"
                  ],
                  "properties": {
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "integer"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "integer"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "integer"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "integer"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "integer"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/catalogs/{catalogId}/diagnostics": {
      "get": {
        "operationId": "getCatalogDiagnostics",
        "summary": "Get catalog diagnostics",
        "tags": [
          "catalogs"
        ],
        "description": "Returns diagnostics for a catalog from Meta API with 30-minute cache.",
        "parameters": [
          {
            "schema": {
              "minLength": 1,
              "type": "string"
            },
            "in": "path",
            "name": "catalogId",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "diagnostics",
                    "event_stats",
                    "cached"
                  ],
                  "properties": {
                    "diagnostics": {
                      "type": "array",
                      "items": {
                        "$comment": "json-value",
                        "description": "Arbitrary JSON value with nested arrays and objects."
                      }
                    },
                    "event_stats": {
                      "type": "array",
                      "items": {
                        "$comment": "json-value",
                        "description": "Arbitrary JSON value with nested arrays and objects."
                      }
                    },
                    "cached": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "integer"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "integer"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "integer"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "integer"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "integer"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/catalogs/{catalogId}/event-stats": {
      "get": {
        "operationId": "getCatalogEventStats",
        "summary": "Get catalog event stats",
        "tags": [
          "catalogs"
        ],
        "description": "Returns event stats for a catalog from Meta API with 30-minute cache.",
        "parameters": [
          {
            "schema": {
              "minLength": 1,
              "type": "string"
            },
            "in": "path",
            "name": "catalogId",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "event_stats",
                    "cached"
                  ],
                  "properties": {
                    "event_stats": {
                      "type": "array",
                      "items": {
                        "$comment": "json-value",
                        "description": "Arbitrary JSON value with nested arrays and objects."
                      }
                    },
                    "cached": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "integer"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "integer"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "integer"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "integer"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "integer"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/chat/presets": {
      "get": {
        "operationId": "getApiV1ChatPresets",
        "summary": "List AI Chat presets",
        "tags": [
          "ai-chat"
        ],
        "description": "Returns visible personal, team, and managed AI chat presets for the authenticated user.",
        "parameters": [
          {
            "schema": {
              "default": false,
              "type": "boolean"
            },
            "in": "query",
            "name": "include_deleted",
            "required": false
          }
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "items"
                  ],
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "additionalProperties": false,
                        "type": "object",
                        "required": [
                          "allowed_sources",
                          "category",
                          "created_at",
                          "default_context_schema",
                          "description",
                          "id",
                          "metadata",
                          "name",
                          "output_format",
                          "owner_id",
                          "prompt",
                          "required_input_schema",
                          "risk_tier",
                          "team_id",
                          "updated_at",
                          "usage_count",
                          "version",
                          "visibility"
                        ],
                        "properties": {
                          "allowed_sources": {
                            "type": "array",
                            "items": {
                              "type": "string"
                            }
                          },
                          "category": {
                            "type": "string"
                          },
                          "created_at": {
                            "format": "date-time",
                            "type": "string"
                          },
                          "default_context_schema": {
                            "$comment": "json-value"
                          },
                          "description": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "id": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "metadata": {
                            "$comment": "json-value"
                          },
                          "name": {
                            "type": "string"
                          },
                          "output_format": {
                            "type": "string"
                          },
                          "owner_id": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "prompt": {
                            "type": "string"
                          },
                          "required_input_schema": {
                            "$comment": "json-value"
                          },
                          "risk_tier": {
                            "anyOf": [
                              {
                                "type": "string",
                                "enum": [
                                  "low"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "medium"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "high"
                                ]
                              }
                            ]
                          },
                          "team_id": {
                            "anyOf": [
                              {
                                "format": "uuid",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "updated_at": {
                            "format": "date-time",
                            "type": "string"
                          },
                          "usage_count": {
                            "type": "integer"
                          },
                          "version": {
                            "type": "integer"
                          },
                          "visibility": {
                            "anyOf": [
                              {
                                "type": "string",
                                "enum": [
                                  "personal"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "team"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "managed"
                                ]
                              }
                            ]
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "postApiV1ChatPresets",
        "summary": "Create an AI Chat preset",
        "tags": [
          "ai-chat"
        ],
        "description": "Creates a personal, team, or managed AI chat preset with its prompt and JSON input contracts.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "name",
                  "prompt",
                  "visibility"
                ],
                "properties": {
                  "allowed_sources": {
                    "maxItems": 12,
                    "type": "array",
                    "items": {
                      "maxLength": 80,
                      "type": "string"
                    }
                  },
                  "category": {
                    "maxLength": 40,
                    "type": "string"
                  },
                  "default_context_schema": {
                    "$comment": "json-value"
                  },
                  "description": {
                    "anyOf": [
                      {
                        "maxLength": 500,
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "metadata": {
                    "$comment": "json-value"
                  },
                  "name": {
                    "minLength": 1,
                    "maxLength": 120,
                    "type": "string"
                  },
                  "output_format": {
                    "maxLength": 40,
                    "type": "string"
                  },
                  "prompt": {
                    "minLength": 1,
                    "maxLength": 8000,
                    "type": "string"
                  },
                  "required_input_schema": {
                    "$comment": "json-value"
                  },
                  "risk_tier": {
                    "anyOf": [
                      {
                        "type": "string",
                        "enum": [
                          "low"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "medium"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "high"
                        ]
                      }
                    ]
                  },
                  "team_id": {
                    "anyOf": [
                      {
                        "format": "uuid",
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "visibility": {
                    "anyOf": [
                      {
                        "type": "string",
                        "enum": [
                          "personal"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "team"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "managed"
                        ]
                      }
                    ]
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "201": {
            "description": "Resource created",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "allowed_sources",
                    "category",
                    "created_at",
                    "default_context_schema",
                    "description",
                    "id",
                    "metadata",
                    "name",
                    "output_format",
                    "owner_id",
                    "prompt",
                    "required_input_schema",
                    "risk_tier",
                    "team_id",
                    "updated_at",
                    "usage_count",
                    "version",
                    "visibility"
                  ],
                  "properties": {
                    "allowed_sources": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "category": {
                      "type": "string"
                    },
                    "created_at": {
                      "format": "date-time",
                      "type": "string"
                    },
                    "default_context_schema": {
                      "$comment": "json-value"
                    },
                    "description": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "metadata": {
                      "$comment": "json-value"
                    },
                    "name": {
                      "type": "string"
                    },
                    "output_format": {
                      "type": "string"
                    },
                    "owner_id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "prompt": {
                      "type": "string"
                    },
                    "required_input_schema": {
                      "$comment": "json-value"
                    },
                    "risk_tier": {
                      "anyOf": [
                        {
                          "type": "string",
                          "enum": [
                            "low"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "medium"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "high"
                          ]
                        }
                      ]
                    },
                    "team_id": {
                      "anyOf": [
                        {
                          "format": "uuid",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "updated_at": {
                      "format": "date-time",
                      "type": "string"
                    },
                    "usage_count": {
                      "type": "integer"
                    },
                    "version": {
                      "type": "integer"
                    },
                    "visibility": {
                      "anyOf": [
                        {
                          "type": "string",
                          "enum": [
                            "personal"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "team"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "managed"
                          ]
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "Conflict - resource state prevents the operation",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/chat/presets/{id}": {
      "patch": {
        "operationId": "patchApiV1ChatPresetsById",
        "summary": "Update an AI Chat preset",
        "tags": [
          "ai-chat"
        ],
        "description": "Updates editable fields on an existing AI chat preset visible to the authenticated user.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "properties": {
                  "allowed_sources": {
                    "maxItems": 12,
                    "type": "array",
                    "items": {
                      "maxLength": 80,
                      "type": "string"
                    }
                  },
                  "category": {
                    "maxLength": 40,
                    "type": "string"
                  },
                  "default_context_schema": {
                    "$comment": "json-value"
                  },
                  "description": {
                    "anyOf": [
                      {
                        "maxLength": 500,
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "metadata": {
                    "$comment": "json-value"
                  },
                  "name": {
                    "minLength": 1,
                    "maxLength": 120,
                    "type": "string"
                  },
                  "output_format": {
                    "maxLength": 40,
                    "type": "string"
                  },
                  "prompt": {
                    "minLength": 1,
                    "maxLength": 8000,
                    "type": "string"
                  },
                  "required_input_schema": {
                    "$comment": "json-value"
                  },
                  "risk_tier": {
                    "anyOf": [
                      {
                        "type": "string",
                        "enum": [
                          "low"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "medium"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "high"
                        ]
                      }
                    ]
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "allowed_sources",
                    "category",
                    "created_at",
                    "default_context_schema",
                    "description",
                    "id",
                    "metadata",
                    "name",
                    "output_format",
                    "owner_id",
                    "prompt",
                    "required_input_schema",
                    "risk_tier",
                    "team_id",
                    "updated_at",
                    "usage_count",
                    "version",
                    "visibility"
                  ],
                  "properties": {
                    "allowed_sources": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "category": {
                      "type": "string"
                    },
                    "created_at": {
                      "format": "date-time",
                      "type": "string"
                    },
                    "default_context_schema": {
                      "$comment": "json-value"
                    },
                    "description": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "metadata": {
                      "$comment": "json-value"
                    },
                    "name": {
                      "type": "string"
                    },
                    "output_format": {
                      "type": "string"
                    },
                    "owner_id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "prompt": {
                      "type": "string"
                    },
                    "required_input_schema": {
                      "$comment": "json-value"
                    },
                    "risk_tier": {
                      "anyOf": [
                        {
                          "type": "string",
                          "enum": [
                            "low"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "medium"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "high"
                          ]
                        }
                      ]
                    },
                    "team_id": {
                      "anyOf": [
                        {
                          "format": "uuid",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "updated_at": {
                      "format": "date-time",
                      "type": "string"
                    },
                    "usage_count": {
                      "type": "integer"
                    },
                    "version": {
                      "type": "integer"
                    },
                    "visibility": {
                      "anyOf": [
                        {
                          "type": "string",
                          "enum": [
                            "personal"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "team"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "managed"
                          ]
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "Conflict - resource state prevents the operation",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          }
        }
      },
      "delete": {
        "operationId": "deleteApiV1ChatPresetsById",
        "summary": "Delete an AI Chat preset",
        "tags": [
          "ai-chat"
        ],
        "description": "Soft-deletes an AI chat preset within the user accessible scope.",
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "204": {
            "description": "No content"
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/chat/presets/{id}/use": {
      "post": {
        "operationId": "postApiV1ChatPresetsByIdUse",
        "summary": "Record AI Chat preset usage",
        "tags": [
          "ai-chat"
        ],
        "description": "Increments usage counters and returns the selected AI chat preset.",
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "allowed_sources",
                    "category",
                    "created_at",
                    "default_context_schema",
                    "description",
                    "id",
                    "metadata",
                    "name",
                    "output_format",
                    "owner_id",
                    "prompt",
                    "required_input_schema",
                    "risk_tier",
                    "team_id",
                    "updated_at",
                    "usage_count",
                    "version",
                    "visibility"
                  ],
                  "properties": {
                    "allowed_sources": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "category": {
                      "type": "string"
                    },
                    "created_at": {
                      "format": "date-time",
                      "type": "string"
                    },
                    "default_context_schema": {
                      "$comment": "json-value"
                    },
                    "description": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "metadata": {
                      "$comment": "json-value"
                    },
                    "name": {
                      "type": "string"
                    },
                    "output_format": {
                      "type": "string"
                    },
                    "owner_id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "prompt": {
                      "type": "string"
                    },
                    "required_input_schema": {
                      "$comment": "json-value"
                    },
                    "risk_tier": {
                      "anyOf": [
                        {
                          "type": "string",
                          "enum": [
                            "low"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "medium"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "high"
                          ]
                        }
                      ]
                    },
                    "team_id": {
                      "anyOf": [
                        {
                          "format": "uuid",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "updated_at": {
                      "format": "date-time",
                      "type": "string"
                    },
                    "usage_count": {
                      "type": "integer"
                    },
                    "version": {
                      "type": "integer"
                    },
                    "visibility": {
                      "anyOf": [
                        {
                          "type": "string",
                          "enum": [
                            "personal"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "team"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "managed"
                          ]
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/chat/projects": {
      "get": {
        "operationId": "getApiV1ChatProjects",
        "summary": "List chat projects",
        "tags": [
          "ai-chat"
        ],
        "description": "Returns all chat projects for the authenticated user.",
        "parameters": [
          {
            "schema": {
              "default": false,
              "type": "boolean"
            },
            "in": "query",
            "name": "include_archived",
            "required": false
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object",
                  "required": [
                    "items"
                  ],
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "additionalProperties": true,
                        "type": "object",
                        "required": [
                          "id",
                          "name",
                          "description",
                          "instructions",
                          "color",
                          "is_archived",
                          "created_at",
                          "updated_at"
                        ],
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "name": {
                            "type": "string"
                          },
                          "description": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "instructions": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "color": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "memory_enabled": {
                            "type": "boolean"
                          },
                          "is_archived": {
                            "type": "boolean"
                          },
                          "files": {
                            "type": "array",
                            "items": {
                              "additionalProperties": true,
                              "type": "object",
                              "required": [
                                "id",
                                "file_name",
                                "file_type",
                                "file_size",
                                "created_at"
                              ],
                              "properties": {
                                "id": {
                                  "type": "string"
                                },
                                "file_name": {
                                  "type": "string"
                                },
                                "file_type": {
                                  "type": "string"
                                },
                                "file_url": {
                                  "type": "string"
                                },
                                "file_size": {
                                  "anyOf": [
                                    {
                                      "type": "integer"
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "project_id": {
                                  "type": "string"
                                },
                                "created_at": {
                                  "format": "date-time",
                                  "type": "string"
                                }
                              }
                            }
                          },
                          "chat_count": {
                            "type": "integer"
                          },
                          "created_at": {
                            "format": "date-time",
                            "type": "string"
                          },
                          "updated_at": {
                            "format": "date-time",
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "postApiV1ChatProjects",
        "summary": "Create a chat project",
        "tags": [
          "ai-chat"
        ],
        "description": "Creates a standalone AI chat project for organizing sessions and project file references.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "name"
                ],
                "properties": {
                  "name": {
                    "minLength": 1,
                    "maxLength": 255,
                    "type": "string"
                  },
                  "description": {
                    "maxLength": 2000,
                    "type": "string"
                  },
                  "instructions": {
                    "maxLength": 5000,
                    "type": "string"
                  },
                  "color": {
                    "pattern": "^#[0-9A-Fa-f]{6}$",
                    "type": "string"
                  },
                  "memory_enabled": {
                    "type": "boolean"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "201": {
            "description": "Resource created",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object",
                  "required": [
                    "id",
                    "name",
                    "description",
                    "instructions",
                    "color",
                    "is_archived",
                    "created_at",
                    "updated_at"
                  ],
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "name": {
                      "type": "string"
                    },
                    "description": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "instructions": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "color": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "memory_enabled": {
                      "type": "boolean"
                    },
                    "is_archived": {
                      "type": "boolean"
                    },
                    "files": {
                      "type": "array",
                      "items": {
                        "additionalProperties": true,
                        "type": "object",
                        "required": [
                          "id",
                          "file_name",
                          "file_type",
                          "file_size",
                          "created_at"
                        ],
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "file_name": {
                            "type": "string"
                          },
                          "file_type": {
                            "type": "string"
                          },
                          "file_url": {
                            "type": "string"
                          },
                          "file_size": {
                            "anyOf": [
                              {
                                "type": "integer"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "project_id": {
                            "type": "string"
                          },
                          "created_at": {
                            "format": "date-time",
                            "type": "string"
                          }
                        }
                      }
                    },
                    "chat_count": {
                      "type": "integer"
                    },
                    "created_at": {
                      "format": "date-time",
                      "type": "string"
                    },
                    "updated_at": {
                      "format": "date-time",
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/chat/projects/{id}": {
      "get": {
        "operationId": "getApiV1ChatProjectsById",
        "summary": "Get chat project details",
        "tags": [
          "ai-chat"
        ],
        "description": "Returns one chat project with files, memory flag, and active chat count.",
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object",
                  "required": [
                    "id",
                    "name",
                    "description",
                    "instructions",
                    "color",
                    "is_archived",
                    "created_at",
                    "updated_at"
                  ],
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "name": {
                      "type": "string"
                    },
                    "description": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "instructions": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "color": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "memory_enabled": {
                      "type": "boolean"
                    },
                    "is_archived": {
                      "type": "boolean"
                    },
                    "files": {
                      "type": "array",
                      "items": {
                        "additionalProperties": true,
                        "type": "object",
                        "required": [
                          "id",
                          "file_name",
                          "file_type",
                          "file_size",
                          "created_at"
                        ],
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "file_name": {
                            "type": "string"
                          },
                          "file_type": {
                            "type": "string"
                          },
                          "file_url": {
                            "type": "string"
                          },
                          "file_size": {
                            "anyOf": [
                              {
                                "type": "integer"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "project_id": {
                            "type": "string"
                          },
                          "created_at": {
                            "format": "date-time",
                            "type": "string"
                          }
                        }
                      }
                    },
                    "chat_count": {
                      "type": "integer"
                    },
                    "created_at": {
                      "format": "date-time",
                      "type": "string"
                    },
                    "updated_at": {
                      "format": "date-time",
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      },
      "patch": {
        "operationId": "patchApiV1ChatProjectsById",
        "summary": "Update a chat project",
        "tags": [
          "ai-chat"
        ],
        "description": "Updates chat project metadata, archive state, and optional memory flag.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "properties": {
                  "name": {
                    "minLength": 1,
                    "maxLength": 255,
                    "type": "string"
                  },
                  "description": {
                    "anyOf": [
                      {
                        "maxLength": 2000,
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "instructions": {
                    "anyOf": [
                      {
                        "maxLength": 5000,
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "color": {
                    "anyOf": [
                      {
                        "pattern": "^#[0-9A-Fa-f]{6}$",
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "memory_enabled": {
                    "type": "boolean"
                  },
                  "is_archived": {
                    "type": "boolean"
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object",
                  "required": [
                    "id",
                    "name",
                    "description",
                    "instructions",
                    "color",
                    "is_archived",
                    "created_at",
                    "updated_at"
                  ],
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "name": {
                      "type": "string"
                    },
                    "description": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "instructions": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "color": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "memory_enabled": {
                      "type": "boolean"
                    },
                    "is_archived": {
                      "type": "boolean"
                    },
                    "files": {
                      "type": "array",
                      "items": {
                        "additionalProperties": true,
                        "type": "object",
                        "required": [
                          "id",
                          "file_name",
                          "file_type",
                          "file_size",
                          "created_at"
                        ],
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "file_name": {
                            "type": "string"
                          },
                          "file_type": {
                            "type": "string"
                          },
                          "file_url": {
                            "type": "string"
                          },
                          "file_size": {
                            "anyOf": [
                              {
                                "type": "integer"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "project_id": {
                            "type": "string"
                          },
                          "created_at": {
                            "format": "date-time",
                            "type": "string"
                          }
                        }
                      }
                    },
                    "chat_count": {
                      "type": "integer"
                    },
                    "created_at": {
                      "format": "date-time",
                      "type": "string"
                    },
                    "updated_at": {
                      "format": "date-time",
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      },
      "delete": {
        "operationId": "deleteApiV1ChatProjectsById",
        "summary": "Delete a chat project",
        "tags": [
          "ai-chat"
        ],
        "description": "Deletes a chat project. Chat sessions are unlinked (not deleted).",
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "204": {
            "description": "No content"
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/chat/projects/{id}/files": {
      "post": {
        "operationId": "postApiV1ChatProjectsByIdFiles",
        "summary": "Add a file reference to a chat project",
        "tags": [
          "ai-chat"
        ],
        "description": "Adds an already uploaded supported file reference to a chat project.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "file_name",
                  "file_url",
                  "file_type"
                ],
                "properties": {
                  "file_name": {
                    "minLength": 1,
                    "maxLength": 500,
                    "type": "string"
                  },
                  "file_url": {
                    "minLength": 1,
                    "type": "string"
                  },
                  "file_type": {
                    "minLength": 1,
                    "maxLength": 120,
                    "type": "string"
                  },
                  "file_size": {
                    "minimum": 0,
                    "type": "integer"
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "201": {
            "description": "Resource created",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object",
                  "required": [
                    "id",
                    "file_name",
                    "file_type",
                    "file_size",
                    "created_at"
                  ],
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "file_name": {
                      "type": "string"
                    },
                    "file_type": {
                      "type": "string"
                    },
                    "file_url": {
                      "type": "string"
                    },
                    "file_size": {
                      "anyOf": [
                        {
                          "type": "integer"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "project_id": {
                      "type": "string"
                    },
                    "created_at": {
                      "format": "date-time",
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/chat/projects/{id}/files/{fileId}": {
      "delete": {
        "operationId": "deleteApiV1ChatProjectsByIdFilesByFileId",
        "summary": "Remove a file from a chat project",
        "tags": [
          "ai-chat"
        ],
        "description": "Removes a file reference from a chat project owned by the authenticated user.",
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "path",
            "name": "fileId",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "204": {
            "description": "No content"
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/chat/projects/{id}/sessions/{sessionId}": {
      "post": {
        "operationId": "postApiV1ChatProjectsByIdSessionsBySessionId",
        "summary": "Assign a chat session to a project",
        "tags": [
          "ai-chat"
        ],
        "description": "Links an existing chat session to a chat project owned by the authenticated user.",
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "path",
            "name": "sessionId",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object",
                  "required": [
                    "status"
                  ],
                  "properties": {
                    "status": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      },
      "delete": {
        "operationId": "deleteApiV1ChatProjectsByIdSessionsBySessionId",
        "summary": "Remove a chat session from a project",
        "tags": [
          "ai-chat"
        ],
        "description": "Unlinks a chat session from a chat project without deleting the session.",
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "path",
            "name": "sessionId",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "204": {
            "description": "No content"
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/chat-upload": {
      "post": {
        "operationId": "chatUploadFile",
        "summary": "Upload file for chat attachment",
        "tags": [
          "ai-chat"
        ],
        "description": "Accepts a single file (max 10MB, enforced via the multipart limits registered on this route) and uploads to S3 or local filesystem. Supported MIME types: jpeg, png, webp, gif, pdf, csv, txt, markdown, ms-excel (Windows-exported CSV), docx, xlsx. HEIC/HEIF photos are rejected (415) with guidance to convert to JPEG.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "url",
                    "fileName",
                    "fileType",
                    "fileSize"
                  ],
                  "properties": {
                    "url": {
                      "description": "Public/CDN URL to retrieve the uploaded file",
                      "type": "string"
                    },
                    "fileName": {
                      "description": "Original filename (or generated UUID if not provided)",
                      "type": "string"
                    },
                    "fileType": {
                      "description": "MIME type of the uploaded file",
                      "type": "string"
                    },
                    "fileSize": {
                      "description": "File size in bytes",
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "413": {
            "description": "Payload too large",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "415": {
            "description": "Response 415",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/chat-voice/transcribe": {
      "post": {
        "operationId": "chatVoiceTranscribe",
        "summary": "Transcribe audio via OpenAI Whisper API",
        "tags": [
          "ai-chat"
        ],
        "description": "Accepts audio file (webm/mp3/wav, max 25MB per Whisper API limit; see plugin 13-multipart for global limits) and returns transcribed text. Used as fallback when browser SpeechRecognition is unavailable. The optional `language` query parameter (BCP-47 code) hints Whisper; if omitted, Whisper auto-detects the spoken language.",
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "language",
            "required": false,
            "description": "Language hint for Whisper (BCP-47, e.g. \"it\", \"en\"). Default \"it\"."
          }
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "text"
                  ],
                  "properties": {
                    "text": {
                      "description": "Transcribed text from the audio input",
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "413": {
            "description": "Payload too large",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "502": {
            "description": "Bad gateway - upstream provider failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/chat/sessions": {
      "get": {
        "operationId": "getApiV1ChatSessions",
        "summary": "List chat sessions",
        "tags": [
          "ai-chat"
        ],
        "description": "Returns a paginated list of the user's AI chat sessions.",
        "parameters": [
          {
            "schema": {
              "minimum": 1,
              "maximum": 50,
              "default": 20,
              "type": "integer"
            },
            "in": "query",
            "name": "limit",
            "required": false
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "cursor",
            "required": false
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "project_id",
            "required": false
          },
          {
            "schema": {
              "default": false,
              "type": "boolean"
            },
            "in": "query",
            "name": "archived",
            "required": false
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "items",
                    "next_cursor"
                  ],
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "additionalProperties": false,
                        "type": "object",
                        "required": [
                          "id",
                          "title",
                          "created_at",
                          "updated_at",
                          "project_id",
                          "is_favorite",
                          "last_message",
                          "message_count"
                        ],
                        "properties": {
                          "id": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "title": {
                            "type": "string"
                          },
                          "created_at": {
                            "format": "date-time",
                            "type": "string"
                          },
                          "updated_at": {
                            "anyOf": [
                              {
                                "format": "date-time",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "project_id": {
                            "anyOf": [
                              {
                                "format": "uuid",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "is_favorite": {
                            "type": "boolean"
                          },
                          "last_message": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "message_count": {
                            "type": "integer"
                          }
                        }
                      }
                    },
                    "next_cursor": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    },
                    "retryAfterSeconds": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "postApiV1ChatSessions",
        "summary": "Create a new AI chat session",
        "tags": [
          "ai-chat"
        ],
        "description": "Creates a new AI chat session for the authenticated user.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "properties": {
                  "project_id": {
                    "type": "string"
                  },
                  "team_id": {
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "201": {
            "description": "Resource created",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "id",
                    "title",
                    "created_at",
                    "project_id"
                  ],
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "title": {
                      "type": "string"
                    },
                    "created_at": {
                      "type": "string"
                    },
                    "project_id": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      },
      "delete": {
        "operationId": "deleteApiV1ChatSessions",
        "summary": "Delete (archive) all chat sessions",
        "tags": [
          "ai-chat"
        ],
        "description": "Archives all of the user's chat sessions.",
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "project_id",
            "required": false
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "deleted_count"
                  ],
                  "properties": {
                    "deleted_count": {
                      "minimum": 0,
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/chat/sessions/{id}": {
      "get": {
        "operationId": "getApiV1ChatSessionsById",
        "summary": "Get chat session with messages",
        "tags": [
          "ai-chat"
        ],
        "description": "Returns a single chat session with its full message history.",
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "id",
                    "user_id",
                    "team_id",
                    "project_id",
                    "title",
                    "created_at",
                    "updated_at",
                    "is_archived",
                    "is_favorite",
                    "briefing_id",
                    "project_type",
                    "ui_messages",
                    "permission",
                    "messages"
                  ],
                  "properties": {
                    "id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "user_id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "team_id": {
                      "anyOf": [
                        {
                          "format": "uuid",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "project_id": {
                      "anyOf": [
                        {
                          "format": "uuid",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "title": {
                      "type": "string"
                    },
                    "created_at": {
                      "format": "date-time",
                      "type": "string"
                    },
                    "updated_at": {
                      "anyOf": [
                        {
                          "format": "date-time",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "is_archived": {
                      "type": "boolean"
                    },
                    "is_favorite": {
                      "type": "boolean"
                    },
                    "briefing_id": {
                      "anyOf": [
                        {
                          "format": "uuid",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "project_type": {
                      "type": "string"
                    },
                    "ui_messages": {
                      "type": "array",
                      "items": {
                        "additionalProperties": {
                          "$comment": "json-value"
                        },
                        "type": "object",
                        "required": [
                          "role"
                        ],
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "role": {
                            "type": "string"
                          },
                          "parts": {
                            "type": "array",
                            "items": {
                              "additionalProperties": {
                                "$comment": "json-value"
                              },
                              "type": "object",
                              "required": [
                                "type"
                              ],
                              "properties": {
                                "type": {
                                  "type": "string"
                                },
                                "text": {
                                  "type": "string"
                                }
                              }
                            }
                          },
                          "content": {
                            "type": "string"
                          },
                          "createdAt": {
                            "anyOf": [
                              {
                                "format": "date-time",
                                "type": "string"
                              },
                              {
                                "type": "string"
                              },
                              {
                                "type": "number"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          }
                        }
                      }
                    },
                    "permission": {
                      "type": "string"
                    },
                    "messages": {
                      "type": "array",
                      "items": {
                        "additionalProperties": false,
                        "type": "object",
                        "required": [
                          "id",
                          "role",
                          "content",
                          "data",
                          "credits_used",
                          "created_at"
                        ],
                        "properties": {
                          "id": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "role": {
                            "type": "string"
                          },
                          "content": {
                            "type": "string"
                          },
                          "data": {
                            "anyOf": [
                              {
                                "$comment": "json-value"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "credits_used": {
                            "anyOf": [
                              {
                                "type": "integer"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "created_at": {
                            "format": "date-time",
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    },
                    "retryAfterSeconds": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          }
        }
      },
      "patch": {
        "operationId": "patchApiV1ChatSessionsById",
        "summary": "Rename chat session",
        "tags": [
          "ai-chat"
        ],
        "description": "Updates the title of an existing chat session.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "title"
                ],
                "properties": {
                  "title": {
                    "minLength": 1,
                    "maxLength": 255,
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "id",
                    "title"
                  ],
                  "properties": {
                    "id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "title": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    },
                    "retryAfterSeconds": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    },
                    "retryAfterSeconds": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          }
        }
      },
      "delete": {
        "operationId": "deleteApiV1ChatSessionsById",
        "summary": "Delete (archive) a chat session",
        "tags": [
          "ai-chat"
        ],
        "description": "Archives a chat session. The session is soft-deleted and no longer appears in listings.",
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "204": {
            "description": "No content"
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    },
                    "retryAfterSeconds": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/chat/sessions/{id}/unarchive": {
      "post": {
        "operationId": "postApiV1ChatSessionsByIdUnarchive",
        "summary": "Restore an archived chat session",
        "tags": [
          "ai-chat"
        ],
        "description": "Moves a previously archived chat session back into the active list.",
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "id",
                    "is_archived"
                  ],
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "is_archived": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/chat/sessions/{id}/favorite": {
      "patch": {
        "operationId": "patchApiV1ChatSessionsByIdFavorite",
        "summary": "Toggle session favorite",
        "tags": [
          "ai-chat"
        ],
        "description": "Toggles the is_favorite flag on a chat session.",
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "id",
                    "is_favorite"
                  ],
                  "properties": {
                    "id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "is_favorite": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    },
                    "retryAfterSeconds": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/chat/messages/{messageId}/feedback": {
      "patch": {
        "operationId": "patchApiV1ChatMessagesByMessageIdFeedback",
        "summary": "Submit feedback on an assistant message",
        "tags": [
          "ai-chat"
        ],
        "description": "Rate an AI response with thumbs up/down and optional comment. The messageId is the client-side UIMessage.id.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "rating"
                ],
                "properties": {
                  "rating": {
                    "minimum": -1,
                    "maximum": 1,
                    "type": "integer"
                  },
                  "comment": {
                    "maxLength": 1000,
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "schema": {
              "minLength": 1,
              "maxLength": 200,
              "type": "string"
            },
            "in": "path",
            "name": "messageId",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "ok"
                  ],
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    },
                    "retryAfterSeconds": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    },
                    "retryAfterSeconds": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    },
                    "retryAfterSeconds": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/chat/sessions/shared-with-me": {
      "get": {
        "operationId": "getApiV1ChatSessionsSharedWithMe",
        "summary": "List sessions shared with the current user",
        "tags": [
          "ai-chat"
        ],
        "description": "Returns active standalone AI chat sessions shared with the authenticated user.",
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "additionalProperties": false,
                    "type": "object",
                    "required": [
                      "id",
                      "title",
                      "created_at",
                      "updated_at",
                      "permission",
                      "shared_by"
                    ],
                    "properties": {
                      "id": {
                        "format": "uuid",
                        "type": "string"
                      },
                      "title": {
                        "type": "string"
                      },
                      "created_at": {
                        "format": "date-time",
                        "type": "string"
                      },
                      "updated_at": {
                        "anyOf": [
                          {
                            "format": "date-time",
                            "type": "string"
                          },
                          {
                            "type": "null"
                          }
                        ]
                      },
                      "permission": {
                        "type": "string"
                      },
                      "shared_by": {
                        "additionalProperties": false,
                        "type": "object",
                        "required": [
                          "name",
                          "email"
                        ],
                        "properties": {
                          "name": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "email": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    },
                    "retryAfterSeconds": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/chat/sessions/{id}/share": {
      "post": {
        "operationId": "postApiV1ChatSessionsByIdShare",
        "summary": "Share a chat session with a team member",
        "tags": [
          "ai-chat"
        ],
        "description": "Grants read or write access to a chat session for another member of the owner team.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "user_id",
                  "permission"
                ],
                "properties": {
                  "user_id": {
                    "type": "string"
                  },
                  "permission": {
                    "anyOf": [
                      {
                        "type": "string",
                        "enum": [
                          "read"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "write"
                        ]
                      }
                    ]
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "201": {
            "description": "Resource created",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "ok"
                  ],
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    },
                    "retryAfterSeconds": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/chat/sessions/{id}/share/{userId}": {
      "delete": {
        "operationId": "deleteApiV1ChatSessionsByIdShareByUserId",
        "summary": "Remove session sharing with a team member",
        "tags": [
          "ai-chat"
        ],
        "description": "Revokes a team member share from a chat session owned by the authenticated user.",
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "path",
            "name": "userId",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "204": {
            "description": "No content"
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    },
                    "retryAfterSeconds": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/chat/sessions/{id}/actions": {
      "get": {
        "operationId": "getApiV1ChatSessionsByIdActions",
        "summary": "List AI actions for a chat session",
        "tags": [
          "ai-chat"
        ],
        "description": "Returns pending and historical AI actions (audit trail) for a chat session.",
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "status",
            "required": false
          },
          {
            "schema": {
              "minimum": 1,
              "maximum": 100,
              "default": 50,
              "type": "integer"
            },
            "in": "query",
            "name": "limit",
            "required": false
          },
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "items"
                  ],
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "additionalProperties": false,
                        "type": "object",
                        "required": [
                          "id",
                          "chat_message_id",
                          "tool_name",
                          "entity_type",
                          "entity_id",
                          "entity_name",
                          "account_id",
                          "action_params",
                          "status",
                          "created_at"
                        ],
                        "properties": {
                          "id": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "chat_message_id": {
                            "anyOf": [
                              {
                                "format": "uuid",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "tool_name": {
                            "type": "string"
                          },
                          "entity_type": {
                            "type": "string"
                          },
                          "entity_id": {
                            "type": "string"
                          },
                          "entity_name": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "account_id": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "action_params": {
                            "$comment": "json-value"
                          },
                          "status": {
                            "type": "string"
                          },
                          "result_data": {
                            "anyOf": [
                              {
                                "$comment": "json-value"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "created_at": {
                            "format": "date-time",
                            "type": "string"
                          },
                          "confirmed_at": {
                            "anyOf": [
                              {
                                "format": "date-time",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "executed_at": {
                            "anyOf": [
                              {
                                "format": "date-time",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "confirmed_by": {
                            "anyOf": [
                              {
                                "format": "uuid",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    },
                    "retryAfterSeconds": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/chat/sessions/{id}/actions/{actionId}/execute": {
      "post": {
        "operationId": "postApiV1ChatSessionsByIdActionsByActionIdExecute",
        "summary": "Execute a pending AI action",
        "tags": [
          "ai-chat"
        ],
        "description": "Confirms and executes a pending AI action with row-level locking and TTL verification.",
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          },
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "actionId",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "status"
                  ],
                  "properties": {
                    "status": {
                      "type": "string"
                    },
                    "result_data": {
                      "$comment": "json-value"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    },
                    "retryAfterSeconds": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    },
                    "retryAfterSeconds": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    },
                    "retryAfterSeconds": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "Conflict - resource state prevents the operation",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    },
                    "retryAfterSeconds": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "410": {
            "description": "Gone - resource is permanently removed",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    },
                    "retryAfterSeconds": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "423": {
            "description": "Response 423",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    },
                    "retryAfterSeconds": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    },
                    "retryAfterSeconds": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/chat/sessions/{id}/actions/{actionId}/reject": {
      "post": {
        "operationId": "postApiV1ChatSessionsByIdActionsByActionIdReject",
        "summary": "Reject a pending AI action",
        "tags": [
          "ai-chat"
        ],
        "description": "Marks a pending AI action as rejected.",
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          },
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "actionId",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "status"
                  ],
                  "properties": {
                    "status": {
                      "type": "string",
                      "enum": [
                        "REJECTED"
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    },
                    "retryAfterSeconds": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    },
                    "retryAfterSeconds": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "Conflict - resource state prevents the operation",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    },
                    "retryAfterSeconds": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    },
                    "retryAfterSeconds": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/chat/sessions/{id}/messages": {
      "post": {
        "operationId": "postApiV1ChatSessionsByIdMessages",
        "summary": "Send message and receive AI response via data stream",
        "tags": [
          "ai-chat"
        ],
        "description": "Sends a user message to the AI chat and streams the response back via the AI SDK data stream protocol (`text/event-stream`). The route uses `reply.hijack()` + `pipeUIMessageStreamToResponse()` from the `ai` package, so the declared JSON schemas on other endpoints do NOT apply here. Clients must consume the response as Server-Sent Events and parse each `data:` frame as an AI SDK UIMessage stream chunk. Error responses (400/403/404) are still returned as JSON when the request is rejected before streaming begins.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": {
                  "$comment": "json-value"
                },
                "description": "Chat stream request. Permissive on extra fields so callers can pass provider-specific options without backend changes.",
                "type": "object",
                "properties": {
                  "id": {
                    "type": "string"
                  },
                  "message": {
                    "additionalProperties": {
                      "$comment": "json-value"
                    },
                    "description": "Single user message. Extra fields (attachments, tool results, provider hints) are forwarded as-is to the AI provider.",
                    "type": "object",
                    "required": [
                      "id",
                      "role"
                    ],
                    "properties": {
                      "id": {
                        "type": "string"
                      },
                      "role": {
                        "type": "string"
                      },
                      "parts": {
                        "type": "array",
                        "items": {
                          "additionalProperties": {
                            "$comment": "json-value"
                          },
                          "type": "object",
                          "required": [
                            "type"
                          ],
                          "properties": {
                            "type": {
                              "type": "string"
                            },
                            "text": {
                              "type": "string"
                            }
                          }
                        }
                      }
                    }
                  },
                  "messages": {
                    "maxItems": 100,
                    "type": "array",
                    "items": {
                      "additionalProperties": {
                        "$comment": "json-value"
                      },
                      "description": "Conversation history entry. Extra fields are forwarded to the AI provider unchanged.",
                      "type": "object",
                      "required": [
                        "role"
                      ],
                      "properties": {
                        "id": {
                          "type": "string"
                        },
                        "role": {
                          "type": "string"
                        },
                        "parts": {
                          "type": "array",
                          "items": {
                            "additionalProperties": {
                              "$comment": "json-value"
                            },
                            "type": "object",
                            "required": [
                              "type"
                            ],
                            "properties": {
                              "type": {
                                "type": "string"
                              },
                              "text": {
                                "type": "string"
                              }
                            }
                          }
                        },
                        "content": {
                          "type": "string"
                        }
                      }
                    }
                  },
                  "trigger": {
                    "type": "string"
                  },
                  "messageId": {
                    "type": "string"
                  },
                  "mode": {
                    "maxLength": 16,
                    "type": "string"
                  },
                  "model": {
                    "type": "string"
                  },
                  "from_date": {
                    "format": "date",
                    "type": "string"
                  },
                  "to_date": {
                    "format": "date",
                    "type": "string"
                  },
                  "content": {
                    "maxLength": 5000,
                    "type": "string"
                  },
                  "page_context": {
                    "additionalProperties": false,
                    "type": "object",
                    "properties": {
                      "path": {
                        "anyOf": [
                          {
                            "type": "string"
                          },
                          {
                            "type": "null"
                          }
                        ]
                      },
                      "route": {
                        "anyOf": [
                          {
                            "type": "string"
                          },
                          {
                            "type": "null"
                          }
                        ]
                      },
                      "route_params": {
                        "anyOf": [
                          {
                            "type": "object",
                            "additionalProperties": {
                              "anyOf": [
                                {
                                  "type": "string"
                                },
                                {
                                  "type": "number"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            }
                          },
                          {
                            "type": "null"
                          }
                        ]
                      },
                      "search_params": {
                        "anyOf": [
                          {
                            "type": "object",
                            "additionalProperties": {
                              "anyOf": [
                                {
                                  "type": "string"
                                },
                                {
                                  "type": "number"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            }
                          },
                          {
                            "type": "null"
                          }
                        ]
                      },
                      "selected_entity": {
                        "anyOf": [
                          {
                            "additionalProperties": false,
                            "type": "object",
                            "required": [
                              "type",
                              "id"
                            ],
                            "properties": {
                              "type": {
                                "type": "string"
                              },
                              "id": {
                                "type": "string"
                              },
                              "name": {
                                "anyOf": [
                                  {
                                    "type": "string"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              }
                            }
                          },
                          {
                            "type": "null"
                          }
                        ]
                      },
                      "visible_filters": {
                        "anyOf": [
                          {
                            "type": "object",
                            "additionalProperties": {
                              "$comment": "json-value"
                            }
                          },
                          {
                            "type": "null"
                          }
                        ]
                      }
                    }
                  }
                }
              }
            }
          },
          "description": "Chat stream request. Permissive on extra fields so callers can pass provider-specific options without backend changes."
        },
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "AI SDK UIMessage data stream served as Server-Sent Events. Each frame is a `data: <json>\\n\\n` line where the payload follows the AI SDK v5 UIMessage stream format (text deltas, tool calls, tool results, finish events, etc.). See the `ai` package (`pipeUIMessageStreamToResponse`) for the payload shape.",
            "content": {
              "text/event-stream": {
                "schema": {
                  "type": "string",
                  "description": "Raw SSE frames carrying AI SDK UIMessage stream chunks. Decode with an AI SDK compatible transport on the client."
                }
              }
            }
          },
          "400": {
            "description": "Request is missing message content or contains an invalid payload.",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    },
                    "retryAfterSeconds": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "The user can read the session but cannot send messages to it, or is blocked by abuse controls.",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    },
                    "retryAfterSeconds": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Chat session was not found or is not accessible.",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    },
                    "retryAfterSeconds": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/chat": {
      "post": {
        "operationId": "postApiV1Chat",
        "summary": "Send message and receive AI response via stock AI SDK transport",
        "tags": [
          "ai-chat"
        ],
        "description": "Stock AI SDK chat transport: identical streaming semantics to `POST /api/v1/chat/sessions/:id/messages` but the session id is read from the request body. Uses `reply.hijack()` + `pipeUIMessageStreamToResponse()`, so the response is an SSE stream (`text/event-stream`) carrying AI SDK UIMessage chunks, not JSON.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "allOf": [
                  {
                    "additionalProperties": {
                      "$comment": "json-value"
                    },
                    "description": "Chat stream request. Permissive on extra fields so callers can pass provider-specific options without backend changes.",
                    "type": "object",
                    "properties": {
                      "id": {
                        "type": "string"
                      },
                      "message": {
                        "additionalProperties": {
                          "$comment": "json-value"
                        },
                        "description": "Single user message. Extra fields (attachments, tool results, provider hints) are forwarded as-is to the AI provider.",
                        "type": "object",
                        "required": [
                          "id",
                          "role"
                        ],
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "role": {
                            "type": "string"
                          },
                          "parts": {
                            "type": "array",
                            "items": {
                              "additionalProperties": {
                                "$comment": "json-value"
                              },
                              "type": "object",
                              "required": [
                                "type"
                              ],
                              "properties": {
                                "type": {
                                  "type": "string"
                                },
                                "text": {
                                  "type": "string"
                                }
                              }
                            }
                          }
                        }
                      },
                      "messages": {
                        "maxItems": 100,
                        "type": "array",
                        "items": {
                          "additionalProperties": {
                            "$comment": "json-value"
                          },
                          "description": "Conversation history entry. Extra fields are forwarded to the AI provider unchanged.",
                          "type": "object",
                          "required": [
                            "role"
                          ],
                          "properties": {
                            "id": {
                              "type": "string"
                            },
                            "role": {
                              "type": "string"
                            },
                            "parts": {
                              "type": "array",
                              "items": {
                                "additionalProperties": {
                                  "$comment": "json-value"
                                },
                                "type": "object",
                                "required": [
                                  "type"
                                ],
                                "properties": {
                                  "type": {
                                    "type": "string"
                                  },
                                  "text": {
                                    "type": "string"
                                  }
                                }
                              }
                            },
                            "content": {
                              "type": "string"
                            }
                          }
                        }
                      },
                      "trigger": {
                        "type": "string"
                      },
                      "messageId": {
                        "type": "string"
                      },
                      "mode": {
                        "maxLength": 16,
                        "type": "string"
                      },
                      "model": {
                        "type": "string"
                      },
                      "from_date": {
                        "format": "date",
                        "type": "string"
                      },
                      "to_date": {
                        "format": "date",
                        "type": "string"
                      },
                      "content": {
                        "maxLength": 5000,
                        "type": "string"
                      },
                      "page_context": {
                        "additionalProperties": false,
                        "type": "object",
                        "properties": {
                          "path": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "route": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "route_params": {
                            "anyOf": [
                              {
                                "type": "object",
                                "additionalProperties": {
                                  "anyOf": [
                                    {
                                      "type": "string"
                                    },
                                    {
                                      "type": "number"
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                }
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "search_params": {
                            "anyOf": [
                              {
                                "type": "object",
                                "additionalProperties": {
                                  "anyOf": [
                                    {
                                      "type": "string"
                                    },
                                    {
                                      "type": "number"
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                }
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "selected_entity": {
                            "anyOf": [
                              {
                                "additionalProperties": false,
                                "type": "object",
                                "required": [
                                  "type",
                                  "id"
                                ],
                                "properties": {
                                  "type": {
                                    "type": "string"
                                  },
                                  "id": {
                                    "type": "string"
                                  },
                                  "name": {
                                    "anyOf": [
                                      {
                                        "type": "string"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  }
                                }
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "visible_filters": {
                            "anyOf": [
                              {
                                "type": "object",
                                "additionalProperties": {
                                  "$comment": "json-value"
                                }
                              },
                              {
                                "type": "null"
                              }
                            ]
                          }
                        }
                      }
                    }
                  },
                  {
                    "type": "object",
                    "required": [
                      "id"
                    ],
                    "properties": {
                      "id": {
                        "type": "string"
                      }
                    }
                  }
                ]
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "AI SDK UIMessage data stream served as Server-Sent Events. Each frame is a `data: <json>\\n\\n` line following the AI SDK v5 UIMessage stream format. See `pipeUIMessageStreamToResponse` in the `ai` package for the payload shape.",
            "content": {
              "text/event-stream": {
                "schema": {
                  "type": "string",
                  "description": "Raw SSE frames carrying AI SDK UIMessage stream chunks."
                }
              }
            }
          },
          "400": {
            "description": "Request is missing a chat session id or message content.",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    },
                    "retryAfterSeconds": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "The user can read the session but cannot send messages to it, or is blocked by abuse controls.",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    },
                    "retryAfterSeconds": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Chat session was not found or is not accessible.",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    },
                    "retryAfterSeconds": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/chat/{id}/stream": {
      "get": {
        "operationId": "getApiV1ChatByIdStream",
        "summary": "Reconnect to an active AI chat stream",
        "tags": [
          "ai-chat"
        ],
        "description": "Returns the buffered + live SSE stream for a session. Used by the frontend to resume after refresh/disconnect. The route uses `reply.hijack()` + `reply.raw.writeHead(200, { \"Content-Type\": \"text/event-stream\" })` and pipes bytes from a resumable stream managed by the stream manager (Redis-backed). If there is no active stream the route responds with a plain `204 No Content`; otherwise the response body is a raw SSE payload and the JSON schemas declared elsewhere do NOT apply.",
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Server-Sent Events stream resumed from the AI SDK UIMessage data stream (same payload shape as `POST /api/v1/chat/sessions/:id/messages`).",
            "content": {
              "text/event-stream": {
                "schema": {
                  "type": "string",
                  "description": "Raw SSE frames carrying AI SDK UIMessage stream chunks replayed from the resumable stream buffer."
                }
              }
            }
          },
          "204": {
            "description": "No active stream to resume for this session."
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Session not found or not accessible.",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    },
                    "retryAfterSeconds": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/chat/sessions/{id}/stop": {
      "post": {
        "operationId": "postApiV1ChatSessionsByIdStop",
        "summary": "Stop an active AI chat stream",
        "tags": [
          "ai-chat"
        ],
        "description": "Sends a soft stop signal via Redis pub/sub. Works across any pod in a multi-instance cluster.",
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "stopped"
                  ],
                  "properties": {
                    "stopped": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "stopped"
                  ],
                  "properties": {
                    "stopped": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/chat/models": {
      "get": {
        "operationId": "getApiV1ChatModels",
        "summary": "List the neutral chat capability modes available to the caller",
        "tags": [
          "ai-chat"
        ],
        "description": "Returns ONLY opaque capability modes (fast|smart|expert) with per-plan availability. Never exposes the underlying model id, name, provider, version or cost.",
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "modes"
                  ],
                  "properties": {
                    "modes": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "key",
                          "label",
                          "available",
                          "allowed_by_plan",
                          "available_now",
                          "default"
                        ],
                        "properties": {
                          "key": {
                            "description": "Opaque capability mode: fast | smart | expert.",
                            "type": "string"
                          },
                          "label": {
                            "description": "Human-readable label for the mode.",
                            "type": "string"
                          },
                          "available": {
                            "description": "DEPRECATED legacy field, now `allowed_by_plan && available_now` — i.e. the mode is usable. Read allowed_by_plan (upsell) and available_now (temporary unavailability) instead: this single boolean cannot say WHICH of the two failed.",
                            "type": "boolean"
                          },
                          "allowed_by_plan": {
                            "description": "Whether the caller plan unlocks the mode. false → upsell.",
                            "type": "boolean"
                          },
                          "available_now": {
                            "description": "Whether the mode can run right now (its lane is configured and not switched off). false → temporary unavailability, not an upgrade prompt.",
                            "type": "boolean"
                          },
                          "default": {
                            "description": "Whether this is the default mode.",
                            "type": "boolean"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/chat/credits": {
      "get": {
        "operationId": "getApiV1ChatCredits",
        "summary": "Get AI chat credit balance",
        "tags": [
          "ai-chat"
        ],
        "description": "Returns the current AI chat credit balance, total purchased, and total used for the team owner.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "balance",
                    "grant_balance",
                    "currency",
                    "spendable",
                    "total_purchased",
                    "total_used",
                    "monthly_cap",
                    "monthly_used",
                    "monthly_pct",
                    "monthly_reset_at",
                    "weekly_cap",
                    "weekly_used",
                    "weekly_pct",
                    "weekly_reset_at",
                    "monthly_spend_limit_cents",
                    "monthly_spend_cents",
                    "spend_pct",
                    "spend_reset_at",
                    "auto_recharge"
                  ],
                  "properties": {
                    "balance": {
                      "type": "number"
                    },
                    "grant_balance": {
                      "type": "number"
                    },
                    "currency": {
                      "type": "string"
                    },
                    "spendable": {
                      "type": "number"
                    },
                    "total_purchased": {
                      "type": "number"
                    },
                    "total_used": {
                      "type": "number"
                    },
                    "monthly_cap": {
                      "anyOf": [
                        {
                          "type": "integer"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "monthly_used": {
                      "type": "integer"
                    },
                    "monthly_pct": {
                      "anyOf": [
                        {
                          "type": "number"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "monthly_reset_at": {
                      "anyOf": [
                        {
                          "format": "date-time",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "weekly_cap": {
                      "anyOf": [
                        {
                          "type": "integer"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "weekly_used": {
                      "type": "integer"
                    },
                    "weekly_pct": {
                      "anyOf": [
                        {
                          "type": "number"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "weekly_reset_at": {
                      "anyOf": [
                        {
                          "format": "date-time",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "monthly_spend_limit_cents": {
                      "anyOf": [
                        {
                          "type": "integer"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "monthly_spend_cents": {
                      "type": "integer"
                    },
                    "spend_pct": {
                      "anyOf": [
                        {
                          "type": "number"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "spend_reset_at": {
                      "anyOf": [
                        {
                          "format": "date-time",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "auto_recharge": {
                      "type": "object",
                      "required": [
                        "enabled",
                        "threshold",
                        "package_key",
                        "target_balance",
                        "monthly_cap_cents",
                        "spent_cents",
                        "last_status"
                      ],
                      "properties": {
                        "enabled": {
                          "type": "boolean"
                        },
                        "threshold": {
                          "anyOf": [
                            {
                              "type": "integer"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "package_key": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "target_balance": {
                          "anyOf": [
                            {
                              "type": "integer"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "monthly_cap_cents": {
                          "anyOf": [
                            {
                              "type": "integer"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "spent_cents": {
                          "type": "integer"
                        },
                        "last_status": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/chat/credits/auto-recharge": {
      "get": {
        "operationId": "getApiV1ChatCreditsAutoRecharge",
        "summary": "Get the auto-recharge configuration",
        "tags": [
          "ai-chat"
        ],
        "description": "Returns the current auto-recharge threshold, target balance, package, cap, and last status.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "enabled",
                    "threshold",
                    "dropToThreshold",
                    "targetBalance",
                    "packageKey",
                    "monthlyCapCents",
                    "spentCents",
                    "lastStatus"
                  ],
                  "properties": {
                    "enabled": {
                      "type": "boolean"
                    },
                    "threshold": {
                      "anyOf": [
                        {
                          "type": "number"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "dropToThreshold": {
                      "anyOf": [
                        {
                          "type": "number"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "targetBalance": {
                      "anyOf": [
                        {
                          "type": "number"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "packageKey": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "monthlyCapCents": {
                      "anyOf": [
                        {
                          "type": "number"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "spentCents": {
                      "type": "number"
                    },
                    "lastStatus": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      },
      "put": {
        "operationId": "putApiV1ChatCreditsAutoRecharge",
        "summary": "Configure auto-recharge (threshold + package + monthly cap)",
        "tags": [
          "ai-chat"
        ],
        "description": "Updates auto-recharge settings used to top up AI credits when balance drops below the threshold.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "enabled"
                ],
                "properties": {
                  "enabled": {
                    "type": "boolean"
                  },
                  "threshold": {
                    "anyOf": [
                      {
                        "minimum": 1,
                        "type": "integer"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "package_key": {
                    "anyOf": [
                      {
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "target_balance": {
                    "anyOf": [
                      {
                        "minimum": 1,
                        "maximum": 27777777,
                        "type": "integer"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "monthly_cap_cents": {
                    "anyOf": [
                      {
                        "minimum": 0,
                        "type": "integer"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "enabled",
                    "threshold",
                    "dropToThreshold",
                    "targetBalance",
                    "packageKey",
                    "monthlyCapCents",
                    "spentCents",
                    "lastStatus"
                  ],
                  "properties": {
                    "enabled": {
                      "type": "boolean"
                    },
                    "threshold": {
                      "anyOf": [
                        {
                          "type": "number"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "dropToThreshold": {
                      "anyOf": [
                        {
                          "type": "number"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "targetBalance": {
                      "anyOf": [
                        {
                          "type": "number"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "packageKey": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "monthlyCapCents": {
                      "anyOf": [
                        {
                          "type": "number"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "spentCents": {
                      "type": "number"
                    },
                    "lastStatus": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    },
                    "retryAfterSeconds": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/chat/credits/history": {
      "get": {
        "operationId": "getApiV1ChatCreditsHistory",
        "summary": "Get credit transaction history",
        "tags": [
          "ai-chat"
        ],
        "description": "Returns a paginated list of credit purchase and usage transactions.",
        "parameters": [
          {
            "schema": {
              "minimum": 1,
              "maximum": 50,
              "default": 20,
              "type": "integer"
            },
            "in": "query",
            "name": "limit",
            "required": false
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "cursor",
            "required": false
          },
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "query",
            "name": "team_id",
            "required": false
          }
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "items",
                    "next_cursor"
                  ],
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "additionalProperties": false,
                        "type": "object",
                        "required": [
                          "id",
                          "owner_id",
                          "organization_id",
                          "type",
                          "amount",
                          "balance_after",
                          "description",
                          "stripe_payment_intent_id",
                          "chat_message_id",
                          "user_id",
                          "created_at"
                        ],
                        "properties": {
                          "id": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "owner_id": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "organization_id": {
                            "anyOf": [
                              {
                                "format": "uuid",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "type": {
                            "type": "string"
                          },
                          "amount": {
                            "type": "integer"
                          },
                          "balance_after": {
                            "type": "integer"
                          },
                          "description": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "stripe_payment_intent_id": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "chat_message_id": {
                            "anyOf": [
                              {
                                "format": "uuid",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "user_id": {
                            "anyOf": [
                              {
                                "format": "uuid",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "created_at": {
                            "format": "date-time",
                            "type": "string"
                          },
                          "reversal_key": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          }
                        }
                      }
                    },
                    "next_cursor": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/chat/credits/packages": {
      "get": {
        "operationId": "getApiV1ChatCreditsPackages",
        "summary": "List purchasable AI credit packages",
        "tags": [
          "ai-chat"
        ],
        "description": "Returns the sellable credit top-up packages. Sourced from the credit_package table (enabled + priced) when populated, otherwise the in-code fallback catalogue.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "currency",
                    "packages"
                  ],
                  "properties": {
                    "currency": {
                      "type": "string"
                    },
                    "packages": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "key",
                          "credits",
                          "price_cents",
                          "unit_amount_cents",
                          "currency",
                          "name"
                        ],
                        "properties": {
                          "key": {
                            "type": "string"
                          },
                          "credits": {
                            "type": "integer"
                          },
                          "price_cents": {
                            "type": "integer"
                          },
                          "unit_amount_cents": {
                            "type": "integer"
                          },
                          "currency": {
                            "type": "string"
                          },
                          "name": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/chat/credits/checkout": {
      "post": {
        "operationId": "postApiV1ChatCreditsCheckout",
        "summary": "Create Stripe checkout for credit purchase",
        "tags": [
          "ai-chat"
        ],
        "description": "Creates a Stripe checkout session to purchase an AI chat credit package. Returns the checkout URL.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "properties": {
                  "package": {
                    "anyOf": [
                      {
                        "type": "string",
                        "enum": [
                          "starter"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "standard"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "pro"
                        ]
                      }
                    ]
                  },
                  "amount_cents": {
                    "minimum": 1,
                    "type": "integer"
                  },
                  "currency": {
                    "maxLength": 3,
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "checkout_url"
                  ],
                  "properties": {
                    "checkout_url": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    },
                    "retryAfterSeconds": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "402": {
            "description": "Response 402",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error",
                    "limit_cents",
                    "spent_cents"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "limit_cents": {
                      "type": "integer"
                    },
                    "spent_cents": {
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    },
                    "retryAfterSeconds": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    },
                    "retryAfterSeconds": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "Service unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    },
                    "retryAfterSeconds": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/chat/credits/purchase": {
      "post": {
        "operationId": "postApiV1ChatCreditsPurchase",
        "summary": "Purchase credits using saved payment method",
        "tags": [
          "ai-chat"
        ],
        "description": "Creates a Stripe PaymentIntent to purchase AI chat credits using the customer default payment method. Returns immediately if payment succeeds, or a client_secret for 3D Secure confirmation.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "properties": {
                  "package": {
                    "anyOf": [
                      {
                        "type": "string",
                        "enum": [
                          "starter"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "standard"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "pro"
                        ]
                      }
                    ]
                  },
                  "amount_cents": {
                    "minimum": 1,
                    "type": "integer"
                  },
                  "currency": {
                    "maxLength": 3,
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "properties": {
                    "has_payment_method": {
                      "type": "boolean"
                    },
                    "setup_client_secret": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "success": {
                      "type": "boolean"
                    },
                    "credits": {
                      "type": "integer"
                    },
                    "requires_action": {
                      "type": "boolean"
                    },
                    "client_secret": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    },
                    "retryAfterSeconds": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "402": {
            "description": "Response 402",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "limit_cents": {
                      "type": "integer"
                    },
                    "spent_cents": {
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    },
                    "retryAfterSeconds": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    },
                    "retryAfterSeconds": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "Service unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    },
                    "retryAfterSeconds": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/chat/credits/confirm": {
      "post": {
        "operationId": "postApiV1ChatCreditsConfirm",
        "summary": "Confirm 3D Secure credit purchase",
        "tags": [
          "ai-chat"
        ],
        "description": "After frontend completes 3D Secure, call this to verify the PaymentIntent succeeded and record credits.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "payment_intent_id"
                ],
                "properties": {
                  "payment_intent_id": {
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "success",
                    "credits"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "credits": {
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    },
                    "retryAfterSeconds": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    },
                    "retryAfterSeconds": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    },
                    "retryAfterSeconds": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "Service unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    },
                    "retryAfterSeconds": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/chat/preferences": {
      "get": {
        "operationId": "getApiV1ChatPreferences",
        "summary": "Get current user AI preferences",
        "tags": [
          "ai-chat"
        ],
        "description": "Returns the current user AI chat preferences with preferred model mapped to a neutral mode.",
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "instructions",
                    "preferred_language",
                    "preferred_model"
                  ],
                  "properties": {
                    "id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "user_id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "team_id": {
                      "anyOf": [
                        {
                          "format": "uuid",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "instructions": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "preferred_language": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "preferred_model": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "tone": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "verbosity": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "expertise_level": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "format_preference": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "response_format": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "preferred_metrics": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "preferred_currency": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "memory_enabled": {
                      "type": "boolean"
                    },
                    "memory_opted_out_at": {
                      "anyOf": [
                        {
                          "format": "date-time",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "created_at": {
                      "format": "date-time",
                      "type": "string"
                    },
                    "updated_at": {
                      "anyOf": [
                        {
                          "format": "date-time",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    },
                    "retryAfterSeconds": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          }
        }
      },
      "put": {
        "operationId": "putApiV1ChatPreferences",
        "summary": "Update current user AI preferences",
        "tags": [
          "ai-chat"
        ],
        "description": "Updates current user AI chat preferences and persists only neutral model modes.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "properties": {
                  "instructions": {
                    "maxLength": 2000,
                    "type": "string"
                  },
                  "preferred_language": {
                    "maxLength": 10,
                    "type": "string"
                  },
                  "preferred_model": {
                    "anyOf": [
                      {
                        "maxLength": 100,
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "instructions",
                    "preferred_language",
                    "preferred_model"
                  ],
                  "properties": {
                    "id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "user_id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "team_id": {
                      "anyOf": [
                        {
                          "format": "uuid",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "instructions": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "preferred_language": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "preferred_model": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "tone": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "verbosity": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "expertise_level": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "format_preference": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "response_format": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "preferred_metrics": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "preferred_currency": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "memory_enabled": {
                      "type": "boolean"
                    },
                    "memory_opted_out_at": {
                      "anyOf": [
                        {
                          "format": "date-time",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "created_at": {
                      "format": "date-time",
                      "type": "string"
                    },
                    "updated_at": {
                      "anyOf": [
                        {
                          "format": "date-time",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    },
                    "retryAfterSeconds": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    },
                    "retryAfterSeconds": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/chat/credits/cap": {
      "put": {
        "operationId": "putApiV1ChatCreditsCap",
        "summary": "Update monthly credit cap (owner/admin only)",
        "tags": [
          "ai-chat"
        ],
        "description": "Updates the monthly AI credit consumption cap for the billing owner.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "monthly_cap"
                ],
                "properties": {
                  "monthly_cap": {
                    "anyOf": [
                      {
                        "minimum": 0,
                        "type": "integer"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "ok",
                    "monthly_cap"
                  ],
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    },
                    "monthly_cap": {
                      "anyOf": [
                        {
                          "type": "integer"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    },
                    "retryAfterSeconds": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    },
                    "retryAfterSeconds": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/chat/credits/spend-limit": {
      "put": {
        "operationId": "putApiV1ChatCreditsSpendLimit",
        "summary": "Update monthly spend limit in currency minor units (owner/admin only)",
        "tags": [
          "ai-chat"
        ],
        "description": "Updates or removes the monthly spend limit for buying AI credits.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "monthly_spend_limit_cents"
                ],
                "properties": {
                  "monthly_spend_limit_cents": {
                    "anyOf": [
                      {
                        "minimum": 1,
                        "description": "Positive cap in minor units, or null to remove the limit.",
                        "type": "integer"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "ok",
                    "monthly_spend_limit_cents"
                  ],
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    },
                    "monthly_spend_limit_cents": {
                      "anyOf": [
                        {
                          "type": "integer"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    },
                    "retryAfterSeconds": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    },
                    "retryAfterSeconds": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/commerce/attribution-sources": {
      "get": {
        "operationId": "getCommerceAttributionSources",
        "summary": "Revenue and orders grouped by normalized traffic source for the team",
        "tags": [
          "commerce"
        ],
        "description": "Aggregates commerce orders in the requested date range by normalized UTM/source bucket (meta, google, email, organic, direct, other), optionally filtered to a connected store.",
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "from",
            "required": true,
            "description": "ISO date (inclusive lower bound)"
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "to",
            "required": true,
            "description": "ISO date (inclusive upper bound)"
          },
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "query",
            "name": "catalog_source_id",
            "required": false
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "items"
                  ],
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "source",
                          "revenue",
                          "orders"
                        ],
                        "properties": {
                          "source": {
                            "type": "string"
                          },
                          "revenue": {
                            "type": "number"
                          },
                          "orders": {
                            "type": "integer"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/commerce/orders/{orderId}/attribution": {
      "patch": {
        "operationId": "setCommerceOrderAttribution",
        "summary": "Manually set attribution for a commerce order",
        "tags": [
          "commerce"
        ],
        "description": "Creates or updates a manual attribution override for one commerce order. Pass a campaign id to attribute it, or null to mark the order as manually unattributed.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "campaign_id"
                ],
                "properties": {
                  "campaign_id": {
                    "anyOf": [
                      {
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "campaign_name": {
                    "anyOf": [
                      {
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "note": {
                    "anyOf": [
                      {
                        "maxLength": 1000,
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "orderId",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "success"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/commerce/orders/{orderId}/attribution/revert": {
      "post": {
        "operationId": "revertCommerceOrderAttribution",
        "summary": "Revert manual attribution to automatic",
        "tags": [
          "commerce"
        ],
        "description": "Removes the manual attribution override for a commerce order so the automatic attribution worker can evaluate it again on the next run.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "properties": {
                  "note": {
                    "anyOf": [
                      {
                        "maxLength": 1000,
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "orderId",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "reverted"
                  ],
                  "properties": {
                    "reverted": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/commerce/orders/bulk-attribute": {
      "post": {
        "operationId": "bulkSetCommerceOrderAttribution",
        "summary": "Bulk-set attribution for multiple commerce orders",
        "tags": [
          "commerce"
        ],
        "description": "Applies the same manual attribution override to up to 500 commerce orders in the caller team and returns the number updated plus skipped order ids.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "order_ids",
                  "campaign_id"
                ],
                "properties": {
                  "order_ids": {
                    "minItems": 1,
                    "maxItems": 500,
                    "type": "array",
                    "items": {
                      "format": "uuid",
                      "type": "string"
                    }
                  },
                  "campaign_id": {
                    "anyOf": [
                      {
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "campaign_name": {
                    "anyOf": [
                      {
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "note": {
                    "anyOf": [
                      {
                        "maxLength": 1000,
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "updated",
                    "skipped"
                  ],
                  "properties": {
                    "updated": {
                      "type": "integer"
                    },
                    "skipped": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/commerce/orders/{orderId}/attribution/history": {
      "get": {
        "operationId": "getCommerceOrderAttributionHistory",
        "summary": "Get manual attribution audit log for a commerce order",
        "tags": [
          "commerce"
        ],
        "description": "Returns manual attribution changes for one commerce order, including previous and new campaign values, actor details, timestamp, change type, and optional note.",
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "orderId",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "items"
                  ],
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "id",
                          "changed_at",
                          "change_type",
                          "from_campaign_id",
                          "from_campaign_name",
                          "to_campaign_id",
                          "to_campaign_name",
                          "changed_by_user_id",
                          "changed_by_name",
                          "changed_by_email",
                          "note"
                        ],
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "changed_at": {
                            "type": "string"
                          },
                          "change_type": {
                            "anyOf": [
                              {
                                "type": "string",
                                "enum": [
                                  "manual_attribute"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "manual_reattribute"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "manual_unattribute"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "revert_to_auto"
                                ]
                              }
                            ]
                          },
                          "from_campaign_id": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "from_campaign_name": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "to_campaign_id": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "to_campaign_name": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "changed_by_user_id": {
                            "type": "string"
                          },
                          "changed_by_name": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "changed_by_email": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "note": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/commerce/catalog-priority": {
      "get": {
        "operationId": "getApiV1CommerceCatalogPriority",
        "summary": "List commerce catalog source priority",
        "tags": [
          "commerce"
        ],
        "description": "Returns the current source-type ordering used when resolving commerce catalog records for the active team.",
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "ordering"
                  ],
                  "properties": {
                    "ordering": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "priorityRank",
                          "sourceType",
                          "updatedAt"
                        ],
                        "properties": {
                          "priorityRank": {
                            "minimum": 1,
                            "type": "integer"
                          },
                          "sourceType": {
                            "type": "string"
                          },
                          "updatedAt": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "apiKeyAuth": []
          }
        ]
      },
      "put": {
        "operationId": "putApiV1CommerceCatalogPriority",
        "summary": "Replace commerce catalog source priority",
        "tags": [
          "commerce"
        ],
        "description": "Replaces the team-level source-type ordering after validating that ranks and source types are unique.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "ordering"
                ],
                "properties": {
                  "ordering": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "required": [
                        "priorityRank",
                        "sourceType"
                      ],
                      "properties": {
                        "priorityRank": {
                          "minimum": 1,
                          "type": "integer"
                        },
                        "sourceType": {
                          "minLength": 1,
                          "type": "string"
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "ok"
                  ],
                  "properties": {
                    "ok": {
                      "type": "boolean",
                      "enum": [
                        true
                      ]
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ]
      }
    },
    "/api/v1/commerce/customers/new": {
      "get": {
        "operationId": "getCommerceNewCustomers",
        "summary": "New customers per day (first-ever order date) for the team",
        "tags": [
          "commerce"
        ],
        "description": "Counts customers whose first recorded order falls on each day in the requested range, scoped to the caller team and optionally filtered to one connected store.",
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "from",
            "required": true,
            "description": "ISO date (inclusive lower bound)"
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "to",
            "required": true,
            "description": "ISO date (inclusive upper bound)"
          },
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "query",
            "name": "catalog_source_id",
            "required": false
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "items"
                  ],
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "date",
                          "new_customers"
                        ],
                        "properties": {
                          "date": {
                            "type": "string"
                          },
                          "new_customers": {
                            "type": "integer"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/commerce/match-queue": {
      "get": {
        "operationId": "getApiV1CommerceMatchQueue",
        "summary": "List commerce match review queue",
        "tags": [
          "commerce"
        ],
        "description": "Returns pending low-confidence catalog match candidates for the active team, capped by the optional limit.",
        "parameters": [
          {
            "schema": {
              "minimum": 1,
              "maximum": 500,
              "type": "integer"
            },
            "in": "query",
            "name": "limit",
            "required": false
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "items",
                    "autoApproveThreshold"
                  ],
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "id",
                          "candidateExternalId",
                          "candidateSourceId",
                          "confidence",
                          "createdAt",
                          "status",
                          "variantMasterId"
                        ],
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "candidateExternalId": {
                            "type": "string"
                          },
                          "candidateSourceId": {
                            "type": "string"
                          },
                          "confidence": {
                            "type": "number"
                          },
                          "createdAt": {
                            "type": "string"
                          },
                          "status": {
                            "anyOf": [
                              {
                                "type": "string",
                                "enum": [
                                  "pending"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "approved"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "rejected"
                                ]
                              }
                            ]
                          },
                          "variantMasterId": {
                            "type": "string"
                          }
                        }
                      }
                    },
                    "autoApproveThreshold": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ]
      }
    },
    "/api/v1/commerce/match-queue/{id}/approve": {
      "post": {
        "operationId": "postApiV1CommerceMatchQueueByIdApprove",
        "summary": "Approve a commerce match candidate",
        "tags": [
          "commerce"
        ],
        "description": "Marks one pending catalog match review item as approved for the active team and records the reviewer.",
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "ok"
                  ],
                  "properties": {
                    "ok": {
                      "type": "boolean",
                      "enum": [
                        true
                      ]
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ]
      }
    },
    "/api/v1/commerce/match-queue/{id}/reject": {
      "post": {
        "operationId": "postApiV1CommerceMatchQueueByIdReject",
        "summary": "Reject a commerce match candidate",
        "tags": [
          "commerce"
        ],
        "description": "Marks one pending catalog match review item as rejected for the active team and records the reviewer.",
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "ok"
                  ],
                  "properties": {
                    "ok": {
                      "type": "boolean",
                      "enum": [
                        true
                      ]
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ]
      }
    },
    "/api/v1/commerce/match-queue/bulk-approve": {
      "post": {
        "operationId": "postApiV1CommerceMatchQueueBulkApprove",
        "summary": "Bulk-approve commerce match candidates",
        "tags": [
          "commerce"
        ],
        "description": "Approves all pending catalog match review items above the supplied confidence threshold for the active team.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "minConfidence": {
                    "minimum": 0,
                    "maximum": 1,
                    "type": "number"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "approvedCount"
                  ],
                  "properties": {
                    "approvedCount": {
                      "minimum": 0,
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ]
      }
    },
    "/api/v1/commerce/revenue/summary": {
      "get": {
        "operationId": "getCommerceRevenueSummary",
        "summary": "Get source-agnostic commerce revenue summary",
        "tags": [
          "commerce"
        ],
        "description": "Returns total revenue, profit, orders, spend, ROAS, margin, and related commerce KPIs for the caller team across connected commerce sources.",
        "parameters": [
          {
            "schema": {
              "format": "date",
              "type": "string"
            },
            "in": "query",
            "name": "from",
            "required": true
          },
          {
            "schema": {
              "format": "date",
              "type": "string"
            },
            "in": "query",
            "name": "to",
            "required": true
          },
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "query",
            "name": "catalog_source_id",
            "required": false
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "total_revenue",
                    "total_sales",
                    "gross_sales",
                    "net_sales",
                    "total_profit",
                    "total_cogs",
                    "total_refunds",
                    "total_orders",
                    "attributed_orders",
                    "unattributed_orders",
                    "attribution_rate_pct",
                    "avg_order_value",
                    "avg_profit_margin_pct",
                    "total_sessions",
                    "total_sessions_added_to_cart",
                    "total_sessions_reached_checkout",
                    "total_sessions_completed_checkout",
                    "currency"
                  ],
                  "properties": {
                    "total_revenue": {
                      "type": "number"
                    },
                    "total_sales": {
                      "description": "Shopify's Total sales for the period. Null when the store has no collected sales data.",
                      "anyOf": [
                        {
                          "type": "number"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "gross_sales": {
                      "description": "Shopify's Gross sales: product revenue before discounts, returns, tax and shipping. Null when N/A.",
                      "anyOf": [
                        {
                          "type": "number"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "net_sales": {
                      "description": "Shopify's Net sales: gross sales minus discounts and returns. Null when N/A.",
                      "anyOf": [
                        {
                          "type": "number"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "total_profit": {
                      "anyOf": [
                        {
                          "type": "number"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "total_cogs": {
                      "type": "number"
                    },
                    "total_refunds": {
                      "type": "number"
                    },
                    "total_orders": {
                      "type": "number"
                    },
                    "attributed_orders": {
                      "type": "number"
                    },
                    "unattributed_orders": {
                      "type": "number"
                    },
                    "attribution_rate_pct": {
                      "type": "number"
                    },
                    "avg_order_value": {
                      "type": "number"
                    },
                    "avg_profit_margin_pct": {
                      "anyOf": [
                        {
                          "type": "number"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "total_sessions": {
                      "type": "number"
                    },
                    "total_sessions_added_to_cart": {
                      "type": "number"
                    },
                    "total_sessions_reached_checkout": {
                      "type": "number"
                    },
                    "total_sessions_completed_checkout": {
                      "type": "number"
                    },
                    "currency": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/commerce/revenue/by-campaign": {
      "get": {
        "operationId": "getCommerceRevenueByCampaign",
        "summary": "Get source-agnostic commerce revenue by campaign",
        "tags": [
          "commerce"
        ],
        "description": "Returns paginated campaign-level commerce revenue, profit, spend, order, ROAS, and margin metrics for the requested date range with cursor pagination and sorting.",
        "parameters": [
          {
            "schema": {
              "format": "date",
              "type": "string"
            },
            "in": "query",
            "name": "from",
            "required": true
          },
          {
            "schema": {
              "format": "date",
              "type": "string"
            },
            "in": "query",
            "name": "to",
            "required": true
          },
          {
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "enum": [
                    "revenue"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "profit"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "spend"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "orders"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "roas"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "margin"
                  ]
                }
              ]
            },
            "in": "query",
            "name": "sort_by",
            "required": false
          },
          {
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "enum": [
                    "asc"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "desc"
                  ]
                }
              ]
            },
            "in": "query",
            "name": "sort_dir",
            "required": false
          },
          {
            "schema": {
              "minimum": 1,
              "maximum": 200,
              "type": "integer"
            },
            "in": "query",
            "name": "limit",
            "required": false
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "cursor",
            "required": false
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "items",
                    "unattributed",
                    "next_cursor"
                  ],
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "campaign_id",
                          "campaign_name",
                          "revenue",
                          "spend",
                          "roas",
                          "profit",
                          "margin_pct",
                          "orders_count",
                          "units_sold",
                          "high_confidence",
                          "medium_confidence",
                          "low_confidence",
                          "currency",
                          "platform"
                        ],
                        "properties": {
                          "campaign_id": {
                            "type": "string"
                          },
                          "campaign_name": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "revenue": {
                            "type": "number"
                          },
                          "spend": {
                            "type": "number"
                          },
                          "roas": {
                            "anyOf": [
                              {
                                "type": "number"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "profit": {
                            "anyOf": [
                              {
                                "type": "number"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "margin_pct": {
                            "anyOf": [
                              {
                                "type": "number"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "orders_count": {
                            "type": "number"
                          },
                          "units_sold": {
                            "type": "number"
                          },
                          "high_confidence": {
                            "type": "number"
                          },
                          "medium_confidence": {
                            "type": "number"
                          },
                          "low_confidence": {
                            "type": "number"
                          },
                          "currency": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "platform": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          }
                        }
                      }
                    },
                    "unattributed": {
                      "type": "object",
                      "required": [
                        "revenue",
                        "orders_count",
                        "units_sold",
                        "profit"
                      ],
                      "properties": {
                        "revenue": {
                          "type": "number"
                        },
                        "orders_count": {
                          "type": "number"
                        },
                        "units_sold": {
                          "type": "number"
                        },
                        "profit": {
                          "anyOf": [
                            {
                              "type": "number"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        }
                      }
                    },
                    "next_cursor": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/commerce/revenue/trend": {
      "get": {
        "operationId": "getCommerceRevenueTrend",
        "summary": "Get source-agnostic commerce revenue trend",
        "tags": [
          "commerce"
        ],
        "description": "Returns revenue/profit trend buckets for the requested date range and granularity, optionally filtered to one connected commerce store.",
        "parameters": [
          {
            "schema": {
              "format": "date",
              "type": "string"
            },
            "in": "query",
            "name": "from",
            "required": true
          },
          {
            "schema": {
              "format": "date",
              "type": "string"
            },
            "in": "query",
            "name": "to",
            "required": true
          },
          {
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "enum": [
                    "day"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "week"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "month"
                  ]
                }
              ]
            },
            "in": "query",
            "name": "granularity",
            "required": false
          },
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "query",
            "name": "catalog_source_id",
            "required": false
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "points",
                    "coverage"
                  ],
                  "properties": {
                    "points": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "date",
                          "revenue",
                          "total_sales",
                          "gross_sales",
                          "net_sales",
                          "profit",
                          "cogs",
                          "orders_count",
                          "refunds",
                          "sessions",
                          "margin_pct"
                        ],
                        "properties": {
                          "date": {
                            "type": "string"
                          },
                          "revenue": {
                            "type": "number"
                          },
                          "total_sales": {
                            "type": "number"
                          },
                          "gross_sales": {
                            "type": "number"
                          },
                          "net_sales": {
                            "type": "number"
                          },
                          "profit": {
                            "anyOf": [
                              {
                                "type": "number"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "cogs": {
                            "type": "number"
                          },
                          "orders_count": {
                            "type": "number"
                          },
                          "refunds": {
                            "type": "number"
                          },
                          "sessions": {
                            "type": "number"
                          },
                          "margin_pct": {
                            "anyOf": [
                              {
                                "type": "number"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          }
                        }
                      }
                    },
                    "coverage": {
                      "type": "object",
                      "required": [
                        "full_pct",
                        "partial_pct",
                        "missing_pct"
                      ],
                      "properties": {
                        "full_pct": {
                          "type": "number"
                        },
                        "partial_pct": {
                          "type": "number"
                        },
                        "missing_pct": {
                          "type": "number"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/commerce/revenue/by-product": {
      "get": {
        "operationId": "getCommerceRevenueByProduct",
        "summary": "Get source-agnostic commerce revenue by product",
        "tags": [
          "commerce"
        ],
        "description": "Returns paginated product-level revenue, profit, units, margin, and related commerce metrics for the requested date range, optionally filtered to one store.",
        "parameters": [
          {
            "schema": {
              "format": "date",
              "type": "string"
            },
            "in": "query",
            "name": "from",
            "required": true
          },
          {
            "schema": {
              "format": "date",
              "type": "string"
            },
            "in": "query",
            "name": "to",
            "required": true
          },
          {
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "enum": [
                    "profit"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "revenue"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "units"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "margin"
                  ]
                }
              ]
            },
            "in": "query",
            "name": "sort_by",
            "required": false
          },
          {
            "schema": {
              "minimum": 1,
              "maximum": 200,
              "type": "integer"
            },
            "in": "query",
            "name": "limit",
            "required": false
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "cursor",
            "required": false
          },
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "query",
            "name": "catalog_source_id",
            "required": false
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "items",
                    "next_cursor"
                  ],
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "variant_id",
                          "product_id",
                          "product_title",
                          "variant_title",
                          "sku",
                          "revenue",
                          "cogs",
                          "profit",
                          "margin_pct",
                          "units_sold",
                          "orders_count"
                        ],
                        "properties": {
                          "variant_id": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "product_id": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "product_title": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "variant_title": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "sku": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "revenue": {
                            "type": "number"
                          },
                          "cogs": {
                            "type": "number"
                          },
                          "profit": {
                            "anyOf": [
                              {
                                "type": "number"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "margin_pct": {
                            "anyOf": [
                              {
                                "type": "number"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "units_sold": {
                            "type": "number"
                          },
                          "orders_count": {
                            "type": "number"
                          }
                        }
                      }
                    },
                    "next_cursor": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/commerce/revenue/product-campaign-matrix": {
      "get": {
        "operationId": "getCommerceProductCampaignMatrix",
        "summary": "Get source-agnostic commerce product/campaign matrix",
        "tags": [
          "commerce"
        ],
        "description": "Returns the top product-to-campaign revenue/profit matrix rows for the requested date range so clients can show which campaigns drive each product.",
        "parameters": [
          {
            "schema": {
              "format": "date",
              "type": "string"
            },
            "in": "query",
            "name": "from",
            "required": true
          },
          {
            "schema": {
              "format": "date",
              "type": "string"
            },
            "in": "query",
            "name": "to",
            "required": true
          },
          {
            "schema": {
              "minimum": 1,
              "maximum": 100,
              "type": "integer"
            },
            "in": "query",
            "name": "limit",
            "required": false
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "items"
                  ],
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "variant_master_id",
                          "product_title",
                          "variant_title",
                          "sku",
                          "total_revenue",
                          "total_units",
                          "total_profit",
                          "campaigns"
                        ],
                        "properties": {
                          "variant_master_id": {
                            "type": "string"
                          },
                          "product_title": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "variant_title": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "sku": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "total_revenue": {
                            "type": "number"
                          },
                          "total_units": {
                            "type": "number"
                          },
                          "total_profit": {
                            "anyOf": [
                              {
                                "type": "number"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "campaigns": {
                            "type": "array",
                            "items": {
                              "type": "object",
                              "required": [
                                "campaign_id",
                                "campaign_name",
                                "revenue",
                                "units_sold",
                                "spend",
                                "roas"
                              ],
                              "properties": {
                                "campaign_id": {
                                  "type": "string"
                                },
                                "campaign_name": {
                                  "anyOf": [
                                    {
                                      "type": "string"
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "revenue": {
                                  "type": "number"
                                },
                                "units_sold": {
                                  "type": "number"
                                },
                                "spend": {
                                  "type": "number"
                                },
                                "roas": {
                                  "anyOf": [
                                    {
                                      "type": "number"
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                }
                              }
                            }
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/commerce/stores/{sourceId}/orders/{orderId}": {
      "get": {
        "operationId": "getStoreOrderDetail",
        "summary": "Get one order of a connected store with its line items",
        "tags": [
          "commerce"
        ],
        "description": "Returns a single order (summary + attribution + UTM) and its line items (product/variant, quantity, unit price, line total) resolved from the order CDM for that store. Responds 404 when the store does not exist in the caller active scope, and when the order does not exist in that store.",
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "sourceId",
            "required": true
          },
          {
            "schema": {
              "minLength": 1,
              "type": "string"
            },
            "in": "path",
            "name": "orderId",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "order",
                    "line_items",
                    "refunds",
                    "raw"
                  ],
                  "properties": {
                    "order": {
                      "type": "object",
                      "required": [
                        "id",
                        "external_order_id",
                        "order_name",
                        "placed_at",
                        "total",
                        "currency",
                        "item_count",
                        "status",
                        "financial_status",
                        "fulfillment_status",
                        "attributed",
                        "campaign",
                        "customer",
                        "discount_codes",
                        "utm_source",
                        "utm_medium",
                        "utm_campaign",
                        "attribution",
                        "profit"
                      ],
                      "properties": {
                        "id": {
                          "type": "string"
                        },
                        "external_order_id": {
                          "type": "string"
                        },
                        "order_name": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "placed_at": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "total": {
                          "anyOf": [
                            {
                              "type": "number"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "currency": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "item_count": {
                          "type": "integer"
                        },
                        "status": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "financial_status": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "fulfillment_status": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "attributed": {
                          "type": "boolean"
                        },
                        "campaign": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "customer": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "discount_codes": {
                          "type": "array",
                          "items": {
                            "type": "string"
                          }
                        },
                        "utm_source": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "utm_medium": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "utm_campaign": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "attribution": {
                          "type": "object",
                          "required": [
                            "attribution_method",
                            "confidence",
                            "confidence_level",
                            "explanation",
                            "manual_override",
                            "match_status",
                            "matched_entity_id",
                            "matched_entity_name",
                            "matched_entity_platform",
                            "matched_entity_type"
                          ],
                          "properties": {
                            "attribution_method": {
                              "anyOf": [
                                {
                                  "type": "string"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "confidence": {
                              "anyOf": [
                                {
                                  "type": "number"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "confidence_level": {
                              "anyOf": [
                                {
                                  "type": "string"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "explanation": {
                              "anyOf": [
                                {
                                  "type": "string"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "manual_override": {
                              "type": "boolean"
                            },
                            "match_status": {
                              "type": "string"
                            },
                            "matched_entity_id": {
                              "anyOf": [
                                {
                                  "type": "string"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "matched_entity_name": {
                              "anyOf": [
                                {
                                  "type": "string"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "matched_entity_platform": {
                              "anyOf": [
                                {
                                  "type": "string"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "matched_entity_type": {
                              "anyOf": [
                                {
                                  "type": "string"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            }
                          }
                        },
                        "profit": {
                          "type": "object",
                          "required": [
                            "revenue",
                            "cogs",
                            "refund_impact",
                            "shipping",
                            "tax",
                            "gross_profit",
                            "coverage_state",
                            "currency"
                          ],
                          "properties": {
                            "revenue": {
                              "anyOf": [
                                {
                                  "type": "number"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "cogs": {
                              "anyOf": [
                                {
                                  "type": "number"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "refund_impact": {
                              "anyOf": [
                                {
                                  "type": "number"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "shipping": {
                              "anyOf": [
                                {
                                  "type": "number"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "tax": {
                              "anyOf": [
                                {
                                  "type": "number"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "gross_profit": {
                              "anyOf": [
                                {
                                  "type": "number"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "coverage_state": {
                              "anyOf": [
                                {
                                  "type": "string"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "currency": {
                              "anyOf": [
                                {
                                  "type": "string"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            }
                          }
                        }
                      }
                    },
                    "line_items": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "external_line_id",
                          "title",
                          "option_label",
                          "sku",
                          "qty",
                          "unit_price",
                          "line_total",
                          "unit_cost",
                          "margin_pct"
                        ],
                        "properties": {
                          "external_line_id": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "title": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "option_label": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "sku": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "qty": {
                            "type": "integer"
                          },
                          "unit_price": {
                            "anyOf": [
                              {
                                "type": "number"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "line_total": {
                            "anyOf": [
                              {
                                "type": "number"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "unit_cost": {
                            "anyOf": [
                              {
                                "type": "number"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "margin_pct": {
                            "anyOf": [
                              {
                                "type": "number"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          }
                        }
                      }
                    },
                    "refunds": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "amount",
                          "reason",
                          "created_at"
                        ],
                        "properties": {
                          "amount": {
                            "anyOf": [
                              {
                                "type": "number"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "reason": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "created_at": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          }
                        }
                      }
                    },
                    "raw": {
                      "anyOf": [
                        {
                          "type": "object",
                          "required": [
                            "customer_name",
                            "customer_email",
                            "customer_phone",
                            "shipping_method",
                            "shipping_address",
                            "billing_address",
                            "custom_attributes"
                          ],
                          "properties": {
                            "customer_name": {
                              "anyOf": [
                                {
                                  "type": "string"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "customer_email": {
                              "anyOf": [
                                {
                                  "type": "string"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "customer_phone": {
                              "anyOf": [
                                {
                                  "type": "string"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "shipping_method": {
                              "anyOf": [
                                {
                                  "type": "string"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "shipping_address": {
                              "type": "array",
                              "items": {
                                "type": "string"
                              }
                            },
                            "billing_address": {
                              "type": "array",
                              "items": {
                                "type": "string"
                              }
                            },
                            "custom_attributes": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "required": [
                                  "name",
                                  "value"
                                ],
                                "properties": {
                                  "name": {
                                    "type": "string"
                                  },
                                  "value": {
                                    "type": "string"
                                  }
                                }
                              }
                            }
                          }
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/commerce/stores/{sourceId}/orders/export": {
      "get": {
        "operationId": "exportStoreOrders",
        "summary": "Export the filtered orders of one connected store as CSV",
        "tags": [
          "commerce"
        ],
        "description": "Returns the orders of a single catalog source as a CSV download, applying the exact same filters, search and sort as GET /commerce/stores/{sourceId}/orders but without pagination. One row per order, mirroring the order-detail panel section by section: summary, customer and shipping, campaign and attribution (score, level, reason), full profit breakdown, refunds, and line items. The repeating parts collapse into one cell each — \"products\" carries product/variant, sku, quantity, unit price, unit cost, margin and line total; \"refunds\" carries date, reason and amount per refund; \"custom_attributes\" carries the order note attributes. CONTAINS PERSONAL DATA: customer name, email, phone and postal addresses are included for Shopify stores with protected customer data access (empty for other stores and for orders synced before that access was granted). Capped at 20k rows, and X-Export-Truncated is set to true when the filtered set is larger. Responds 404 when the store does not exist in the caller active scope.",
        "parameters": [
          {
            "schema": {
              "format": "date-time",
              "type": "string"
            },
            "in": "query",
            "name": "from",
            "required": false
          },
          {
            "schema": {
              "format": "date-time",
              "type": "string"
            },
            "in": "query",
            "name": "to",
            "required": false
          },
          {
            "schema": {
              "maxLength": 200,
              "type": "string"
            },
            "in": "query",
            "name": "q",
            "required": false
          },
          {
            "schema": {
              "maxLength": 500,
              "type": "string"
            },
            "in": "query",
            "name": "payment",
            "required": false
          },
          {
            "schema": {
              "maxLength": 500,
              "type": "string"
            },
            "in": "query",
            "name": "fulfillment",
            "required": false
          },
          {
            "schema": {
              "maxLength": 500,
              "type": "string"
            },
            "in": "query",
            "name": "shipping",
            "required": false
          },
          {
            "schema": {
              "maxLength": 2000,
              "type": "string"
            },
            "in": "query",
            "name": "campaigns",
            "required": false
          },
          {
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "enum": [
                    "all"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "attributed"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "unattributed"
                  ]
                }
              ]
            },
            "in": "query",
            "name": "attribution",
            "required": false
          },
          {
            "schema": {
              "minimum": 0,
              "type": "number"
            },
            "in": "query",
            "name": "tmin",
            "required": false
          },
          {
            "schema": {
              "minimum": 0,
              "type": "number"
            },
            "in": "query",
            "name": "tmax",
            "required": false
          },
          {
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "enum": [
                    "date"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "total"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "profit"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "order"
                  ]
                }
              ]
            },
            "in": "query",
            "name": "sort",
            "required": false
          },
          {
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "enum": [
                    "asc"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "desc"
                  ]
                }
              ]
            },
            "in": "query",
            "name": "dir",
            "required": false
          },
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "sourceId",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/commerce/stores/{sourceId}/orders": {
      "get": {
        "operationId": "getStoreOrders",
        "summary": "List orders for one connected store (server-side filtered, sorted and paginated)",
        "tags": [
          "commerce"
        ],
        "description": "Returns one page of orders for a single catalog source, filtered/sorted server-side, with item quantity, financial/fulfillment status, campaign attribution, gross profit, shipping method and a pseudonymous customer id. KPIs (orders, revenue, AOV, refunds) and filter facets are computed over the whole filtered set, not just the page. Responds 404 when the store does not exist in the caller active scope.",
        "parameters": [
          {
            "schema": {
              "format": "date-time",
              "type": "string"
            },
            "in": "query",
            "name": "from",
            "required": false
          },
          {
            "schema": {
              "format": "date-time",
              "type": "string"
            },
            "in": "query",
            "name": "to",
            "required": false
          },
          {
            "schema": {
              "maxLength": 200,
              "type": "string"
            },
            "in": "query",
            "name": "q",
            "required": false
          },
          {
            "schema": {
              "maxLength": 500,
              "type": "string"
            },
            "in": "query",
            "name": "payment",
            "required": false
          },
          {
            "schema": {
              "maxLength": 500,
              "type": "string"
            },
            "in": "query",
            "name": "fulfillment",
            "required": false
          },
          {
            "schema": {
              "maxLength": 500,
              "type": "string"
            },
            "in": "query",
            "name": "shipping",
            "required": false
          },
          {
            "schema": {
              "maxLength": 2000,
              "type": "string"
            },
            "in": "query",
            "name": "campaigns",
            "required": false
          },
          {
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "enum": [
                    "all"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "attributed"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "unattributed"
                  ]
                }
              ]
            },
            "in": "query",
            "name": "attribution",
            "required": false
          },
          {
            "schema": {
              "minimum": 0,
              "type": "number"
            },
            "in": "query",
            "name": "tmin",
            "required": false
          },
          {
            "schema": {
              "minimum": 0,
              "type": "number"
            },
            "in": "query",
            "name": "tmax",
            "required": false
          },
          {
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "enum": [
                    "date"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "total"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "profit"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "order"
                  ]
                }
              ]
            },
            "in": "query",
            "name": "sort",
            "required": false
          },
          {
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "enum": [
                    "asc"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "desc"
                  ]
                }
              ]
            },
            "in": "query",
            "name": "dir",
            "required": false
          },
          {
            "schema": {
              "minimum": 1,
              "maximum": 200,
              "type": "integer"
            },
            "in": "query",
            "name": "limit",
            "required": false
          },
          {
            "schema": {
              "minimum": 0,
              "type": "integer"
            },
            "in": "query",
            "name": "offset",
            "required": false
          },
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "sourceId",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "kpis",
                    "facets",
                    "page",
                    "has_profit",
                    "orders"
                  ],
                  "properties": {
                    "kpis": {
                      "type": "object",
                      "required": [
                        "orders",
                        "revenue",
                        "aov",
                        "refunds",
                        "gross_profit"
                      ],
                      "properties": {
                        "orders": {
                          "type": "integer"
                        },
                        "revenue": {
                          "type": "number"
                        },
                        "aov": {
                          "type": "number"
                        },
                        "refunds": {
                          "type": "integer"
                        },
                        "gross_profit": {
                          "type": "number"
                        }
                      }
                    },
                    "facets": {
                      "type": "object",
                      "required": [
                        "payment_statuses",
                        "fulfillment_statuses",
                        "shipping_methods"
                      ],
                      "properties": {
                        "payment_statuses": {
                          "type": "array",
                          "items": {
                            "type": "string"
                          }
                        },
                        "fulfillment_statuses": {
                          "type": "array",
                          "items": {
                            "type": "string"
                          }
                        },
                        "shipping_methods": {
                          "type": "array",
                          "items": {
                            "type": "string"
                          }
                        }
                      }
                    },
                    "page": {
                      "type": "object",
                      "required": [
                        "limit",
                        "offset",
                        "total",
                        "has_more"
                      ],
                      "properties": {
                        "limit": {
                          "type": "integer"
                        },
                        "offset": {
                          "type": "integer"
                        },
                        "total": {
                          "type": "integer"
                        },
                        "has_more": {
                          "type": "boolean"
                        }
                      }
                    },
                    "has_profit": {
                      "type": "boolean"
                    },
                    "orders": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "external_order_id",
                          "order_name",
                          "placed_at",
                          "total",
                          "currency",
                          "item_count",
                          "status",
                          "financial_status",
                          "fulfillment_status",
                          "attributed",
                          "confidence",
                          "campaign",
                          "campaign_id",
                          "campaign_platform",
                          "customer",
                          "profit",
                          "shipping_method"
                        ],
                        "properties": {
                          "external_order_id": {
                            "type": "string"
                          },
                          "order_name": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "placed_at": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "total": {
                            "anyOf": [
                              {
                                "type": "number"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "currency": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "item_count": {
                            "type": "integer"
                          },
                          "status": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "financial_status": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "fulfillment_status": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "attributed": {
                            "type": "boolean"
                          },
                          "confidence": {
                            "anyOf": [
                              {
                                "type": "number"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "campaign": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "campaign_id": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "campaign_platform": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "customer": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "profit": {
                            "anyOf": [
                              {
                                "type": "number"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "shipping_method": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/commerce/stores/{sourceId}/products/{parentExternalId}/provenance": {
      "get": {
        "operationId": "getStoreProductProvenance",
        "summary": "Cross-source provenance for one per-store product",
        "tags": [
          "commerce"
        ],
        "description": "Resolves the product variants of a store to their unified variant_master ids and returns the other catalog sources that sell the same master (cross-source provenance), plus whether any master has a pending match-review entry. Responds 404 when the store does not exist in the caller active scope.",
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "sourceId",
            "required": true
          },
          {
            "schema": {
              "minLength": 1,
              "type": "string"
            },
            "in": "path",
            "name": "parentExternalId",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "master_count",
                    "needs_review",
                    "sources",
                    "collections",
                    "metafields"
                  ],
                  "properties": {
                    "master_count": {
                      "type": "integer"
                    },
                    "needs_review": {
                      "type": "boolean"
                    },
                    "sources": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "id",
                          "name",
                          "type",
                          "is_current"
                        ],
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "name": {
                            "type": "string"
                          },
                          "type": {
                            "type": "string"
                          },
                          "is_current": {
                            "type": "boolean"
                          }
                        }
                      }
                    },
                    "collections": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "metafields": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "namespace",
                          "key",
                          "value"
                        ],
                        "properties": {
                          "namespace": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "key": {
                            "type": "string"
                          },
                          "value": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/commerce/stores/{sourceId}/products/{parentExternalId}/campaigns": {
      "get": {
        "operationId": "getStoreProductCampaigns",
        "summary": "Campaigns that advertised one per-store product",
        "tags": [
          "commerce"
        ],
        "description": "Resolves the product variants of a store to their unified variant_master ids and returns the campaigns that generated sales for them (aggregated revenue, units, spend and ROAS) from the campaign/product daily stats. Empty until attribution recompute has populated the stats.",
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "sourceId",
            "required": true
          },
          {
            "schema": {
              "minLength": 1,
              "type": "string"
            },
            "in": "path",
            "name": "parentExternalId",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "campaigns"
                  ],
                  "properties": {
                    "campaigns": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "campaign_id",
                          "campaign_name",
                          "platform",
                          "revenue",
                          "units_sold",
                          "spend",
                          "roas"
                        ],
                        "properties": {
                          "campaign_id": {
                            "type": "string"
                          },
                          "campaign_name": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "platform": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "revenue": {
                            "type": "number"
                          },
                          "units_sold": {
                            "type": "integer"
                          },
                          "spend": {
                            "type": "number"
                          },
                          "roas": {
                            "anyOf": [
                              {
                                "type": "number"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/commerce/stores/{sourceId}/products": {
      "get": {
        "operationId": "getStoreProducts",
        "summary": "List products (grouped by parent, with variants) for one connected store",
        "tags": [
          "commerce"
        ],
        "description": "Returns one page of products for a single catalog source, grouped by parent product and filtered/sorted server-side, each with its variants, plus overview KPIs computed over the whole filtered set. Read from the normalized source-variant CDM for that store. Stock is read in this order: a variant the store marks as not available for sale counts as out of stock whether or not a quantity exists; otherwise, a variant the store keeps no count for (no stock value, or a stock policy of 'untracked') counts as available and stays out of the out_of_stock KPI, even when the connector reports its quantity as 0; otherwise the counted quantity decides.",
        "parameters": [
          {
            "schema": {
              "maxLength": 200,
              "type": "string"
            },
            "in": "query",
            "name": "q",
            "required": false
          },
          {
            "schema": {
              "maxLength": 40,
              "type": "string"
            },
            "in": "query",
            "name": "status",
            "required": false
          },
          {
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "enum": [
                    "all"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "in"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "out"
                  ]
                }
              ]
            },
            "in": "query",
            "name": "stock",
            "required": false
          },
          {
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "enum": [
                    "all"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "with"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "missing"
                  ]
                }
              ]
            },
            "in": "query",
            "name": "cost",
            "required": false
          },
          {
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "enum": [
                    "title"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "price"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "stock"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "variants"
                  ]
                }
              ]
            },
            "in": "query",
            "name": "sort",
            "required": false
          },
          {
            "schema": {
              "minimum": 1,
              "maximum": 200,
              "type": "integer"
            },
            "in": "query",
            "name": "limit",
            "required": false
          },
          {
            "schema": {
              "minimum": 0,
              "type": "integer"
            },
            "in": "query",
            "name": "offset",
            "required": false
          },
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "sourceId",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "kpis",
                    "page",
                    "products"
                  ],
                  "properties": {
                    "kpis": {
                      "type": "object",
                      "required": [
                        "products",
                        "variants",
                        "active",
                        "out_of_stock",
                        "cost_coverage_pct"
                      ],
                      "properties": {
                        "products": {
                          "type": "integer"
                        },
                        "variants": {
                          "type": "integer"
                        },
                        "active": {
                          "type": "integer"
                        },
                        "out_of_stock": {
                          "type": "integer"
                        },
                        "cost_coverage_pct": {
                          "type": "integer"
                        }
                      }
                    },
                    "page": {
                      "type": "object",
                      "required": [
                        "limit",
                        "offset",
                        "total",
                        "has_more"
                      ],
                      "properties": {
                        "limit": {
                          "type": "integer"
                        },
                        "offset": {
                          "type": "integer"
                        },
                        "total": {
                          "type": "integer"
                        },
                        "has_more": {
                          "type": "boolean"
                        }
                      }
                    },
                    "products": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "parent_external_id",
                          "title",
                          "status",
                          "category",
                          "description",
                          "vendor",
                          "handle",
                          "images",
                          "tags",
                          "image_url",
                          "currency",
                          "variant_count",
                          "stock_total",
                          "price_min",
                          "price_max",
                          "variants"
                        ],
                        "properties": {
                          "parent_external_id": {
                            "type": "string"
                          },
                          "title": {
                            "type": "string"
                          },
                          "status": {
                            "type": "string"
                          },
                          "category": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "description": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "vendor": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "handle": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "images": {
                            "type": "array",
                            "items": {
                              "type": "string"
                            }
                          },
                          "tags": {
                            "type": "array",
                            "items": {
                              "type": "string"
                            }
                          },
                          "image_url": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "currency": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "variant_count": {
                            "type": "integer"
                          },
                          "stock_total": {
                            "type": "integer"
                          },
                          "price_min": {
                            "anyOf": [
                              {
                                "type": "number"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "price_max": {
                            "anyOf": [
                              {
                                "type": "number"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "variants": {
                            "type": "array",
                            "items": {
                              "type": "object",
                              "required": [
                                "id",
                                "external_id",
                                "sku",
                                "option_label",
                                "price",
                                "compare_at_price",
                                "cost",
                                "margin_pct",
                                "stock",
                                "availability",
                                "gtin",
                                "barcode",
                                "weight_grams",
                                "image_url"
                              ],
                              "properties": {
                                "id": {
                                  "type": "string"
                                },
                                "external_id": {
                                  "type": "string"
                                },
                                "sku": {
                                  "anyOf": [
                                    {
                                      "type": "string"
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "option_label": {
                                  "anyOf": [
                                    {
                                      "type": "string"
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "price": {
                                  "anyOf": [
                                    {
                                      "type": "number"
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "compare_at_price": {
                                  "anyOf": [
                                    {
                                      "type": "number"
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "cost": {
                                  "anyOf": [
                                    {
                                      "type": "number"
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "margin_pct": {
                                  "anyOf": [
                                    {
                                      "type": "number"
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "stock": {
                                  "anyOf": [
                                    {
                                      "type": "integer"
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "availability": {
                                  "anyOf": [
                                    {
                                      "type": "string"
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "gtin": {
                                  "anyOf": [
                                    {
                                      "type": "string"
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "barcode": {
                                  "anyOf": [
                                    {
                                      "type": "string"
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "weight_grams": {
                                  "anyOf": [
                                    {
                                      "type": "number"
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "image_url": {
                                  "anyOf": [
                                    {
                                      "type": "string"
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                }
                              }
                            }
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/commerce/stores/{sourceId}/variants/{id}/cost": {
      "patch": {
        "operationId": "setStoreVariantCost",
        "summary": "Set the unit cost (COGS) of one store variant",
        "tags": [
          "commerce"
        ],
        "description": "Writes a direct cost amount and currency on a CDM source variant of a connected store, regardless of platform. On Shopify stores it also writes the matching variant-level cost override (the only input the Shopify profit pipeline reads), refreshes the profit snapshots of that variant and re-queues the profit recompute.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "cost_amount",
                  "cost_currency"
                ],
                "properties": {
                  "cost_amount": {
                    "minimum": 0,
                    "type": "number"
                  },
                  "cost_currency": {
                    "minLength": 1,
                    "maxLength": 3,
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "sourceId",
            "required": true
          },
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "id",
                    "message"
                  ],
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      },
      "delete": {
        "operationId": "clearStoreVariantCost",
        "summary": "Clear the unit cost (COGS) of one store variant",
        "tags": [
          "commerce"
        ],
        "description": "Clears the direct cost amount and currency from a CDM source variant of a connected store, regardless of platform. On Shopify stores it also removes the matching variant-level cost override, refreshes the profit snapshots of that variant and re-queues the profit recompute.",
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "sourceId",
            "required": true
          },
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "id",
                    "message"
                  ],
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/commerce/stores": {
      "get": {
        "operationId": "getCommerceStores",
        "summary": "List the connected commerce stores for the active workspace scope",
        "tags": [
          "commerce"
        ],
        "description": "Lists active Shopify and WooCommerce catalog sources connected to the caller active scope with display label, normalized URL, and platform type for store filters.",
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "stores"
                  ],
                  "properties": {
                    "stores": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "id",
                          "label",
                          "url",
                          "platform",
                          "status",
                          "connected_at",
                          "last_sync_at",
                          "product_count",
                          "order_count",
                          "shopify_config_id",
                          "woocommerce_config_id"
                        ],
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "label": {
                            "type": "string"
                          },
                          "url": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "platform": {
                            "type": "string"
                          },
                          "status": {
                            "type": "string"
                          },
                          "connected_at": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "last_sync_at": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "product_count": {
                            "type": "integer"
                          },
                          "order_count": {
                            "type": "integer"
                          },
                          "shopify_config_id": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "woocommerce_config_id": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/competitive-intelligence/watchlist": {
      "get": {
        "operationId": "getApiV1CompetitiveIntelligenceWatchlist",
        "summary": "List competitor watchlist",
        "tags": [
          "competitive-intelligence"
        ],
        "description": "List competitor pages tracked by the current team scope.",
        "parameters": [
          {
            "schema": {
              "type": "number"
            },
            "in": "query",
            "name": "limit",
            "required": false
          },
          {
            "schema": {
              "type": "number"
            },
            "in": "query",
            "name": "offset",
            "required": false
          },
          {
            "schema": {
              "maxLength": 200,
              "type": "string"
            },
            "in": "query",
            "name": "search",
            "required": false
          },
          {
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "enum": [
                    "true"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "false"
                  ]
                }
              ]
            },
            "in": "query",
            "name": "is_active",
            "required": false
          },
          {
            "schema": {
              "minLength": 2,
              "maxLength": 5,
              "type": "string"
            },
            "in": "query",
            "name": "country",
            "required": false
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "items"
                  ],
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "countries",
                          "created_at",
                          "id",
                          "is_active",
                          "name",
                          "search_terms"
                        ],
                        "properties": {
                          "ad_count": {
                            "type": "number"
                          },
                          "categories": {
                            "type": "array",
                            "items": {
                              "type": "string"
                            }
                          },
                          "countries": {
                            "type": "array",
                            "items": {
                              "type": "string"
                            }
                          },
                          "created_at": {
                            "type": "string"
                          },
                          "id": {
                            "type": "string"
                          },
                          "is_active": {
                            "type": "boolean"
                          },
                          "last_sync_error": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "last_sync_status": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "last_synced_at": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "name": {
                            "type": "string"
                          },
                          "new_ads_7d": {
                            "type": "number"
                          },
                          "page_id": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "page_name": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "search_terms": {
                            "type": "array",
                            "items": {
                              "type": "string"
                            }
                          },
                          "sync_frequency": {
                            "type": "string"
                          },
                          "team_id": {
                            "type": "string"
                          },
                          "total_ads": {
                            "type": "number"
                          },
                          "updated_at": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "postApiV1CompetitiveIntelligenceWatchlist",
        "summary": "Add competitor to watchlist",
        "tags": [
          "competitive-intelligence"
        ],
        "description": "Add a Meta Ad Library page to the competitor watchlist and queue the first sync.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "page_id",
                  "page_name"
                ],
                "properties": {
                  "categories": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  },
                  "countries": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  },
                  "page_id": {
                    "minLength": 1,
                    "type": "string"
                  },
                  "page_name": {
                    "minLength": 1,
                    "type": "string"
                  },
                  "search_terms": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  },
                  "sync_frequency": {
                    "anyOf": [
                      {
                        "type": "string",
                        "enum": [
                          "daily"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "weekly"
                        ]
                      }
                    ]
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "countries",
                    "created_at",
                    "id",
                    "is_active",
                    "name",
                    "search_terms"
                  ],
                  "properties": {
                    "ad_count": {
                      "type": "number"
                    },
                    "categories": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "countries": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "created_at": {
                      "type": "string"
                    },
                    "id": {
                      "type": "string"
                    },
                    "is_active": {
                      "type": "boolean"
                    },
                    "last_sync_error": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "last_sync_status": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "last_synced_at": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "name": {
                      "type": "string"
                    },
                    "new_ads_7d": {
                      "type": "number"
                    },
                    "page_id": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "page_name": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "search_terms": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "sync_frequency": {
                      "type": "string"
                    },
                    "team_id": {
                      "type": "string"
                    },
                    "total_ads": {
                      "type": "number"
                    },
                    "updated_at": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "402": {
            "description": "Response 402",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "code",
                    "current",
                    "error",
                    "max",
                    "message"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "current": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string",
                      "enum": [
                        "Payment Required"
                      ]
                    },
                    "max": {
                      "type": "number"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/competitive-intelligence/watchlist/{id}": {
      "put": {
        "operationId": "putApiV1CompetitiveIntelligenceWatchlistById",
        "summary": "Update competitor watchlist entry",
        "tags": [
          "competitive-intelligence"
        ],
        "description": "Update a competitor watchlist entry within the current team scope.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "properties": {
                  "categories": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  },
                  "countries": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  },
                  "is_active": {
                    "type": "boolean"
                  },
                  "name": {
                    "minLength": 1,
                    "type": "string"
                  },
                  "page_id": {
                    "type": "string"
                  },
                  "page_name": {
                    "type": "string"
                  },
                  "search_terms": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  },
                  "sync_frequency": {
                    "anyOf": [
                      {
                        "type": "string",
                        "enum": [
                          "daily"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "weekly"
                        ]
                      }
                    ]
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "countries",
                    "created_at",
                    "id",
                    "is_active",
                    "name",
                    "search_terms"
                  ],
                  "properties": {
                    "ad_count": {
                      "type": "number"
                    },
                    "categories": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "countries": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "created_at": {
                      "type": "string"
                    },
                    "id": {
                      "type": "string"
                    },
                    "is_active": {
                      "type": "boolean"
                    },
                    "last_sync_error": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "last_sync_status": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "last_synced_at": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "name": {
                      "type": "string"
                    },
                    "new_ads_7d": {
                      "type": "number"
                    },
                    "page_id": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "page_name": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "search_terms": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "sync_frequency": {
                      "type": "string"
                    },
                    "team_id": {
                      "type": "string"
                    },
                    "total_ads": {
                      "type": "number"
                    },
                    "updated_at": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "402": {
            "description": "Response 402",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "code",
                    "current",
                    "error",
                    "max",
                    "message"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "current": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string",
                      "enum": [
                        "Payment Required"
                      ]
                    },
                    "max": {
                      "type": "number"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      },
      "delete": {
        "operationId": "deleteApiV1CompetitiveIntelligenceWatchlistById",
        "summary": "Remove competitor from watchlist",
        "tags": [
          "competitive-intelligence"
        ],
        "description": "Soft-delete a competitor watchlist entry.",
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "deleted"
                  ],
                  "properties": {
                    "deleted": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/competitive-intelligence/watchlist/{id}/sync": {
      "post": {
        "operationId": "postApiV1CompetitiveIntelligenceWatchlistByIdSync",
        "summary": "Queue competitor ad sync",
        "tags": [
          "competitive-intelligence"
        ],
        "description": "Queue an asynchronous Meta Ad Library sync for a tracked competitor.",
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "status",
                    "watchlist_id"
                  ],
                  "properties": {
                    "status": {
                      "type": "string",
                      "enum": [
                        "queued"
                      ]
                    },
                    "watchlist_id": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/competitive-intelligence/suggestions": {
      "get": {
        "operationId": "getApiV1CompetitiveIntelligenceSuggestions",
        "summary": "List competitor suggestions",
        "tags": [
          "competitive-intelligence"
        ],
        "description": "List competitor suggestions generated for the current team scope.",
        "parameters": [
          {
            "schema": {
              "type": "number"
            },
            "in": "query",
            "name": "limit",
            "required": false
          },
          {
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "enum": [
                    "suggested"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "accepted"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "dismissed"
                  ]
                }
              ]
            },
            "in": "query",
            "name": "status",
            "required": false
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "items"
                  ],
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "confidence_score",
                          "created_at",
                          "id",
                          "name",
                          "source",
                          "status"
                        ],
                        "properties": {
                          "accepted_at": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "confidence_score": {
                            "type": "number"
                          },
                          "created_at": {
                            "type": "string"
                          },
                          "dismissed_at": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "evidence": {
                            "$comment": "json-value"
                          },
                          "id": {
                            "type": "string"
                          },
                          "name": {
                            "type": "string"
                          },
                          "page_id": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "page_name": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "reason": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "source": {
                            "type": "string"
                          },
                          "source_url": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "status": {
                            "type": "string"
                          },
                          "team_id": {
                            "type": "string"
                          },
                          "updated_at": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/competitive-intelligence/suggestions/discover": {
      "post": {
        "operationId": "postApiV1CompetitiveIntelligenceSuggestionsDiscover",
        "summary": "Discover competitor suggestions",
        "tags": [
          "competitive-intelligence"
        ],
        "description": "Discover competitor suggestions using account context and Meta Ad Library pages.",
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "items",
                    "status",
                    "total"
                  ],
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "confidence_score",
                          "created_at",
                          "id",
                          "name",
                          "source",
                          "status"
                        ],
                        "properties": {
                          "accepted_at": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "confidence_score": {
                            "type": "number"
                          },
                          "created_at": {
                            "type": "string"
                          },
                          "dismissed_at": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "evidence": {
                            "$comment": "json-value"
                          },
                          "id": {
                            "type": "string"
                          },
                          "name": {
                            "type": "string"
                          },
                          "page_id": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "page_name": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "reason": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "source": {
                            "type": "string"
                          },
                          "source_url": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "status": {
                            "type": "string"
                          },
                          "team_id": {
                            "type": "string"
                          },
                          "updated_at": {
                            "type": "string"
                          }
                        }
                      }
                    },
                    "status": {
                      "type": "string",
                      "enum": [
                        "completed"
                      ]
                    },
                    "total": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/competitive-intelligence/suggestions/{id}/accept": {
      "post": {
        "operationId": "postApiV1CompetitiveIntelligenceSuggestionsByIdAccept",
        "summary": "Accept competitor suggestion",
        "tags": [
          "competitive-intelligence"
        ],
        "description": "Accept a trackable competitor suggestion and add it to the watchlist.",
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "suggestion",
                    "watchlist"
                  ],
                  "properties": {
                    "suggestion": {
                      "anyOf": [
                        {
                          "type": "object",
                          "required": [
                            "confidence_score",
                            "created_at",
                            "id",
                            "name",
                            "source",
                            "status"
                          ],
                          "properties": {
                            "accepted_at": {
                              "anyOf": [
                                {
                                  "type": "string"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "confidence_score": {
                              "type": "number"
                            },
                            "created_at": {
                              "type": "string"
                            },
                            "dismissed_at": {
                              "anyOf": [
                                {
                                  "type": "string"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "evidence": {
                              "$comment": "json-value"
                            },
                            "id": {
                              "type": "string"
                            },
                            "name": {
                              "type": "string"
                            },
                            "page_id": {
                              "anyOf": [
                                {
                                  "type": "string"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "page_name": {
                              "anyOf": [
                                {
                                  "type": "string"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "reason": {
                              "anyOf": [
                                {
                                  "type": "string"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "source": {
                              "type": "string"
                            },
                            "source_url": {
                              "anyOf": [
                                {
                                  "type": "string"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "status": {
                              "type": "string"
                            },
                            "team_id": {
                              "type": "string"
                            },
                            "updated_at": {
                              "type": "string"
                            }
                          }
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "watchlist": {
                      "type": "object",
                      "required": [
                        "countries",
                        "created_at",
                        "id",
                        "is_active",
                        "name",
                        "search_terms"
                      ],
                      "properties": {
                        "ad_count": {
                          "type": "number"
                        },
                        "categories": {
                          "type": "array",
                          "items": {
                            "type": "string"
                          }
                        },
                        "countries": {
                          "type": "array",
                          "items": {
                            "type": "string"
                          }
                        },
                        "created_at": {
                          "type": "string"
                        },
                        "id": {
                          "type": "string"
                        },
                        "is_active": {
                          "type": "boolean"
                        },
                        "last_sync_error": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "last_sync_status": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "last_synced_at": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "name": {
                          "type": "string"
                        },
                        "new_ads_7d": {
                          "type": "number"
                        },
                        "page_id": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "page_name": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "search_terms": {
                          "type": "array",
                          "items": {
                            "type": "string"
                          }
                        },
                        "sync_frequency": {
                          "type": "string"
                        },
                        "team_id": {
                          "type": "string"
                        },
                        "total_ads": {
                          "type": "number"
                        },
                        "updated_at": {
                          "type": "string"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "402": {
            "description": "Response 402",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "code",
                    "current",
                    "error",
                    "max",
                    "message"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "current": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string",
                      "enum": [
                        "Payment Required"
                      ]
                    },
                    "max": {
                      "type": "number"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/competitive-intelligence/suggestions/{id}/dismiss": {
      "patch": {
        "operationId": "patchApiV1CompetitiveIntelligenceSuggestionsByIdDismiss",
        "summary": "Dismiss competitor suggestion",
        "tags": [
          "competitive-intelligence"
        ],
        "description": "Dismiss a competitor suggestion for the current team scope.",
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "confidence_score",
                    "created_at",
                    "id",
                    "name",
                    "source",
                    "status"
                  ],
                  "properties": {
                    "accepted_at": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "confidence_score": {
                      "type": "number"
                    },
                    "created_at": {
                      "type": "string"
                    },
                    "dismissed_at": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "evidence": {
                      "$comment": "json-value"
                    },
                    "id": {
                      "type": "string"
                    },
                    "name": {
                      "type": "string"
                    },
                    "page_id": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "page_name": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "reason": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "source": {
                      "type": "string"
                    },
                    "source_url": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "status": {
                      "type": "string"
                    },
                    "team_id": {
                      "type": "string"
                    },
                    "updated_at": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/competitive-intelligence/ads": {
      "get": {
        "operationId": "getApiV1CompetitiveIntelligenceAds",
        "summary": "List competitor ads",
        "tags": [
          "competitive-intelligence"
        ],
        "description": "List deduplicated competitor ads with optional filters. `destination` splits on-platform ads (Instant Form / Messenger / WhatsApp — the lead-gen proxy) from ads driving to an external site.",
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "angle",
            "required": false
          },
          {
            "schema": {
              "minLength": 3,
              "maxLength": 8,
              "type": "string"
            },
            "in": "query",
            "name": "currency",
            "required": false
          },
          {
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "enum": [
                    "external"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "on_platform"
                  ]
                }
              ]
            },
            "in": "query",
            "name": "destination",
            "required": false
          },
          {
            "schema": {
              "format": "date",
              "type": "string"
            },
            "in": "query",
            "name": "from_date",
            "required": false
          },
          {
            "schema": {
              "type": "number"
            },
            "in": "query",
            "name": "limit",
            "required": false
          },
          {
            "schema": {
              "type": "number"
            },
            "in": "query",
            "name": "offset",
            "required": false
          },
          {
            "schema": {
              "maxLength": 200,
              "type": "string"
            },
            "in": "query",
            "name": "search",
            "required": false
          },
          {
            "schema": {
              "format": "date",
              "type": "string"
            },
            "in": "query",
            "name": "to_date",
            "required": false
          },
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "query",
            "name": "watchlist_id",
            "required": false
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "items",
                    "total"
                  ],
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "first_seen_at",
                          "id"
                        ],
                        "properties": {
                          "ad_bodies": {
                            "anyOf": [
                              {
                                "type": "array",
                                "items": {
                                  "type": "string"
                                }
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "ad_creation_time": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "ad_delivery_start_time": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "ad_delivery_stop_time": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "ad_descriptions": {
                            "anyOf": [
                              {
                                "type": "array",
                                "items": {
                                  "type": "string"
                                }
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "ad_kind": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "ad_link_captions": {
                            "anyOf": [
                              {
                                "type": "array",
                                "items": {
                                  "type": "string"
                                }
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "ad_snapshot_url": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "ad_titles": {
                            "anyOf": [
                              {
                                "type": "array",
                                "items": {
                                  "type": "string"
                                }
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "age_gender_breakdown": {
                            "$comment": "json-value"
                          },
                          "beneficiary_payers": {
                            "$comment": "json-value"
                          },
                          "competitor_name": {
                            "type": "string"
                          },
                          "creative_analysis": {
                            "$comment": "json-value"
                          },
                          "destination_domains": {
                            "anyOf": [
                              {
                                "type": "array",
                                "items": {
                                  "type": "string"
                                }
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "destination_type": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "eu_total_reach": {
                            "anyOf": [
                              {
                                "type": "number"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "first_seen_at": {
                            "type": "string"
                          },
                          "id": {
                            "type": "string"
                          },
                          "impressions_lower": {
                            "anyOf": [
                              {
                                "type": "number"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "impressions_upper": {
                            "anyOf": [
                              {
                                "type": "number"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "media_extraction_status": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "media_types": {
                            "anyOf": [
                              {
                                "type": "array",
                                "items": {
                                  "type": "string"
                                }
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "media_urls": {
                            "anyOf": [
                              {
                                "type": "array",
                                "items": {
                                  "type": "string"
                                }
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "meta_ad_id": {
                            "type": "string"
                          },
                          "page_id": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "page_name": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "publisher_platforms": {
                            "anyOf": [
                              {
                                "type": "array",
                                "items": {
                                  "type": "string"
                                }
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "reach_max": {
                            "anyOf": [
                              {
                                "type": "number"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "reach_min": {
                            "anyOf": [
                              {
                                "type": "number"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "reach_summed": {
                            "anyOf": [
                              {
                                "type": "number"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "spend_confidence": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "spend_currency": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "spend_estimate_monthly": {
                            "anyOf": [
                              {
                                "type": "number"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "spend_estimate_monthly_eur": {
                            "anyOf": [
                              {
                                "type": "number"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "spend_lower": {
                            "anyOf": [
                              {
                                "type": "number"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "spend_upper": {
                            "anyOf": [
                              {
                                "type": "number"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "target_ages": {
                            "anyOf": [
                              {
                                "type": "array",
                                "items": {
                                  "type": "string"
                                }
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "target_gender": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "target_locations": {
                            "$comment": "json-value"
                          },
                          "targeting_uniform": {
                            "anyOf": [
                              {
                                "type": "boolean"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "team_id": {
                            "type": "string"
                          },
                          "variant_count": {
                            "type": "number"
                          },
                          "variant_meta_ad_ids": {
                            "type": "array",
                            "items": {
                              "type": "string"
                            }
                          },
                          "watchlist_id": {
                            "type": "string"
                          }
                        }
                      }
                    },
                    "total": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/competitive-intelligence/alerts": {
      "get": {
        "operationId": "getApiV1CompetitiveIntelligenceAlerts",
        "summary": "List competitor alerts",
        "tags": [
          "competitive-intelligence"
        ],
        "description": "List competitive-intelligence alerts for the current team scope.",
        "parameters": [
          {
            "schema": {
              "type": "number"
            },
            "in": "query",
            "name": "limit",
            "required": false
          },
          {
            "schema": {
              "type": "boolean"
            },
            "in": "query",
            "name": "unread_only",
            "required": false
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "items"
                  ],
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "created_at",
                          "id",
                          "title"
                        ],
                        "properties": {
                          "alert_type": {
                            "type": "string"
                          },
                          "competitor_ad_id": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "competitor_name": {
                            "type": "string"
                          },
                          "created_at": {
                            "type": "string"
                          },
                          "id": {
                            "type": "string"
                          },
                          "is_read": {
                            "type": "boolean"
                          },
                          "message": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "metadata": {
                            "$comment": "json-value"
                          },
                          "severity": {
                            "type": "string"
                          },
                          "snoozed_until": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "team_id": {
                            "type": "string"
                          },
                          "title": {
                            "type": "string"
                          },
                          "watchlist_id": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/competitive-intelligence/alerts/{id}/read": {
      "patch": {
        "operationId": "patchApiV1CompetitiveIntelligenceAlertsByIdRead",
        "summary": "Mark competitor alert as read",
        "tags": [
          "competitive-intelligence"
        ],
        "description": "Mark a competitive-intelligence alert as read.",
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "created_at",
                    "id",
                    "title"
                  ],
                  "properties": {
                    "alert_type": {
                      "type": "string"
                    },
                    "competitor_ad_id": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "competitor_name": {
                      "type": "string"
                    },
                    "created_at": {
                      "type": "string"
                    },
                    "id": {
                      "type": "string"
                    },
                    "is_read": {
                      "type": "boolean"
                    },
                    "message": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "metadata": {
                      "$comment": "json-value"
                    },
                    "severity": {
                      "type": "string"
                    },
                    "snoozed_until": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "team_id": {
                      "type": "string"
                    },
                    "title": {
                      "type": "string"
                    },
                    "watchlist_id": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/competitive-intelligence/alerts/{id}/snooze": {
      "patch": {
        "operationId": "patchApiV1CompetitiveIntelligenceAlertsByIdSnooze",
        "summary": "Snooze competitor alert",
        "tags": [
          "competitive-intelligence"
        ],
        "description": "Snooze a competitive-intelligence alert.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "days"
                ],
                "properties": {
                  "days": {
                    "anyOf": [
                      {
                        "type": "number",
                        "enum": [
                          1
                        ]
                      },
                      {
                        "type": "number",
                        "enum": [
                          7
                        ]
                      },
                      {
                        "type": "number",
                        "enum": [
                          30
                        ]
                      }
                    ]
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "created_at",
                    "id",
                    "title"
                  ],
                  "properties": {
                    "alert_type": {
                      "type": "string"
                    },
                    "competitor_ad_id": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "competitor_name": {
                      "type": "string"
                    },
                    "created_at": {
                      "type": "string"
                    },
                    "id": {
                      "type": "string"
                    },
                    "is_read": {
                      "type": "boolean"
                    },
                    "message": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "metadata": {
                      "$comment": "json-value"
                    },
                    "severity": {
                      "type": "string"
                    },
                    "snoozed_until": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "team_id": {
                      "type": "string"
                    },
                    "title": {
                      "type": "string"
                    },
                    "watchlist_id": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/competitive-intelligence/alerts/read-all": {
      "patch": {
        "operationId": "patchApiV1CompetitiveIntelligenceAlertsReadAll",
        "summary": "Mark all competitor alerts as read",
        "tags": [
          "competitive-intelligence"
        ],
        "description": "Mark all competitive-intelligence alerts as read for the current team scope.",
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "updated"
                  ],
                  "properties": {
                    "updated": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/competitive-intelligence/alerts/backfill-notifications": {
      "post": {
        "operationId": "postApiV1CompetitiveIntelligenceAlertsBackfillNotifications",
        "summary": "Backfill competitor alert notifications",
        "tags": [
          "competitive-intelligence"
        ],
        "description": "Backfill notifications for existing competitive-intelligence alerts.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "properties": {
                  "team_id": {
                    "format": "uuid",
                    "type": "string"
                  },
                  "limit": {
                    "minimum": 1,
                    "maximum": 10000,
                    "type": "number"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "alertsScanned",
                    "alertsTouched",
                    "notificationsCreated"
                  ],
                  "properties": {
                    "alertsScanned": {
                      "type": "number"
                    },
                    "alertsTouched": {
                      "type": "number"
                    },
                    "notificationsCreated": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/competitive-intelligence/reports/latest": {
      "get": {
        "operationId": "getApiV1CompetitiveIntelligenceReportsLatest",
        "summary": "Get latest competitive report",
        "tags": [
          "competitive-intelligence"
        ],
        "description": "Return the latest ready competitive-intelligence report for the current team scope.",
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "content",
                    "dimension",
                    "id",
                    "period_end",
                    "period_start",
                    "period_type",
                    "team_id"
                  ],
                  "properties": {
                    "content": {
                      "$comment": "json-value"
                    },
                    "dimension": {
                      "type": "string"
                    },
                    "generated_at": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "id": {
                      "type": "string"
                    },
                    "period_end": {
                      "type": "string"
                    },
                    "period_start": {
                      "type": "string"
                    },
                    "period_type": {
                      "type": "string"
                    },
                    "status": {
                      "type": "string"
                    },
                    "status_reason": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "team_id": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/competitive-intelligence/reports/quota": {
      "get": {
        "operationId": "getApiV1CompetitiveIntelligenceReportsQuota",
        "summary": "Get competitive report daily quota",
        "tags": [
          "competitive-intelligence"
        ],
        "description": "Return today's manual report-generation usage for the current team scope (used/limit/remaining).",
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "used",
                    "limit",
                    "remaining",
                    "resets_at"
                  ],
                  "properties": {
                    "used": {
                      "type": "integer"
                    },
                    "limit": {
                      "type": "integer"
                    },
                    "remaining": {
                      "type": "integer"
                    },
                    "resets_at": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/competitive-intelligence/correlation": {
      "get": {
        "operationId": "getApiV1CompetitiveIntelligenceCorrelation",
        "summary": "Competitor activity vs own performance correlation",
        "tags": [
          "competitive-intelligence"
        ],
        "description": "Correlate the team’s own daily performance with competitor activity (own-account moat).",
        "parameters": [
          {
            "schema": {
              "maximum": 90,
              "minimum": 7,
              "type": "integer"
            },
            "in": "query",
            "name": "days",
            "required": false
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "insight",
                    "timeline"
                  ],
                  "properties": {
                    "insight": {
                      "anyOf": [
                        {
                          "type": "null"
                        },
                        {
                          "type": "object",
                          "required": [
                            "cpm_correlation",
                            "sample_days"
                          ],
                          "properties": {
                            "cpm_correlation": {
                              "anyOf": [
                                {
                                  "type": "number"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "sample_days": {
                              "type": "number"
                            }
                          }
                        }
                      ]
                    },
                    "timeline": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "competitor_active_ads",
                          "competitor_new_ads",
                          "competitor_spend_est",
                          "date",
                          "my_cpm",
                          "my_purchases",
                          "my_spend"
                        ],
                        "properties": {
                          "competitor_active_ads": {
                            "type": "number"
                          },
                          "competitor_new_ads": {
                            "type": "number"
                          },
                          "competitor_spend_est": {
                            "anyOf": [
                              {
                                "type": "number"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "date": {
                            "type": "string"
                          },
                          "my_cpm": {
                            "anyOf": [
                              {
                                "type": "number"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "my_purchases": {
                            "anyOf": [
                              {
                                "type": "number"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "my_spend": {
                            "anyOf": [
                              {
                                "type": "number"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/competitive-intelligence/velocity": {
      "get": {
        "operationId": "getApiV1CompetitiveIntelligenceVelocity",
        "summary": "Competitor creative velocity",
        "tags": [
          "competitive-intelligence"
        ],
        "description": "Creative velocity: which tracked competitors are ramping new ads.",
        "parameters": [
          {
            "schema": {
              "maximum": 60,
              "minimum": 6,
              "type": "integer"
            },
            "in": "query",
            "name": "days",
            "required": false
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "competitors"
                  ],
                  "properties": {
                    "competitors": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "name",
                          "prior",
                          "recent",
                          "velocity_pct",
                          "watchlist_id"
                        ],
                        "properties": {
                          "name": {
                            "type": "string"
                          },
                          "prior": {
                            "type": "number"
                          },
                          "recent": {
                            "type": "number"
                          },
                          "velocity_pct": {
                            "anyOf": [
                              {
                                "type": "number"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "watchlist_id": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/competitive-intelligence/reports/generate": {
      "post": {
        "operationId": "postApiV1CompetitiveIntelligenceReportsGenerate",
        "summary": "Generate competitive report",
        "tags": [
          "competitive-intelligence"
        ],
        "description": "Queue a weekly competitive-intelligence report generation job.",
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "period_end",
                    "status",
                    "team_id"
                  ],
                  "properties": {
                    "period_end": {
                      "type": "string"
                    },
                    "status": {
                      "type": "string",
                      "enum": [
                        "queued"
                      ]
                    },
                    "team_id": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "Too many requests - rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/competitive-intelligence/search-page": {
      "get": {
        "operationId": "getApiV1CompetitiveIntelligenceSearchPage",
        "summary": "Search competitor Meta pages",
        "tags": [
          "competitive-intelligence"
        ],
        "description": "Search Meta Ad Library pages to add a trackable competitor. Accepts a page name, a numeric Meta page ID, or a facebook.com URL carrying the page ID; countries scope which ad-delivery markets are searched. Name queries run against Meta full-text search over ad copy — the only page lookup the Ad Library exposes — and results are ranked by how closely the advertiser name matches. An id that resolves to something other than an advertiser Page returns an empty list with reason=not_an_advertiser_page.",
        "parameters": [
          {
            "schema": {
              "type": "array",
              "items": {
                "type": "string"
              }
            },
            "in": "query",
            "name": "countries",
            "required": false
          },
          {
            "schema": {
              "minLength": 1,
              "maxLength": 300,
              "type": "string"
            },
            "in": "query",
            "name": "q",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "items"
                  ],
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "ad_count",
                          "page_id",
                          "page_name",
                          "source"
                        ],
                        "properties": {
                          "ad_count": {
                            "type": "number"
                          },
                          "page_id": {
                            "type": "string"
                          },
                          "page_name": {
                            "type": "string"
                          },
                          "source": {
                            "type": "string"
                          }
                        }
                      }
                    },
                    "reason": {
                      "type": "string",
                      "enum": [
                        "not_an_advertiser_page"
                      ]
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/creative-ai-register": {
      "get": {
        "operationId": "creativeAiRegisterList",
        "summary": "List the AI-creatives register",
        "tags": [
          "creative-hub",
          "ai-register"
        ],
        "description": "Lists the workspace AI-creatives register required by EU AI Act art. 50(2) traceability: Creative Hub library assets (generated, uploaded, imported) with their AI classification and provenance evidence, plus the caller's own completed AI generation jobs, from the chat and the legacy hub endpoints (media transforms — resize, background removal — and Creatomate composite renders of user footage are not generations and are excluded). `is_ai_generated` is tri-state — NULL means unknown, never human-made. Use the /export sibling for the CSV attachment.",
        "parameters": [
          {
            "schema": {
              "minimum": 1,
              "maximum": 100,
              "default": 1,
              "type": "integer"
            },
            "in": "query",
            "name": "page",
            "required": false,
            "description": "1-based page index."
          },
          {
            "schema": {
              "minimum": 1,
              "maximum": 200,
              "default": 50,
              "type": "integer"
            },
            "in": "query",
            "name": "page_size",
            "required": false,
            "description": "Rows per page."
          },
          {
            "schema": {
              "default": "all",
              "anyOf": [
                {
                  "type": "string",
                  "enum": [
                    "all"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "ai"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "unknown"
                  ]
                }
              ]
            },
            "in": "query",
            "name": "classified",
            "required": false,
            "description": "Classification slice: `ai` = classified as AI-generated, `unknown` = still unclassified assets (chat jobs are excluded, they are AI by construction), `all` = everything."
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "items",
                    "total",
                    "page",
                    "page_size"
                  ],
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "additionalProperties": false,
                        "type": "object",
                        "required": [
                          "id",
                          "entry_type",
                          "kind",
                          "name",
                          "prompt",
                          "url",
                          "result_urls",
                          "provider",
                          "source",
                          "is_ai_generated",
                          "ai_provenance",
                          "generation_id",
                          "created_at"
                        ],
                        "properties": {
                          "id": {
                            "description": "Row id: creative_asset.id or creative_job.id.",
                            "type": "string"
                          },
                          "entry_type": {
                            "description": "Origin table: `asset` = Creative Hub library asset, `generation_job` = completed AI generation job (chat or legacy hub).",
                            "anyOf": [
                              {
                                "type": "string",
                                "enum": [
                                  "asset"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "generation_job"
                                ]
                              }
                            ]
                          },
                          "kind": {
                            "description": "Media kind (asset.kind) or generation type (job.type).",
                            "type": "string"
                          },
                          "name": {
                            "description": "Asset name; always null for generation jobs.",
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "prompt": {
                            "description": "Generation prompt of a job, truncated to 300 characters. Null for assets.",
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "url": {
                            "description": "Primary media URL.",
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "result_urls": {
                            "description": "Every media URL produced by the row.",
                            "type": "array",
                            "items": {
                              "type": "string"
                            }
                          },
                          "provider": {
                            "description": "AI provider that produced the media.",
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "source": {
                            "description": "Asset source (`generated` | `uploaded` | `imported`), or the job origin: `chat` (AI chat) | `creative_hub` (legacy hub generate endpoints).",
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "is_ai_generated": {
                            "description": "AI Act classification. NULL = unknown (no marker found); it never means \"human-made\".",
                            "anyOf": [
                              {
                                "type": "boolean"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "ai_provenance": {
                            "description": "JSON object with nested arrays and objects.",
                            "type": "object",
                            "additionalProperties": {
                              "$comment": "json-value",
                              "description": "Arbitrary JSON value with nested arrays and objects."
                            }
                          },
                          "generation_id": {
                            "description": "Wevion generation this asset came from. Non-null rows are immutable AI facts.",
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "created_at": {
                            "format": "date-time",
                            "description": "Creation timestamp (ISO 8601).",
                            "type": "string"
                          }
                        }
                      }
                    },
                    "total": {
                      "description": "Total rows matching the filter across both sources.",
                      "type": "integer"
                    },
                    "page": {
                      "description": "Requested page (1-based).",
                      "type": "integer"
                    },
                    "page_size": {
                      "description": "Requested page size.",
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "integer"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "request_id": {
                      "type": "string"
                    },
                    "details": {
                      "type": "object",
                      "additionalProperties": {}
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "integer"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "request_id": {
                      "type": "string"
                    },
                    "details": {
                      "type": "object",
                      "additionalProperties": {}
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "integer"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "request_id": {
                      "type": "string"
                    },
                    "details": {
                      "type": "object",
                      "additionalProperties": {}
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/creative-ai-register/export": {
      "get": {
        "operationId": "creativeAiRegisterExport",
        "summary": "Export the AI-creatives register as CSV",
        "tags": [
          "creative-hub",
          "ai-register"
        ],
        "description": "Same rows as the register list (newest first, up to the newest 5000), as a `text/csv` attachment. Formula-leading cells are prefixed to neutralise spreadsheet formula injection.",
        "parameters": [
          {
            "schema": {
              "default": "all",
              "anyOf": [
                {
                  "type": "string",
                  "enum": [
                    "all"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "ai"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "unknown"
                  ]
                }
              ]
            },
            "in": "query",
            "name": "classified",
            "required": false,
            "description": "Classification slice: `ai` = classified as AI-generated, `unknown` = still unclassified assets (chat jobs are excluded, they are AI by construction), `all` = everything."
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "CSV file content",
            "content": {
              "application/json": {
                "schema": {
                  "description": "CSV file content",
                  "type": "string"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "integer"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "request_id": {
                      "type": "string"
                    },
                    "details": {
                      "type": "object",
                      "additionalProperties": {}
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "integer"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "request_id": {
                      "type": "string"
                    },
                    "details": {
                      "type": "object",
                      "additionalProperties": {}
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "integer"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "request_id": {
                      "type": "string"
                    },
                    "details": {
                      "type": "object",
                      "additionalProperties": {}
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/creative-ai-register/assets/{assetId}": {
      "patch": {
        "operationId": "creativeAiRegisterReclassifyAsset",
        "summary": "Reclassify an uploaded asset in the AI register",
        "tags": [
          "creative-hub",
          "ai-register"
        ],
        "description": "Manually records whether an uploaded or imported asset is AI-generated, for the cases automatic detection cannot decide (an unmarked upload is stored as unknown). Only rows without a generation_id can be reclassified: an asset produced by a Wevion generation is a recorded fact and answers 409. The change is stamped in `ai_provenance.manual_override`.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "is_ai_generated"
                ],
                "properties": {
                  "is_ai_generated": {
                    "description": "True when the media is AI-generated, false when it is not.",
                    "type": "boolean"
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "assetId",
            "required": true,
            "description": "creative_asset.id to reclassify."
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "id",
                    "is_ai_generated",
                    "ai_provenance"
                  ],
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "is_ai_generated": {
                      "type": "boolean"
                    },
                    "ai_provenance": {
                      "description": "JSON object with nested arrays and objects.",
                      "type": "object",
                      "additionalProperties": {
                        "$comment": "json-value",
                        "description": "Arbitrary JSON value with nested arrays and objects."
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "integer"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "request_id": {
                      "type": "string"
                    },
                    "details": {
                      "type": "object",
                      "additionalProperties": {}
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "integer"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "request_id": {
                      "type": "string"
                    },
                    "details": {
                      "type": "object",
                      "additionalProperties": {}
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "integer"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "request_id": {
                      "type": "string"
                    },
                    "details": {
                      "type": "object",
                      "additionalProperties": {}
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "Conflict - resource state prevents the operation",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "integer"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "request_id": {
                      "type": "string"
                    },
                    "details": {
                      "type": "object",
                      "additionalProperties": {}
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/creative-analytics/gallery": {
      "get": {
        "operationId": "getCreativeAnalyticsGallery",
        "summary": "Creative analytics gallery",
        "tags": [
          "creative-analytics"
        ],
        "description": "Per-creative aggregated performance for the date range, with signed thumbnail proxies.",
        "parameters": [
          {
            "schema": {
              "format": "date",
              "type": "string"
            },
            "in": "query",
            "name": "from",
            "required": true
          },
          {
            "schema": {
              "format": "date",
              "type": "string"
            },
            "in": "query",
            "name": "to",
            "required": true
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "sort_by",
            "required": false
          },
          {
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "enum": [
                    "asc"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "desc"
                  ]
                }
              ]
            },
            "in": "query",
            "name": "sort_order",
            "required": false
          },
          {
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "array",
                  "items": {
                    "type": "string"
                  }
                }
              ]
            },
            "in": "query",
            "name": "ad_account_ids",
            "required": false
          },
          {
            "schema": {
              "minimum": 1,
              "maximum": 48,
              "default": 24,
              "type": "integer"
            },
            "in": "query",
            "name": "limit",
            "required": false
          },
          {
            "schema": {
              "minimum": 0,
              "default": 0,
              "type": "integer"
            },
            "in": "query",
            "name": "offset",
            "required": false
          }
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "items",
                    "total"
                  ],
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "sheet_id",
                          "ad_id",
                          "ad_name",
                          "campaign_id",
                          "campaign_name",
                          "adset_id",
                          "adset_name",
                          "ad_account_id",
                          "ad_account_name",
                          "ad_status",
                          "platform",
                          "account_currency",
                          "creative_thumbnail_url",
                          "creative_thumbnail_proxy",
                          "creative_thumbnail_proxy_large",
                          "first_seen",
                          "last_seen",
                          "spend",
                          "impressions",
                          "clicks",
                          "reach",
                          "purchases",
                          "purchase_value",
                          "leads",
                          "add_to_cart",
                          "conversions",
                          "ctr",
                          "cpc",
                          "cpm",
                          "roas",
                          "cpa",
                          "frequency",
                          "format"
                        ],
                        "properties": {
                          "sheet_id": {
                            "type": "string"
                          },
                          "ad_id": {
                            "type": "string"
                          },
                          "ad_name": {
                            "type": "string"
                          },
                          "campaign_id": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "campaign_name": {
                            "type": "string"
                          },
                          "adset_id": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "adset_name": {
                            "type": "string"
                          },
                          "ad_account_id": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "ad_account_name": {
                            "type": "string"
                          },
                          "ad_status": {
                            "type": "string"
                          },
                          "platform": {
                            "type": "string"
                          },
                          "account_currency": {
                            "type": "string"
                          },
                          "creative_thumbnail_url": {
                            "type": "string"
                          },
                          "creative_thumbnail_proxy": {
                            "type": "string"
                          },
                          "creative_thumbnail_proxy_large": {
                            "type": "string"
                          },
                          "first_seen": {
                            "type": "string"
                          },
                          "last_seen": {
                            "type": "string"
                          },
                          "spend": {
                            "type": "number"
                          },
                          "impressions": {
                            "type": "number"
                          },
                          "clicks": {
                            "type": "number"
                          },
                          "reach": {
                            "type": "number"
                          },
                          "purchases": {
                            "type": "number"
                          },
                          "purchase_value": {
                            "type": "number"
                          },
                          "leads": {
                            "type": "number"
                          },
                          "add_to_cart": {
                            "type": "number"
                          },
                          "conversions": {
                            "type": "number"
                          },
                          "ctr": {
                            "type": "number"
                          },
                          "cpc": {
                            "type": "number"
                          },
                          "cpm": {
                            "type": "number"
                          },
                          "roas": {
                            "type": "number"
                          },
                          "cpa": {
                            "type": "number"
                          },
                          "frequency": {
                            "type": "number"
                          },
                          "format": {
                            "type": "string"
                          }
                        }
                      }
                    },
                    "total": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/creative-analytics/fatigue": {
      "get": {
        "operationId": "getCreativeFatigueList",
        "summary": "Creative fatigue scores list",
        "tags": [
          "creative-analytics"
        ],
        "description": "Returns paginated creative fatigue scores for accessible ad accounts, including score drivers, thumbnail proxy and sorting filters.",
        "parameters": [
          {
            "schema": {
              "minimum": 0,
              "maximum": 100,
              "default": 0,
              "type": "integer"
            },
            "in": "query",
            "name": "min_score",
            "required": false
          },
          {
            "schema": {
              "type": "array",
              "items": {
                "type": "string"
              }
            },
            "in": "query",
            "name": "ad_account_ids",
            "required": false
          },
          {
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "enum": [
                    "meta"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "google"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "tiktok"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "taboola"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "snapchat"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "outbrain"
                  ]
                }
              ]
            },
            "in": "query",
            "name": "platform",
            "required": false
          },
          {
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "enum": [
                    "score"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "avg_frequency"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "avg_ctr"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "avg_cpm"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "impressions"
                  ]
                }
              ]
            },
            "in": "query",
            "name": "sort_by",
            "required": false
          },
          {
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "enum": [
                    "asc"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "desc"
                  ]
                }
              ]
            },
            "in": "query",
            "name": "sort_order",
            "required": false
          },
          {
            "schema": {
              "minimum": 1,
              "maximum": 100,
              "default": 50,
              "type": "integer"
            },
            "in": "query",
            "name": "limit",
            "required": false
          },
          {
            "schema": {
              "minimum": 0,
              "default": 0,
              "type": "integer"
            },
            "in": "query",
            "name": "offset",
            "required": false
          }
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "items",
                    "total"
                  ],
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "ad_id",
                          "ad_name",
                          "ad_status",
                          "sheet_id",
                          "campaign_id",
                          "campaign_name",
                          "ad_account_id",
                          "platform",
                          "score",
                          "slope_ctr",
                          "avg_frequency",
                          "avg_ctr",
                          "avg_cpm",
                          "avg_cpc",
                          "baseline_ctr",
                          "baseline_cpm",
                          "baseline_cpc",
                          "impressions",
                          "ctr_series",
                          "window_days",
                          "computed_at",
                          "alerted_at",
                          "creative_thumbnail_url",
                          "creative_thumbnail_proxy",
                          "creative_thumbnail_proxy_large"
                        ],
                        "properties": {
                          "ad_id": {
                            "type": "string"
                          },
                          "ad_name": {
                            "type": "string"
                          },
                          "ad_status": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "sheet_id": {
                            "type": "string"
                          },
                          "campaign_id": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "campaign_name": {
                            "type": "string"
                          },
                          "ad_account_id": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "platform": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "score": {
                            "type": "integer"
                          },
                          "slope_ctr": {
                            "anyOf": [
                              {
                                "type": "number"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "avg_frequency": {
                            "anyOf": [
                              {
                                "type": "number"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "avg_ctr": {
                            "anyOf": [
                              {
                                "type": "number"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "avg_cpm": {
                            "anyOf": [
                              {
                                "type": "number"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "avg_cpc": {
                            "anyOf": [
                              {
                                "type": "number"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "baseline_ctr": {
                            "anyOf": [
                              {
                                "type": "number"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "baseline_cpm": {
                            "anyOf": [
                              {
                                "type": "number"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "baseline_cpc": {
                            "anyOf": [
                              {
                                "type": "number"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "impressions": {
                            "anyOf": [
                              {
                                "type": "number"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "ctr_series": {
                            "type": "array",
                            "items": {
                              "type": "number"
                            }
                          },
                          "window_days": {
                            "type": "integer"
                          },
                          "computed_at": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "alerted_at": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "creative_thumbnail_url": {
                            "type": "string"
                          },
                          "creative_thumbnail_proxy": {
                            "type": "string"
                          },
                          "creative_thumbnail_proxy_large": {
                            "type": "string"
                          }
                        }
                      }
                    },
                    "total": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/creative-analytics/fatigue/alert-config": {
      "get": {
        "operationId": "getCreativeFatigueAlertConfig",
        "summary": "Get the per-user Ad Fatigue alert config",
        "tags": [
          "creative-analytics"
        ],
        "description": "Returns the email-alert configuration (threshold, recipient, frequency) for the current user.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "email",
                    "email_enabled",
                    "frequency",
                    "threshold"
                  ],
                  "properties": {
                    "email": {
                      "type": "string"
                    },
                    "email_enabled": {
                      "type": "boolean"
                    },
                    "frequency": {
                      "anyOf": [
                        {
                          "type": "string",
                          "enum": [
                            "immediate"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "daily"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "weekly"
                          ]
                        }
                      ]
                    },
                    "threshold": {
                      "minimum": 1,
                      "maximum": 100,
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      },
      "put": {
        "operationId": "updateCreativeFatigueAlertConfig",
        "summary": "Update the per-user Ad Fatigue alert config",
        "tags": [
          "creative-analytics"
        ],
        "description": "Persists the email-alert configuration (threshold 1–100, recipient, frequency) for the current user.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "email",
                  "email_enabled",
                  "frequency",
                  "threshold"
                ],
                "properties": {
                  "email": {
                    "type": "string"
                  },
                  "email_enabled": {
                    "type": "boolean"
                  },
                  "frequency": {
                    "anyOf": [
                      {
                        "type": "string",
                        "enum": [
                          "immediate"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "daily"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "weekly"
                        ]
                      }
                    ]
                  },
                  "threshold": {
                    "minimum": 1,
                    "maximum": 100,
                    "type": "integer"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "email",
                    "email_enabled",
                    "frequency",
                    "threshold"
                  ],
                  "properties": {
                    "email": {
                      "type": "string"
                    },
                    "email_enabled": {
                      "type": "boolean"
                    },
                    "frequency": {
                      "anyOf": [
                        {
                          "type": "string",
                          "enum": [
                            "immediate"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "daily"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "weekly"
                          ]
                        }
                      ]
                    },
                    "threshold": {
                      "minimum": 1,
                      "maximum": 100,
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/creative-analytics/fatigue/patterns": {
      "get": {
        "operationId": "getCreativeFatiguePatterns",
        "summary": "Historical creative fatigue patterns",
        "tags": [
          "creative-analytics"
        ],
        "description": "Aggregates historical fatigue alerts into account-level and percentile timing metrics for accessible ad accounts.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "avg_days_to_fatigue",
                    "p50_days_to_fatigue",
                    "p90_days_to_fatigue",
                    "total_creatives_alerted",
                    "by_account"
                  ],
                  "properties": {
                    "avg_days_to_fatigue": {
                      "type": "number"
                    },
                    "p50_days_to_fatigue": {
                      "type": "number"
                    },
                    "p90_days_to_fatigue": {
                      "type": "number"
                    },
                    "total_creatives_alerted": {
                      "type": "number"
                    },
                    "by_account": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "ad_account_id",
                          "avg_days",
                          "count"
                        ],
                        "properties": {
                          "ad_account_id": {
                            "type": "string"
                          },
                          "avg_days": {
                            "type": "number"
                          },
                          "count": {
                            "type": "number"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/creative-analytics/{adId}/fatigue-history": {
      "get": {
        "operationId": "getCreativeFatigueHistory",
        "summary": "Fatigue score history for one ad",
        "tags": [
          "creative-analytics"
        ],
        "description": "Returns recent fatigue score snapshots for one ad, optionally scoped to a specific ad account or accessible team member session.",
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "ad_account_id",
            "required": false
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "sheet_id",
            "required": false
          },
          {
            "schema": {
              "minimum": 1,
              "maximum": 200,
              "default": 30,
              "type": "integer"
            },
            "in": "query",
            "name": "limit",
            "required": false
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "path",
            "name": "adId",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "items"
                  ],
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "id",
                          "ad_id",
                          "ad_account_id",
                          "score",
                          "slope_ctr",
                          "avg_frequency",
                          "avg_ctr",
                          "window_days",
                          "computed_at",
                          "alerted_at"
                        ],
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "ad_id": {
                            "type": "string"
                          },
                          "ad_account_id": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "score": {
                            "type": "integer"
                          },
                          "slope_ctr": {
                            "anyOf": [
                              {
                                "type": "number"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "avg_frequency": {
                            "anyOf": [
                              {
                                "type": "number"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "avg_ctr": {
                            "anyOf": [
                              {
                                "type": "number"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "window_days": {
                            "type": "integer"
                          },
                          "computed_at": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "alerted_at": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/creative-analytics/{adId}/pause": {
      "post": {
        "operationId": "pauseCreativeAd",
        "summary": "Pause a single ad (fatigue tab action)",
        "tags": [
          "creative-analytics"
        ],
        "description": "Dispatches a Meta status toggle to PAUSED for the given ad.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "ad_account_id"
                ],
                "properties": {
                  "ad_account_id": {
                    "type": "string"
                  },
                  "sheet_id": {
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "in": "path",
            "name": "adId",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "ok",
                    "worker_run_id"
                  ],
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    },
                    "worker_run_id": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "message"
                  ],
                  "properties": {
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "message"
                  ],
                  "properties": {
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/creative-analytics/{adId}/resume": {
      "post": {
        "operationId": "resumeCreativeAd",
        "summary": "Resume a single ad (fatigue tab action)",
        "tags": [
          "creative-analytics"
        ],
        "description": "Dispatches a Meta status toggle to ACTIVE for the given ad.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "ad_account_id"
                ],
                "properties": {
                  "ad_account_id": {
                    "type": "string"
                  },
                  "sheet_id": {
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "in": "path",
            "name": "adId",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "ok",
                    "worker_run_id"
                  ],
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    },
                    "worker_run_id": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "message"
                  ],
                  "properties": {
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "message"
                  ],
                  "properties": {
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/creative-hub/avatars": {
      "get": {
        "operationId": "getApiV1CreativeHubAvatars",
        "summary": "List Creative Hub avatars",
        "tags": [
          "creative-hub"
        ],
        "description": "Returns library and user avatars available for Creative Hub UGC generation flows. The estimated_credits field is the text-to-avatar cost only, kept for backward compatibility: price a specific mode with GET /creative-hub/avatars/estimate.",
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "scenario",
            "required": false
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "gender",
            "required": false
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "age_bracket",
            "required": false
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "q",
            "required": false
          },
          {
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "enum": [
                    "library"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "mine"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "all"
                  ]
                }
              ]
            },
            "in": "query",
            "name": "scope",
            "required": false
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "items",
                    "estimated_credits"
                  ],
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "additionalProperties": false,
                        "type": "object",
                        "required": [
                          "id",
                          "team_id",
                          "created_by",
                          "name",
                          "gender",
                          "age_bracket",
                          "scenario",
                          "image_url",
                          "thumbnail_url",
                          "preview_video_url",
                          "prompt",
                          "voice_id",
                          "provider",
                          "provider_avatar_ref",
                          "is_library",
                          "status",
                          "tags",
                          "metadata",
                          "created_at",
                          "updated_at",
                          "deleted_at"
                        ],
                        "properties": {
                          "id": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "team_id": {
                            "anyOf": [
                              {
                                "format": "uuid",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "created_by": {
                            "anyOf": [
                              {
                                "format": "uuid",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "name": {
                            "type": "string"
                          },
                          "gender": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "age_bracket": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "scenario": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "image_url": {
                            "type": "string"
                          },
                          "thumbnail_url": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "preview_video_url": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "prompt": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "voice_id": {
                            "anyOf": [
                              {
                                "format": "uuid",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "provider": {
                            "type": "string"
                          },
                          "provider_avatar_ref": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "is_library": {
                            "type": "boolean"
                          },
                          "status": {
                            "type": "string"
                          },
                          "tags": {
                            "type": "array",
                            "items": {
                              "type": "string"
                            }
                          },
                          "metadata": {
                            "type": "object",
                            "additionalProperties": {
                              "$comment": "json-value"
                            }
                          },
                          "created_at": {
                            "format": "date-time",
                            "type": "string"
                          },
                          "updated_at": {
                            "format": "date-time",
                            "type": "string"
                          },
                          "deleted_at": {
                            "anyOf": [
                              {
                                "format": "date-time",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          }
                        }
                      }
                    },
                    "estimated_credits": {
                      "minimum": 0,
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "postApiV1CreativeHubAvatars",
        "summary": "Create Creative Hub avatar",
        "tags": [
          "creative-hub"
        ],
        "description": "Queues a custom text-to-avatar or photo-to-avatar generation job.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "mode",
                  "name"
                ],
                "properties": {
                  "mode": {
                    "anyOf": [
                      {
                        "type": "string",
                        "enum": [
                          "text"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "photo"
                        ]
                      }
                    ]
                  },
                  "name": {
                    "minLength": 1,
                    "maxLength": 120,
                    "type": "string"
                  },
                  "prompt": {
                    "maxLength": 2000,
                    "type": "string"
                  },
                  "template_avatar_id": {
                    "type": "string"
                  },
                  "source_image_url": {
                    "type": "string"
                  },
                  "gender": {
                    "maxLength": 20,
                    "type": "string"
                  },
                  "age_bracket": {
                    "maxLength": 20,
                    "type": "string"
                  },
                  "scenario": {
                    "maxLength": 40,
                    "type": "string"
                  },
                  "voice_id": {
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "202": {
            "description": "Accepted - processing asynchronously",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "avatar_id",
                    "generation_id",
                    "status",
                    "estimated_credits",
                    "polling_interval_ms"
                  ],
                  "properties": {
                    "avatar_id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "generation_id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "status": {
                      "type": "string"
                    },
                    "estimated_credits": {
                      "minimum": 0,
                      "type": "integer"
                    },
                    "polling_interval_ms": {
                      "minimum": 1,
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "402": {
            "description": "Response 402",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "Too many requests - rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "Service unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/creative-hub/avatars/estimate": {
      "get": {
        "operationId": "creativeHubEstimateAvatar",
        "summary": "Estimate avatar creation credits",
        "tags": [
          "creative-hub",
          "creative-generation"
        ],
        "description": "Returns the deterministic credit hold estimate for creating a custom avatar in the requested mode. text prices the photorealistic still generation; photo prices the re-host of the uploaded still. It is the same amount POST /creative-hub/avatars holds and the generation worker settles.",
        "parameters": [
          {
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "enum": [
                    "text"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "photo"
                  ]
                }
              ]
            },
            "in": "query",
            "name": "mode",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "mode",
                    "estimated_credits"
                  ],
                  "properties": {
                    "mode": {
                      "anyOf": [
                        {
                          "type": "string",
                          "enum": [
                            "text"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "photo"
                          ]
                        }
                      ]
                    },
                    "estimated_credits": {
                      "minimum": 0,
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/creative-hub/avatars/{id}": {
      "patch": {
        "operationId": "patchApiV1CreativeHubAvatarsById",
        "summary": "Rename Creative Hub avatar",
        "tags": [
          "creative-hub"
        ],
        "description": "Renames a custom avatar owned by the authenticated user. Library templates cannot be renamed.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "name"
                ],
                "properties": {
                  "name": {
                    "minLength": 1,
                    "maxLength": 120,
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "id",
                    "team_id",
                    "created_by",
                    "name",
                    "gender",
                    "age_bracket",
                    "scenario",
                    "image_url",
                    "thumbnail_url",
                    "preview_video_url",
                    "prompt",
                    "voice_id",
                    "provider",
                    "provider_avatar_ref",
                    "is_library",
                    "status",
                    "tags",
                    "metadata",
                    "created_at",
                    "updated_at",
                    "deleted_at"
                  ],
                  "properties": {
                    "id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "team_id": {
                      "anyOf": [
                        {
                          "format": "uuid",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "created_by": {
                      "anyOf": [
                        {
                          "format": "uuid",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "name": {
                      "type": "string"
                    },
                    "gender": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "age_bracket": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "scenario": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "image_url": {
                      "type": "string"
                    },
                    "thumbnail_url": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "preview_video_url": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "prompt": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "voice_id": {
                      "anyOf": [
                        {
                          "format": "uuid",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "provider": {
                      "type": "string"
                    },
                    "provider_avatar_ref": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "is_library": {
                      "type": "boolean"
                    },
                    "status": {
                      "type": "string"
                    },
                    "tags": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "metadata": {
                      "type": "object",
                      "additionalProperties": {
                        "$comment": "json-value"
                      }
                    },
                    "created_at": {
                      "format": "date-time",
                      "type": "string"
                    },
                    "updated_at": {
                      "format": "date-time",
                      "type": "string"
                    },
                    "deleted_at": {
                      "anyOf": [
                        {
                          "format": "date-time",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      },
      "delete": {
        "operationId": "deleteApiV1CreativeHubAvatarsById",
        "summary": "Delete Creative Hub avatar",
        "tags": [
          "creative-hub"
        ],
        "description": "Soft-deletes a custom avatar owned by the authenticated user.",
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "204": {
            "description": "No content"
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/creative-hub/brand-kits": {
      "get": {
        "operationId": "getApiV1CreativeHubBrandKits",
        "summary": "List Creative Hub brand kits",
        "tags": [
          "creative-hub"
        ],
        "description": "Returns brand kits of the active workspace scope team for Creative Hub generation flows.",
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "items"
                  ],
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "additionalProperties": false,
                        "type": "object",
                        "required": [
                          "id",
                          "team_id",
                          "created_by",
                          "name",
                          "website",
                          "logo_url",
                          "colors",
                          "fonts",
                          "tagline",
                          "description",
                          "tone",
                          "source",
                          "is_default",
                          "metadata",
                          "created_at",
                          "updated_at",
                          "deleted_at"
                        ],
                        "properties": {
                          "id": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "team_id": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "created_by": {
                            "anyOf": [
                              {
                                "format": "uuid",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "name": {
                            "type": "string"
                          },
                          "website": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "logo_url": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "colors": {
                            "type": "array",
                            "items": {
                              "type": "string"
                            }
                          },
                          "fonts": {
                            "type": "array",
                            "items": {
                              "type": "string"
                            }
                          },
                          "tagline": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "description": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "tone": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "source": {
                            "type": "string"
                          },
                          "is_default": {
                            "type": "boolean"
                          },
                          "metadata": {
                            "type": "object",
                            "additionalProperties": {
                              "$comment": "json-value"
                            }
                          },
                          "created_at": {
                            "format": "date-time",
                            "type": "string"
                          },
                          "updated_at": {
                            "format": "date-time",
                            "type": "string"
                          },
                          "deleted_at": {
                            "anyOf": [
                              {
                                "format": "date-time",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "postApiV1CreativeHubBrandKits",
        "summary": "Create Creative Hub brand kit",
        "tags": [
          "creative-hub"
        ],
        "description": "Creates a brand kit for the active workspace scope team.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "name"
                ],
                "properties": {
                  "name": {
                    "minLength": 1,
                    "maxLength": 200,
                    "type": "string"
                  },
                  "website": {
                    "anyOf": [
                      {
                        "maxLength": 500,
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "logo_url": {
                    "anyOf": [
                      {
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "colors": {
                    "type": "array",
                    "items": {
                      "maxLength": 16,
                      "type": "string"
                    }
                  },
                  "fonts": {
                    "type": "array",
                    "items": {
                      "maxLength": 60,
                      "type": "string"
                    }
                  },
                  "tagline": {
                    "anyOf": [
                      {
                        "maxLength": 300,
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "description": {
                    "anyOf": [
                      {
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "tone": {
                    "anyOf": [
                      {
                        "maxLength": 120,
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "source": {
                    "anyOf": [
                      {
                        "type": "string",
                        "enum": [
                          "url"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "manual"
                        ]
                      }
                    ]
                  },
                  "is_default": {
                    "type": "boolean"
                  },
                  "metadata": {
                    "additionalProperties": false,
                    "type": "object",
                    "properties": {
                      "business_model": {
                        "anyOf": [
                          {
                            "maxLength": 200,
                            "type": "string"
                          },
                          {
                            "type": "null"
                          }
                        ]
                      },
                      "industry": {
                        "anyOf": [
                          {
                            "maxLength": 200,
                            "type": "string"
                          },
                          {
                            "type": "null"
                          }
                        ]
                      },
                      "socials": {
                        "maxItems": 20,
                        "type": "array",
                        "items": {
                          "additionalProperties": false,
                          "type": "object",
                          "required": [
                            "platform",
                            "url"
                          ],
                          "properties": {
                            "platform": {
                              "maxLength": 40,
                              "type": "string"
                            },
                            "url": {
                              "maxLength": 500,
                              "type": "string"
                            }
                          }
                        }
                      },
                      "languages": {
                        "maxItems": 30,
                        "type": "array",
                        "items": {
                          "maxLength": 60,
                          "type": "string"
                        }
                      },
                      "visual_style": {
                        "anyOf": [
                          {
                            "maxLength": 2000,
                            "type": "string"
                          },
                          {
                            "type": "null"
                          }
                        ]
                      },
                      "keywords": {
                        "maxItems": 50,
                        "type": "array",
                        "items": {
                          "maxLength": 80,
                          "type": "string"
                        }
                      },
                      "words_to_avoid": {
                        "maxItems": 50,
                        "type": "array",
                        "items": {
                          "maxLength": 80,
                          "type": "string"
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "201": {
            "description": "Resource created",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "id",
                    "team_id",
                    "created_by",
                    "name",
                    "website",
                    "logo_url",
                    "colors",
                    "fonts",
                    "tagline",
                    "description",
                    "tone",
                    "source",
                    "is_default",
                    "metadata",
                    "created_at",
                    "updated_at",
                    "deleted_at"
                  ],
                  "properties": {
                    "id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "team_id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "created_by": {
                      "anyOf": [
                        {
                          "format": "uuid",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "name": {
                      "type": "string"
                    },
                    "website": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "logo_url": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "colors": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "fonts": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "tagline": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "description": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "tone": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "source": {
                      "type": "string"
                    },
                    "is_default": {
                      "type": "boolean"
                    },
                    "metadata": {
                      "type": "object",
                      "additionalProperties": {
                        "$comment": "json-value"
                      }
                    },
                    "created_at": {
                      "format": "date-time",
                      "type": "string"
                    },
                    "updated_at": {
                      "format": "date-time",
                      "type": "string"
                    },
                    "deleted_at": {
                      "anyOf": [
                        {
                          "format": "date-time",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/creative-hub/brand-kits/{id}": {
      "patch": {
        "operationId": "patchApiV1CreativeHubBrandKitsById",
        "summary": "Update Creative Hub brand kit",
        "tags": [
          "creative-hub"
        ],
        "description": "Updates a brand kit for the active workspace scope team.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "properties": {
                  "name": {
                    "minLength": 1,
                    "maxLength": 200,
                    "type": "string"
                  },
                  "website": {
                    "anyOf": [
                      {
                        "maxLength": 500,
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "logo_url": {
                    "anyOf": [
                      {
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "colors": {
                    "type": "array",
                    "items": {
                      "maxLength": 16,
                      "type": "string"
                    }
                  },
                  "fonts": {
                    "type": "array",
                    "items": {
                      "maxLength": 60,
                      "type": "string"
                    }
                  },
                  "tagline": {
                    "anyOf": [
                      {
                        "maxLength": 300,
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "description": {
                    "anyOf": [
                      {
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "tone": {
                    "anyOf": [
                      {
                        "maxLength": 120,
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "source": {
                    "anyOf": [
                      {
                        "type": "string",
                        "enum": [
                          "url"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "manual"
                        ]
                      }
                    ]
                  },
                  "is_default": {
                    "type": "boolean"
                  },
                  "metadata": {
                    "additionalProperties": false,
                    "type": "object",
                    "properties": {
                      "business_model": {
                        "anyOf": [
                          {
                            "maxLength": 200,
                            "type": "string"
                          },
                          {
                            "type": "null"
                          }
                        ]
                      },
                      "industry": {
                        "anyOf": [
                          {
                            "maxLength": 200,
                            "type": "string"
                          },
                          {
                            "type": "null"
                          }
                        ]
                      },
                      "socials": {
                        "maxItems": 20,
                        "type": "array",
                        "items": {
                          "additionalProperties": false,
                          "type": "object",
                          "required": [
                            "platform",
                            "url"
                          ],
                          "properties": {
                            "platform": {
                              "maxLength": 40,
                              "type": "string"
                            },
                            "url": {
                              "maxLength": 500,
                              "type": "string"
                            }
                          }
                        }
                      },
                      "languages": {
                        "maxItems": 30,
                        "type": "array",
                        "items": {
                          "maxLength": 60,
                          "type": "string"
                        }
                      },
                      "visual_style": {
                        "anyOf": [
                          {
                            "maxLength": 2000,
                            "type": "string"
                          },
                          {
                            "type": "null"
                          }
                        ]
                      },
                      "keywords": {
                        "maxItems": 50,
                        "type": "array",
                        "items": {
                          "maxLength": 80,
                          "type": "string"
                        }
                      },
                      "words_to_avoid": {
                        "maxItems": 50,
                        "type": "array",
                        "items": {
                          "maxLength": 80,
                          "type": "string"
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "id",
                    "team_id",
                    "created_by",
                    "name",
                    "website",
                    "logo_url",
                    "colors",
                    "fonts",
                    "tagline",
                    "description",
                    "tone",
                    "source",
                    "is_default",
                    "metadata",
                    "created_at",
                    "updated_at",
                    "deleted_at"
                  ],
                  "properties": {
                    "id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "team_id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "created_by": {
                      "anyOf": [
                        {
                          "format": "uuid",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "name": {
                      "type": "string"
                    },
                    "website": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "logo_url": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "colors": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "fonts": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "tagline": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "description": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "tone": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "source": {
                      "type": "string"
                    },
                    "is_default": {
                      "type": "boolean"
                    },
                    "metadata": {
                      "type": "object",
                      "additionalProperties": {
                        "$comment": "json-value"
                      }
                    },
                    "created_at": {
                      "format": "date-time",
                      "type": "string"
                    },
                    "updated_at": {
                      "format": "date-time",
                      "type": "string"
                    },
                    "deleted_at": {
                      "anyOf": [
                        {
                          "format": "date-time",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      },
      "delete": {
        "operationId": "deleteApiV1CreativeHubBrandKitsById",
        "summary": "Delete Creative Hub brand kit",
        "tags": [
          "creative-hub"
        ],
        "description": "Soft-deletes a brand kit for the active workspace scope team.",
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "204": {
            "description": "No content"
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/creative-hub/brand-kits/import": {
      "post": {
        "operationId": "postApiV1CreativeHubBrandKitsImport",
        "summary": "Preview brand kit import",
        "tags": [
          "creative-hub"
        ],
        "description": "Scrapes a website and returns a non-persisted brand kit preview for user confirmation.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "url"
                ],
                "properties": {
                  "url": {
                    "minLength": 4,
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "business_model",
                    "colors",
                    "description",
                    "fonts",
                    "industry",
                    "keywords",
                    "languages",
                    "logo_url",
                    "name",
                    "tagline",
                    "tone",
                    "visual_style",
                    "website"
                  ],
                  "properties": {
                    "business_model": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "colors": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "description": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "fonts": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "industry": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "keywords": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "languages": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "logo_url": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "name": {
                      "type": "string"
                    },
                    "tagline": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "tone": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "visual_style": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "website": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "422": {
            "description": "Unprocessable entity - semantic validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "Too many requests - rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "Service unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/creative-hub/explore": {
      "get": {
        "operationId": "creativeHubListExplore",
        "summary": "List curated Creative Hub inspiration items",
        "tags": [
          "creative-hub"
        ],
        "description": "Returns the curated Creative Hub explore catalog and category list, optionally filtered by category for recreate-this inspiration flows.",
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "category",
            "required": false
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "categories",
                    "items"
                  ],
                  "properties": {
                    "categories": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "key",
                          "label"
                        ],
                        "properties": {
                          "key": {
                            "type": "string"
                          },
                          "label": {
                            "type": "string"
                          }
                        }
                      }
                    },
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "id",
                          "title",
                          "description",
                          "thumbnail_url",
                          "category",
                          "target",
                          "prompt"
                        ],
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "title": {
                            "type": "string"
                          },
                          "description": {
                            "type": "string"
                          },
                          "thumbnail_url": {
                            "type": "string"
                          },
                          "category": {
                            "type": "string"
                          },
                          "target": {
                            "anyOf": [
                              {
                                "type": "string",
                                "enum": [
                                  "ugc"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "image"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "video"
                                ]
                              }
                            ]
                          },
                          "prompt": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/creative-hub/team-folders": {
      "get": {
        "operationId": "getApiV1CreativeHubTeamFolders",
        "summary": "List team member folders visible to current user based on role",
        "tags": [
          "creative-hub"
        ],
        "description": "Returns the cached Drive root for every visible team member. This is a read-only inventory: members without a provisioned root are returned with folder_id=null and status 'needs_provisioning'; the listing never creates Drive folders nor mutates app_settings.",
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "folders"
                  ],
                  "properties": {
                    "folders": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "session_id",
                          "user_id",
                          "name",
                          "email",
                          "role",
                          "folder_id",
                          "status"
                        ],
                        "properties": {
                          "session_id": {
                            "type": "string"
                          },
                          "user_id": {
                            "type": "string"
                          },
                          "name": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "email": {
                            "type": "string"
                          },
                          "role": {
                            "type": "string"
                          },
                          "folder_id": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "status": {
                            "anyOf": [
                              {
                                "type": "string",
                                "enum": [
                                  "ready"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "needs_provisioning"
                                ]
                              }
                            ]
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/creative-hub/team-folders/provision": {
      "post": {
        "operationId": "postApiV1CreativeHubTeamFoldersProvision",
        "summary": "Provision a Drive root for the caller or a visible team member",
        "tags": [
          "creative-hub"
        ],
        "description": "Idempotently creates the Drive root for the target user (default: the caller) under a per-(team, user) lock. The target must be within the caller team-scoped visible set.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "properties": {
                  "sessionId": {
                    "minLength": 1,
                    "maxLength": 128,
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "session_id",
                    "user_id",
                    "folder_id",
                    "status"
                  ],
                  "properties": {
                    "session_id": {
                      "type": "string"
                    },
                    "user_id": {
                      "type": "string"
                    },
                    "folder_id": {
                      "type": "string"
                    },
                    "status": {
                      "type": "string",
                      "enum": [
                        "ready"
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/creative-hub/files": {
      "get": {
        "operationId": "getApiV1CreativeHubFiles",
        "summary": "List files and folders",
        "tags": [
          "creative-hub"
        ],
        "description": "Lists files and folders from Google Drive for the current user or a specified team member.",
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "folderId",
            "required": false
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "memberId",
            "required": false,
            "description": "View files of a specific team member (admin/owner/super_admin only)"
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "pageToken",
            "required": false
          },
          {
            "schema": {
              "minimum": 1,
              "maximum": 1000,
              "default": 100,
              "type": "number"
            },
            "in": "query",
            "name": "pageSize",
            "required": false
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "files",
                    "nextPageToken",
                    "userFolderId",
                    "currentFolderId",
                    "member"
                  ],
                  "properties": {
                    "files": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "id",
                          "name",
                          "mimeType",
                          "size",
                          "createdTime",
                          "modifiedTime",
                          "thumbnailUrl",
                          "contentUrl",
                          "viewUrl",
                          "downloadUrl",
                          "isVideo",
                          "isImage",
                          "isAudio",
                          "isFolder",
                          "parents"
                        ],
                        "properties": {
                          "id": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "name": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "mimeType": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "size": {
                            "type": "integer"
                          },
                          "createdTime": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "modifiedTime": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "thumbnailUrl": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "contentUrl": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "viewUrl": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "downloadUrl": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "isVideo": {
                            "type": "boolean"
                          },
                          "isImage": {
                            "type": "boolean"
                          },
                          "isAudio": {
                            "type": "boolean"
                          },
                          "isFolder": {
                            "type": "boolean"
                          },
                          "parents": {
                            "anyOf": [
                              {
                                "type": "array",
                                "items": {
                                  "type": "string"
                                }
                              },
                              {
                                "type": "null"
                              }
                            ]
                          }
                        }
                      }
                    },
                    "nextPageToken": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "userFolderId": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "currentFolderId": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "member": {
                      "anyOf": [
                        {
                          "type": "object",
                          "required": [
                            "id",
                            "name",
                            "email",
                            "role"
                          ],
                          "properties": {
                            "id": {
                              "type": "string"
                            },
                            "name": {
                              "anyOf": [
                                {
                                  "type": "string"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "email": {
                              "type": "string"
                            },
                            "role": {
                              "type": "string"
                            }
                          }
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/creative-hub/breadcrumb": {
      "get": {
        "operationId": "getApiV1CreativeHubBreadcrumb",
        "summary": "Get folder breadcrumb path",
        "tags": [
          "creative-hub"
        ],
        "description": "Resolves the parent chain from a folder up to the user root to build a breadcrumb navigation path.",
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "folderId",
            "required": true
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "memberId",
            "required": false,
            "description": "The team member whose folder tree to resolve"
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "breadcrumb"
                  ],
                  "properties": {
                    "breadcrumb": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "id",
                          "name"
                        ],
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "name": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/creative-hub/upload": {
      "post": {
        "operationId": "postApiV1CreativeHubUpload",
        "summary": "Upload files to Drive",
        "tags": [
          "creative-hub"
        ],
        "description": "Uploads one or more files to the user's Google Drive folder via multipart form data. Supports up to 50 files, 500MB each.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "uploaded",
                    "count"
                  ],
                  "properties": {
                    "uploaded": {
                      "type": "array",
                      "items": {
                        "anyOf": [
                          {
                            "type": "object",
                            "required": [
                              "id",
                              "name",
                              "mimeType",
                              "size",
                              "createdTime",
                              "modifiedTime",
                              "thumbnailUrl",
                              "contentUrl",
                              "viewUrl",
                              "downloadUrl",
                              "isVideo",
                              "isImage",
                              "isAudio",
                              "isFolder",
                              "parents"
                            ],
                            "properties": {
                              "id": {
                                "anyOf": [
                                  {
                                    "type": "string"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "name": {
                                "anyOf": [
                                  {
                                    "type": "string"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "mimeType": {
                                "anyOf": [
                                  {
                                    "type": "string"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "size": {
                                "type": "integer"
                              },
                              "createdTime": {
                                "anyOf": [
                                  {
                                    "type": "string"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "modifiedTime": {
                                "anyOf": [
                                  {
                                    "type": "string"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "thumbnailUrl": {
                                "anyOf": [
                                  {
                                    "type": "string"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "contentUrl": {
                                "anyOf": [
                                  {
                                    "type": "string"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "viewUrl": {
                                "anyOf": [
                                  {
                                    "type": "string"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "downloadUrl": {
                                "anyOf": [
                                  {
                                    "type": "string"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "isVideo": {
                                "type": "boolean"
                              },
                              "isImage": {
                                "type": "boolean"
                              },
                              "isAudio": {
                                "type": "boolean"
                              },
                              "isFolder": {
                                "type": "boolean"
                              },
                              "parents": {
                                "anyOf": [
                                  {
                                    "type": "array",
                                    "items": {
                                      "type": "string"
                                    }
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              }
                            }
                          },
                          {
                            "type": "object",
                            "required": [
                              "error"
                            ],
                            "properties": {
                              "name": {
                                "anyOf": [
                                  {
                                    "type": "string"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "error": {
                                "type": "string"
                              }
                            }
                          }
                        ]
                      }
                    },
                    "count": {
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        },
        "requestBody": {
          "content": {
            "multipart/form-data": {
              "schema": {
                "type": "object",
                "properties": {
                  "folderId": {
                    "type": "string",
                    "description": "Optional target Drive folder id."
                  },
                  "file": {
                    "type": "string",
                    "format": "binary",
                    "description": "One or more uploaded files."
                  }
                },
                "additionalProperties": true
              }
            }
          }
        }
      }
    },
    "/api/v1/creative-hub/import-url": {
      "post": {
        "operationId": "postApiV1CreativeHubImportUrl",
        "summary": "Import generated chat media into Creative Hub",
        "tags": [
          "creative-hub"
        ],
        "description": "Server-side imports an AI Chat generated image/video from the configured creative media CDN or S3 bucket into the current user Drive folder.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "url"
                ],
                "properties": {
                  "url": {
                    "minLength": 1,
                    "maxLength": 2048,
                    "type": "string"
                  },
                  "filename": {
                    "minLength": 1,
                    "maxLength": 180,
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "file"
                  ],
                  "properties": {
                    "file": {
                      "type": "object",
                      "required": [
                        "id",
                        "name",
                        "mimeType",
                        "size",
                        "createdTime",
                        "modifiedTime",
                        "thumbnailUrl",
                        "contentUrl",
                        "viewUrl",
                        "downloadUrl",
                        "isVideo",
                        "isImage",
                        "isAudio",
                        "isFolder",
                        "parents"
                      ],
                      "properties": {
                        "id": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "name": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "mimeType": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "size": {
                          "type": "integer"
                        },
                        "createdTime": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "modifiedTime": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "thumbnailUrl": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "contentUrl": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "viewUrl": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "downloadUrl": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "isVideo": {
                          "type": "boolean"
                        },
                        "isImage": {
                          "type": "boolean"
                        },
                        "isAudio": {
                          "type": "boolean"
                        },
                        "isFolder": {
                          "type": "boolean"
                        },
                        "parents": {
                          "anyOf": [
                            {
                              "type": "array",
                              "items": {
                                "type": "string"
                              }
                            },
                            {
                              "type": "null"
                            }
                          ]
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "415": {
            "description": "Response 415",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/creative-hub/download-url": {
      "post": {
        "operationId": "postApiV1CreativeHubDownloadUrl",
        "summary": "Download generated chat media",
        "tags": [
          "creative-hub"
        ],
        "description": "Server-side downloads an AI Chat generated image/video from the configured creative media CDN or S3 bucket so browsers can save it as a file instead of opening a cross-origin tab.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "url"
                ],
                "properties": {
                  "url": {
                    "minLength": 1,
                    "maxLength": 2048,
                    "type": "string"
                  },
                  "filename": {
                    "minLength": 1,
                    "maxLength": 180,
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Generated media file stream. Content-Type is the original image/* or video/* media type.",
            "content": {
              "image/*": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              },
              "video/*": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              },
              "application/octet-stream": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "415": {
            "description": "Response 415",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/creative-hub/delete": {
      "post": {
        "operationId": "postApiV1CreativeHubDelete",
        "summary": "Delete files or folders",
        "tags": [
          "creative-hub"
        ],
        "description": "Moves files or folders to trash on Google Drive. Falls back to permanent delete if trash fails.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "fileIds"
                ],
                "properties": {
                  "fileIds": {
                    "minItems": 1,
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "results",
                    "deleted"
                  ],
                  "properties": {
                    "results": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "id",
                          "success"
                        ],
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "success": {
                            "type": "boolean"
                          },
                          "error": {
                            "type": "string"
                          }
                        }
                      }
                    },
                    "deleted": {
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/creative-hub/folder": {
      "post": {
        "operationId": "postApiV1CreativeHubFolder",
        "summary": "Create a new folder",
        "tags": [
          "creative-hub"
        ],
        "description": "Creates a new folder in the user's Google Drive space, optionally under a specific parent folder.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "name"
                ],
                "properties": {
                  "name": {
                    "minLength": 1,
                    "type": "string"
                  },
                  "parentFolderId": {
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "folder"
                  ],
                  "properties": {
                    "folder": {
                      "type": "object",
                      "required": [
                        "id",
                        "name",
                        "mimeType",
                        "size",
                        "createdTime",
                        "modifiedTime",
                        "thumbnailUrl",
                        "contentUrl",
                        "viewUrl",
                        "downloadUrl",
                        "isVideo",
                        "isImage",
                        "isAudio",
                        "isFolder",
                        "parents"
                      ],
                      "properties": {
                        "id": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "name": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "mimeType": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "size": {
                          "type": "integer"
                        },
                        "createdTime": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "modifiedTime": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "thumbnailUrl": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "contentUrl": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "viewUrl": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "downloadUrl": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "isVideo": {
                          "type": "boolean"
                        },
                        "isImage": {
                          "type": "boolean"
                        },
                        "isAudio": {
                          "type": "boolean"
                        },
                        "isFolder": {
                          "type": "boolean"
                        },
                        "parents": {
                          "anyOf": [
                            {
                              "type": "array",
                              "items": {
                                "type": "string"
                              }
                            },
                            {
                              "type": "null"
                            }
                          ]
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "Conflict - resource state prevents the operation",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/creative-hub/rename": {
      "patch": {
        "operationId": "patchApiV1CreativeHubRename",
        "summary": "Rename a file or folder",
        "tags": [
          "creative-hub"
        ],
        "description": "Renames a single file or folder on Google Drive.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "fileId",
                  "newName"
                ],
                "properties": {
                  "fileId": {
                    "type": "string"
                  },
                  "newName": {
                    "minLength": 1,
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "file"
                  ],
                  "properties": {
                    "file": {
                      "type": "object",
                      "required": [
                        "id",
                        "name",
                        "mimeType"
                      ],
                      "properties": {
                        "id": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "name": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "mimeType": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/creative-hub/bulk-rename": {
      "post": {
        "operationId": "postApiV1CreativeHubBulkRename",
        "summary": "Bulk rename files",
        "tags": [
          "creative-hub"
        ],
        "description": "Renames multiple files or folders in a single request. Returns individual success/failure results.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "items"
                ],
                "properties": {
                  "items": {
                    "minItems": 1,
                    "type": "array",
                    "items": {
                      "type": "object",
                      "required": [
                        "fileId",
                        "newName"
                      ],
                      "properties": {
                        "fileId": {
                          "type": "string"
                        },
                        "newName": {
                          "minLength": 1,
                          "type": "string"
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "results",
                    "renamed"
                  ],
                  "properties": {
                    "results": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "fileId",
                          "newName",
                          "success"
                        ],
                        "properties": {
                          "fileId": {
                            "type": "string"
                          },
                          "newName": {
                            "type": "string"
                          },
                          "success": {
                            "type": "boolean"
                          },
                          "error": {
                            "type": "string"
                          }
                        }
                      }
                    },
                    "renamed": {
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/creative-hub/move": {
      "post": {
        "operationId": "postApiV1CreativeHubMove",
        "summary": "Move files to a different folder",
        "tags": [
          "creative-hub"
        ],
        "description": "Moves one or more files to a target folder on Google Drive (drag and drop support).",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "fileIds",
                  "targetFolderId"
                ],
                "properties": {
                  "fileIds": {
                    "minItems": 1,
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  },
                  "targetFolderId": {
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "results",
                    "moved"
                  ],
                  "properties": {
                    "results": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "id",
                          "success"
                        ],
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "success": {
                            "type": "boolean"
                          },
                          "error": {
                            "type": "string"
                          }
                        }
                      }
                    },
                    "moved": {
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/creative-hub/files/{fileId}/url": {
      "get": {
        "operationId": "getApiV1CreativeHubFilesByFileIdUrl",
        "summary": "Get direct URL for a creative file",
        "tags": [
          "creative-hub"
        ],
        "description": "Returns the direct download URL and metadata for a file on Google Drive.",
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "in": "path",
            "name": "fileId",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "url",
                    "directUrl"
                  ],
                  "properties": {
                    "url": {
                      "type": "string"
                    },
                    "directUrl": {
                      "type": "string"
                    },
                    "name": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "mimeType": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/creative-hub/media-capabilities": {
      "post": {
        "operationId": "postApiV1CreativeHubMediaCapabilities",
        "summary": "Mint signed media capability tokens for Drive files",
        "tags": [
          "creative-hub"
        ],
        "description": "Returns short-lived, fileId-bound capability tokens for the requested Drive files that live within the caller tenant-allowed Drive roots (own folder + visible team members). The tokens gate the unauthenticated thumbnail/content proxies so the browser can load media without a Bearer header. Files outside the allowed roots are omitted (never minted). Used to (re)mint caps at render time — e.g. for stored campaign drafts — so capability URLs are never persisted.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "fileIds"
                ],
                "properties": {
                  "fileIds": {
                    "minItems": 1,
                    "maxItems": 200,
                    "type": "array",
                    "items": {
                      "minLength": 1,
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "capabilities"
                  ],
                  "properties": {
                    "capabilities": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "fileId",
                          "cap",
                          "exp"
                        ],
                        "properties": {
                          "fileId": {
                            "type": "string"
                          },
                          "cap": {
                            "type": "string"
                          },
                          "exp": {
                            "type": "integer"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/creative-hub/generate/video": {
      "post": {
        "operationId": "creativeHubGenerateVideo",
        "summary": "Generate an AI video clip",
        "tags": [
          "creative-hub",
          "creative-generation"
        ],
        "description": "Queues an AI video generation job using Luma or Runway. Returns 202 Accepted with an async-job handle; poll GET /api/v1/creative-hub/generate/jobs/:id to retrieve the result.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "prompt"
                ],
                "properties": {
                  "prompt": {
                    "minLength": 1,
                    "maxLength": 2000,
                    "type": "string"
                  },
                  "image_url": {
                    "type": "string"
                  },
                  "duration": {
                    "minimum": 2,
                    "maximum": 10,
                    "type": "integer"
                  },
                  "aspect_ratio": {
                    "anyOf": [
                      {
                        "type": "string",
                        "enum": [
                          "16:9"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "9:16"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "1:1"
                        ]
                      }
                    ]
                  },
                  "provider": {
                    "anyOf": [
                      {
                        "type": "string",
                        "enum": [
                          "luma_ray3"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "runway_gen4"
                        ]
                      }
                    ]
                  },
                  "drive_folder_id": {
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "202": {
            "description": "Accepted - processing asynchronously",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "job_id",
                    "status",
                    "polling_interval_ms",
                    "created_at"
                  ],
                  "properties": {
                    "job_id": {
                      "description": "ID of the queued creative_job row",
                      "type": "string"
                    },
                    "status": {
                      "description": "Initial job status (always \"pending\" right after enqueue)",
                      "type": "string"
                    },
                    "polling_interval_ms": {
                      "description": "Suggested polling interval for GET /generate/jobs/:id",
                      "type": "integer"
                    },
                    "estimated_wait_ms": {
                      "description": "Rough estimated completion wait (provider-dependent)",
                      "type": "integer"
                    },
                    "created_at": {
                      "format": "date-time",
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "402": {
            "description": "Response 402",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "Too many requests - rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "Service unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/creative-hub/generate/image": {
      "post": {
        "operationId": "creativeHubGenerateImage",
        "summary": "Generate an AI image from a text prompt",
        "tags": [
          "creative-hub",
          "creative-generation"
        ],
        "description": "Queues an AI image generation job (Flux 2 Pro with GPT-Image fallback). Returns 202 Accepted with an async-job handle; poll GET /api/v1/creative-hub/generate/jobs/:id to retrieve the result.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "prompt"
                ],
                "properties": {
                  "prompt": {
                    "minLength": 1,
                    "maxLength": 2000,
                    "type": "string"
                  },
                  "width": {
                    "minimum": 256,
                    "maximum": 2048,
                    "type": "integer"
                  },
                  "height": {
                    "minimum": 256,
                    "maximum": 2048,
                    "type": "integer"
                  },
                  "num_variants": {
                    "minimum": 1,
                    "maximum": 4,
                    "type": "integer"
                  },
                  "provider": {
                    "anyOf": [
                      {
                        "type": "string",
                        "enum": [
                          "flux_2_pro"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "gpt_image_1_5"
                        ]
                      }
                    ]
                  },
                  "drive_folder_id": {
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "202": {
            "description": "Accepted - processing asynchronously",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "job_id",
                    "status",
                    "polling_interval_ms",
                    "created_at"
                  ],
                  "properties": {
                    "job_id": {
                      "description": "ID of the queued creative_job row",
                      "type": "string"
                    },
                    "status": {
                      "description": "Initial job status (always \"pending\" right after enqueue)",
                      "type": "string"
                    },
                    "polling_interval_ms": {
                      "description": "Suggested polling interval for GET /generate/jobs/:id",
                      "type": "integer"
                    },
                    "estimated_wait_ms": {
                      "description": "Rough estimated completion wait (provider-dependent)",
                      "type": "integer"
                    },
                    "created_at": {
                      "format": "date-time",
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "402": {
            "description": "Response 402",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "Too many requests - rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "Service unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/creative-hub/generate/avatar": {
      "post": {
        "operationId": "creativeHubGenerateAvatar",
        "summary": "Generate an avatar UGC video with HeyGen",
        "tags": [
          "creative-hub",
          "creative-generation"
        ],
        "description": "Queues an avatar-based UGC video generation job via HeyGen. Returns 202 Accepted with an async-job handle; poll GET /api/v1/creative-hub/generate/jobs/:id to retrieve the result.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "script"
                ],
                "properties": {
                  "script": {
                    "minLength": 1,
                    "maxLength": 5000,
                    "type": "string"
                  },
                  "avatar_id": {
                    "type": "string"
                  },
                  "voice_id": {
                    "type": "string"
                  },
                  "language": {
                    "type": "string"
                  },
                  "drive_folder_id": {
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "202": {
            "description": "Accepted - processing asynchronously",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "job_id",
                    "status",
                    "polling_interval_ms",
                    "created_at"
                  ],
                  "properties": {
                    "job_id": {
                      "description": "ID of the queued creative_job row",
                      "type": "string"
                    },
                    "status": {
                      "description": "Initial job status (always \"pending\" right after enqueue)",
                      "type": "string"
                    },
                    "polling_interval_ms": {
                      "description": "Suggested polling interval for GET /generate/jobs/:id",
                      "type": "integer"
                    },
                    "estimated_wait_ms": {
                      "description": "Rough estimated completion wait (provider-dependent)",
                      "type": "integer"
                    },
                    "created_at": {
                      "format": "date-time",
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "402": {
            "description": "Response 402",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "Too many requests - rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "Service unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/creative-hub/generate/tts": {
      "post": {
        "operationId": "creativeHubGenerateTTS",
        "summary": "Generate text-to-speech audio",
        "tags": [
          "creative-hub",
          "creative-generation"
        ],
        "description": "Queues a TTS audio generation job via ElevenLabs or OpenAI. Returns 202 Accepted with an async-job handle; poll GET /api/v1/creative-hub/generate/jobs/:id to retrieve the result.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "text"
                ],
                "properties": {
                  "text": {
                    "minLength": 1,
                    "maxLength": 5000,
                    "type": "string"
                  },
                  "voice_id": {
                    "type": "string"
                  },
                  "language": {
                    "type": "string"
                  },
                  "provider": {
                    "anyOf": [
                      {
                        "type": "string",
                        "enum": [
                          "elevenlabs"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "openai_tts"
                        ]
                      }
                    ]
                  },
                  "drive_folder_id": {
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "202": {
            "description": "Accepted - processing asynchronously",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "job_id",
                    "status",
                    "polling_interval_ms",
                    "created_at"
                  ],
                  "properties": {
                    "job_id": {
                      "description": "ID of the queued creative_job row",
                      "type": "string"
                    },
                    "status": {
                      "description": "Initial job status (always \"pending\" right after enqueue)",
                      "type": "string"
                    },
                    "polling_interval_ms": {
                      "description": "Suggested polling interval for GET /generate/jobs/:id",
                      "type": "integer"
                    },
                    "estimated_wait_ms": {
                      "description": "Rough estimated completion wait (provider-dependent)",
                      "type": "integer"
                    },
                    "created_at": {
                      "format": "date-time",
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "402": {
            "description": "Response 402",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "Too many requests - rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "Service unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/creative-hub/generate/composite": {
      "post": {
        "operationId": "creativeHubGenerateComposite",
        "summary": "Assemble a composite video with Creatomate",
        "tags": [
          "creative-hub",
          "creative-generation"
        ],
        "description": "Queues a composite video assembly job via Creatomate with multiple media elements. Returns 202 Accepted with an async-job handle; poll GET /api/v1/creative-hub/generate/jobs/:id to retrieve the result.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "elements"
                ],
                "properties": {
                  "template_id": {
                    "type": "string"
                  },
                  "elements": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "required": [
                        "type",
                        "source"
                      ],
                      "properties": {
                        "type": {
                          "anyOf": [
                            {
                              "type": "string",
                              "enum": [
                                "video"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "image"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "audio"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "text"
                              ]
                            }
                          ]
                        },
                        "source": {
                          "type": "string"
                        },
                        "start_time": {
                          "type": "number"
                        },
                        "duration": {
                          "type": "number"
                        },
                        "position": {
                          "type": "object",
                          "required": [
                            "x",
                            "y"
                          ],
                          "properties": {
                            "x": {
                              "type": "number"
                            },
                            "y": {
                              "type": "number"
                            }
                          }
                        },
                        "style": {
                          "description": "JSON object with nested arrays and objects.",
                          "type": "object",
                          "additionalProperties": {
                            "$comment": "json-value",
                            "description": "Arbitrary JSON value with nested arrays and objects."
                          }
                        }
                      }
                    }
                  },
                  "width": {
                    "type": "integer"
                  },
                  "height": {
                    "type": "integer"
                  },
                  "duration": {
                    "type": "number"
                  },
                  "drive_folder_id": {
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "202": {
            "description": "Accepted - processing asynchronously",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "job_id",
                    "status",
                    "polling_interval_ms",
                    "created_at"
                  ],
                  "properties": {
                    "job_id": {
                      "description": "ID of the queued creative_job row",
                      "type": "string"
                    },
                    "status": {
                      "description": "Initial job status (always \"pending\" right after enqueue)",
                      "type": "string"
                    },
                    "polling_interval_ms": {
                      "description": "Suggested polling interval for GET /generate/jobs/:id",
                      "type": "integer"
                    },
                    "estimated_wait_ms": {
                      "description": "Rough estimated completion wait (provider-dependent)",
                      "type": "integer"
                    },
                    "created_at": {
                      "format": "date-time",
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "402": {
            "description": "Response 402",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "Too many requests - rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "Service unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/creative-hub/generate/jobs": {
      "get": {
        "operationId": "creativeHubListGenerationJobs",
        "summary": "List creative generation jobs",
        "tags": [
          "creative-hub",
          "creative-generation"
        ],
        "description": "Returns a paginated list of the current user's creative generation jobs, with optional type and status filters. Uses cursor-based pagination (next_cursor is the id of the last item).",
        "parameters": [
          {
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "enum": [
                    "image"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "video"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "avatar"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "tts"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "composite"
                  ]
                }
              ]
            },
            "in": "query",
            "name": "type",
            "required": false
          },
          {
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "enum": [
                    "pending"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "processing"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "completed"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "failed"
                  ]
                }
              ]
            },
            "in": "query",
            "name": "status",
            "required": false
          },
          {
            "schema": {
              "minimum": 1,
              "maximum": 50,
              "default": 20,
              "type": "integer"
            },
            "in": "query",
            "name": "limit",
            "required": false
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "cursor",
            "required": false
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "items",
                    "next_cursor"
                  ],
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "id",
                          "type",
                          "status",
                          "provider",
                          "prompt",
                          "result_urls",
                          "cost_cents",
                          "error_message",
                          "created_at",
                          "completed_at"
                        ],
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "type": {
                            "type": "string"
                          },
                          "status": {
                            "type": "string"
                          },
                          "provider": {
                            "type": "string"
                          },
                          "prompt": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "result_urls": {
                            "$comment": "json-value",
                            "description": "Arbitrary JSON value with nested arrays and objects."
                          },
                          "cost_cents": {
                            "type": "integer"
                          },
                          "error_message": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "created_at": {
                            "format": "date-time",
                            "type": "string"
                          },
                          "completed_at": {
                            "anyOf": [
                              {
                                "format": "date-time",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          }
                        }
                      }
                    },
                    "next_cursor": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/creative-hub/generate/jobs/{id}": {
      "get": {
        "operationId": "creativeHubGetGenerationJob",
        "summary": "Get creative generation job status",
        "tags": [
          "creative-hub",
          "creative-generation"
        ],
        "description": "Returns the full details and current status of a specific creative generation job.",
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "id",
                    "user_id",
                    "type",
                    "status",
                    "provider",
                    "prompt",
                    "settings",
                    "result_urls",
                    "error_message",
                    "cost_cents",
                    "drive_folder_id",
                    "metadata",
                    "created_at",
                    "completed_at"
                  ],
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "user_id": {
                      "type": "string"
                    },
                    "type": {
                      "type": "string"
                    },
                    "status": {
                      "type": "string"
                    },
                    "provider": {
                      "type": "string"
                    },
                    "prompt": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "settings": {
                      "$comment": "json-value",
                      "description": "Arbitrary JSON value with nested arrays and objects."
                    },
                    "result_urls": {
                      "$comment": "json-value",
                      "description": "Arbitrary JSON value with nested arrays and objects."
                    },
                    "error_message": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "cost_cents": {
                      "type": "integer"
                    },
                    "drive_folder_id": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "metadata": {
                      "$comment": "json-value",
                      "description": "Arbitrary JSON value with nested arrays and objects."
                    },
                    "created_at": {
                      "format": "date-time",
                      "type": "string"
                    },
                    "completed_at": {
                      "anyOf": [
                        {
                          "format": "date-time",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/creative-hub/generate/avatars": {
      "get": {
        "operationId": "creativeHubListAvatars",
        "summary": "List available HeyGen avatars",
        "tags": [
          "creative-hub",
          "creative-generation"
        ],
        "description": "Returns the list of available HeyGen avatars that can be used for UGC video generation. The avatar shape is provider-defined (HeyGen) and may evolve - treated as an opaque object map.",
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "avatars"
                  ],
                  "properties": {
                    "avatars": {
                      "type": "array",
                      "items": {
                        "description": "JSON object with nested arrays and objects.",
                        "type": "object",
                        "additionalProperties": {
                          "$comment": "json-value",
                          "description": "Arbitrary JSON value with nested arrays and objects."
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/creative-hub/image-creatives/generate": {
      "post": {
        "operationId": "creativeHubGenerateImageCreative",
        "summary": "Generate static ad image creatives (async)",
        "tags": [
          "creative-hub",
          "creative-generation"
        ],
        "description": "Starts an asynchronous static ad creative generation. When brand_kit_id or product_id is provided, the selected team brand or product context is folded into the provider prompt. Up to 4 reference images can be supplied via reference_image_urls; product_image_url stays accepted as the first reference for back-compat. Supplying any reference switches the model from text-to-image (Seedream 4.5) to the reference-preserving Nano Banana Pro and is priced at that higher rate. brand_colors fold into the prompt as colour art direction.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "objective"
                ],
                "properties": {
                  "objective": {
                    "anyOf": [
                      {
                        "type": "string",
                        "enum": [
                          "sales"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "awareness"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "traffic"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "leads"
                        ]
                      }
                    ]
                  },
                  "product_id": {
                    "minLength": 1,
                    "maxLength": 100,
                    "type": "string"
                  },
                  "product_description": {
                    "maxLength": 2000,
                    "type": "string"
                  },
                  "product_image_url": {
                    "type": "string"
                  },
                  "reference_image_urls": {
                    "maxItems": 4,
                    "type": "array",
                    "items": {
                      "maxLength": 2000,
                      "type": "string"
                    }
                  },
                  "format": {
                    "anyOf": [
                      {
                        "type": "string",
                        "enum": [
                          "1:1"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "3:4"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "4:5"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "9:16"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "16:9"
                        ]
                      }
                    ]
                  },
                  "language": {
                    "type": "string"
                  },
                  "style": {
                    "maxLength": 64,
                    "type": "string"
                  },
                  "resolution": {
                    "anyOf": [
                      {
                        "type": "string",
                        "enum": [
                          "720p"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "1080p"
                        ]
                      }
                    ]
                  },
                  "num_variants": {
                    "minimum": 1,
                    "maximum": 4,
                    "type": "integer"
                  },
                  "brand_colors": {
                    "maxItems": 5,
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  },
                  "brand_kit_id": {
                    "minLength": 1,
                    "maxLength": 100,
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "202": {
            "description": "Accepted - processing asynchronously",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "created_at",
                    "credits_estimated",
                    "generation_id",
                    "polling_interval_ms",
                    "status"
                  ],
                  "properties": {
                    "created_at": {
                      "type": "string"
                    },
                    "credits_estimated": {
                      "type": "integer"
                    },
                    "generation_id": {
                      "type": "string"
                    },
                    "polling_interval_ms": {
                      "type": "integer"
                    },
                    "status": {
                      "anyOf": [
                        {
                          "type": "string",
                          "enum": [
                            "queued"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "processing"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "completed"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "failed"
                          ]
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "402": {
            "description": "Response 402",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "Too many requests - rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "Service unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/creative-hub/image-creatives/estimate": {
      "post": {
        "operationId": "creativeHubEstimateImageCreative",
        "summary": "Estimate image creative generation credit cost",
        "tags": [
          "creative-hub",
          "creative-generation"
        ],
        "description": "Returns the deterministic credit hold estimate for an image creative generation. Supplying any reference image (reference_image_urls or product_image_url) raises the estimate to the reference-preserving model rate.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "num_variants"
                ],
                "properties": {
                  "num_variants": {
                    "minimum": 1,
                    "maximum": 4,
                    "type": "integer"
                  },
                  "product_image_url": {
                    "type": "string"
                  },
                  "reference_image_urls": {
                    "maxItems": 4,
                    "type": "array",
                    "items": {
                      "maxLength": 2000,
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "credits"
                  ],
                  "properties": {
                    "credits": {
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/creative-hub/image-creatives/generations": {
      "get": {
        "operationId": "creativeHubListImageCreativeGenerations",
        "summary": "List image creative generations",
        "tags": [
          "creative-hub",
          "creative-generation"
        ],
        "description": "Lists image creative generations for the authenticated user and joins completed assets.",
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "batch_id",
            "required": false
          },
          {
            "schema": {
              "minimum": 1,
              "maximum": 100,
              "type": "integer"
            },
            "in": "query",
            "name": "limit",
            "required": false
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "cursor",
            "required": false
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "generations",
                    "next_cursor"
                  ],
                  "properties": {
                    "generations": {
                      "type": "array",
                      "items": {
                        "additionalProperties": false,
                        "type": "object",
                        "required": [
                          "assets",
                          "batch_id",
                          "completed_at",
                          "created_at",
                          "credits_charged",
                          "credits_estimated",
                          "error_message",
                          "id",
                          "mode",
                          "result_asset_ids",
                          "settings",
                          "status"
                        ],
                        "properties": {
                          "assets": {
                            "type": "array",
                            "items": {
                              "additionalProperties": false,
                              "type": "object",
                              "required": [
                                "format",
                                "id",
                                "kind",
                                "name",
                                "thumbnail_url",
                                "url"
                              ],
                              "properties": {
                                "format": {
                                  "anyOf": [
                                    {
                                      "type": "string"
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "id": {
                                  "type": "string"
                                },
                                "kind": {
                                  "type": "string"
                                },
                                "name": {
                                  "anyOf": [
                                    {
                                      "type": "string"
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "thumbnail_url": {
                                  "anyOf": [
                                    {
                                      "type": "string"
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "url": {
                                  "type": "string"
                                }
                              }
                            }
                          },
                          "batch_id": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "completed_at": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "created_at": {
                            "type": "string"
                          },
                          "credits_charged": {
                            "anyOf": [
                              {
                                "type": "integer"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "credits_estimated": {
                            "type": "integer"
                          },
                          "error_message": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "id": {
                            "type": "string"
                          },
                          "mode": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "result_asset_ids": {
                            "anyOf": [
                              {
                                "type": "array",
                                "items": {
                                  "type": "string"
                                }
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "settings": {
                            "additionalProperties": false,
                            "type": "object",
                            "properties": {
                              "billing": {
                                "additionalProperties": false,
                                "type": "object",
                                "properties": {
                                  "ai_chat_credits_actual": {
                                    "type": "number"
                                  },
                                  "ai_chat_credits_estimated": {
                                    "type": "number"
                                  },
                                  "higgsfield_credits_actual": {
                                    "type": "number"
                                  },
                                  "higgsfield_credits_estimated": {
                                    "type": "number"
                                  },
                                  "items": {
                                    "type": "array",
                                    "items": {
                                      "additionalProperties": false,
                                      "type": "object",
                                      "required": [
                                        "model_id",
                                        "provider",
                                        "provider_cents_per_unit",
                                        "provider_cost_cents_estimated",
                                        "retail_credits",
                                        "retail_credits_per_unit",
                                        "unit",
                                        "units"
                                      ],
                                      "properties": {
                                        "model_id": {
                                          "type": "string"
                                        },
                                        "provider": {
                                          "type": "string"
                                        },
                                        "provider_cents_per_unit": {
                                          "type": "number"
                                        },
                                        "provider_cost_cents_estimated": {
                                          "type": "number"
                                        },
                                        "retail_credits": {
                                          "type": "number"
                                        },
                                        "retail_credits_per_unit": {
                                          "type": "number"
                                        },
                                        "unit": {
                                          "type": "string"
                                        },
                                        "units": {
                                          "type": "number"
                                        }
                                      }
                                    }
                                  },
                                  "model_id": {
                                    "type": "string"
                                  },
                                  "model_unit": {
                                    "type": "string"
                                  },
                                  "model_units_actual": {
                                    "type": "number"
                                  },
                                  "model_units_estimated": {
                                    "type": "number"
                                  },
                                  "pricing_version": {
                                    "type": "string"
                                  },
                                  "provider": {
                                    "type": "string"
                                  },
                                  "provider_cents_per_unit": {
                                    "type": "number"
                                  },
                                  "provider_cost_cents_actual": {
                                    "type": "number"
                                  },
                                  "provider_cost_cents_estimated": {
                                    "type": "number"
                                  },
                                  "provider_credits_actual": {
                                    "type": "number"
                                  },
                                  "provider_credits_estimated": {
                                    "type": "number"
                                  },
                                  "retail_credits_per_higgsfield_credit": {
                                    "type": "number"
                                  },
                                  "retail_credits_per_unit": {
                                    "type": "number"
                                  },
                                  "retail_credits_per_variant": {
                                    "type": "number"
                                  },
                                  "total_credits_charged": {
                                    "type": "number"
                                  },
                                  "total_credits_estimated": {
                                    "type": "number"
                                  }
                                }
                              },
                              "brand_kit_id": {
                                "anyOf": [
                                  {
                                    "type": "string"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "brand_kit_name": {
                                "anyOf": [
                                  {
                                    "type": "string"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "estimated_cost_cents": {
                                "type": "number"
                              },
                              "format": {
                                "anyOf": [
                                  {
                                    "type": "string",
                                    "enum": [
                                      "1:1"
                                    ]
                                  },
                                  {
                                    "type": "string",
                                    "enum": [
                                      "3:4"
                                    ]
                                  },
                                  {
                                    "type": "string",
                                    "enum": [
                                      "4:5"
                                    ]
                                  },
                                  {
                                    "type": "string",
                                    "enum": [
                                      "9:16"
                                    ]
                                  },
                                  {
                                    "type": "string",
                                    "enum": [
                                      "16:9"
                                    ]
                                  }
                                ]
                              },
                              "frame_prompt": {
                                "type": "string"
                              },
                              "language": {
                                "type": "string"
                              },
                              "num_variants": {
                                "type": "integer"
                              },
                              "objective": {
                                "anyOf": [
                                  {
                                    "type": "string",
                                    "enum": [
                                      "sales"
                                    ]
                                  },
                                  {
                                    "type": "string",
                                    "enum": [
                                      "awareness"
                                    ]
                                  },
                                  {
                                    "type": "string",
                                    "enum": [
                                      "traffic"
                                    ]
                                  },
                                  {
                                    "type": "string",
                                    "enum": [
                                      "leads"
                                    ]
                                  }
                                ]
                              },
                              "resolution": {
                                "anyOf": [
                                  {
                                    "type": "string",
                                    "enum": [
                                      "720p"
                                    ]
                                  },
                                  {
                                    "type": "string",
                                    "enum": [
                                      "1080p"
                                    ]
                                  }
                                ]
                              }
                            }
                          },
                          "status": {
                            "anyOf": [
                              {
                                "type": "string",
                                "enum": [
                                  "queued"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "processing"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "completed"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "failed"
                                ]
                              }
                            ]
                          }
                        }
                      }
                    },
                    "next_cursor": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/creative-hub/image-creatives/generations/{id}": {
      "get": {
        "operationId": "creativeHubGetImageCreativeGeneration",
        "summary": "Get image creative generation",
        "tags": [
          "creative-hub",
          "creative-generation"
        ],
        "description": "Returns one image creative generation for polling/detail views.",
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "assets",
                    "batch_id",
                    "completed_at",
                    "created_at",
                    "credits_charged",
                    "credits_estimated",
                    "error_message",
                    "id",
                    "mode",
                    "result_asset_ids",
                    "settings",
                    "status"
                  ],
                  "properties": {
                    "assets": {
                      "type": "array",
                      "items": {
                        "additionalProperties": false,
                        "type": "object",
                        "required": [
                          "format",
                          "id",
                          "kind",
                          "name",
                          "thumbnail_url",
                          "url"
                        ],
                        "properties": {
                          "format": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "id": {
                            "type": "string"
                          },
                          "kind": {
                            "type": "string"
                          },
                          "name": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "thumbnail_url": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "url": {
                            "type": "string"
                          }
                        }
                      }
                    },
                    "batch_id": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "completed_at": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "created_at": {
                      "type": "string"
                    },
                    "credits_charged": {
                      "anyOf": [
                        {
                          "type": "integer"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "credits_estimated": {
                      "type": "integer"
                    },
                    "error_message": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "id": {
                      "type": "string"
                    },
                    "mode": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "result_asset_ids": {
                      "anyOf": [
                        {
                          "type": "array",
                          "items": {
                            "type": "string"
                          }
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "settings": {
                      "additionalProperties": false,
                      "type": "object",
                      "properties": {
                        "billing": {
                          "additionalProperties": false,
                          "type": "object",
                          "properties": {
                            "ai_chat_credits_actual": {
                              "type": "number"
                            },
                            "ai_chat_credits_estimated": {
                              "type": "number"
                            },
                            "higgsfield_credits_actual": {
                              "type": "number"
                            },
                            "higgsfield_credits_estimated": {
                              "type": "number"
                            },
                            "items": {
                              "type": "array",
                              "items": {
                                "additionalProperties": false,
                                "type": "object",
                                "required": [
                                  "model_id",
                                  "provider",
                                  "provider_cents_per_unit",
                                  "provider_cost_cents_estimated",
                                  "retail_credits",
                                  "retail_credits_per_unit",
                                  "unit",
                                  "units"
                                ],
                                "properties": {
                                  "model_id": {
                                    "type": "string"
                                  },
                                  "provider": {
                                    "type": "string"
                                  },
                                  "provider_cents_per_unit": {
                                    "type": "number"
                                  },
                                  "provider_cost_cents_estimated": {
                                    "type": "number"
                                  },
                                  "retail_credits": {
                                    "type": "number"
                                  },
                                  "retail_credits_per_unit": {
                                    "type": "number"
                                  },
                                  "unit": {
                                    "type": "string"
                                  },
                                  "units": {
                                    "type": "number"
                                  }
                                }
                              }
                            },
                            "model_id": {
                              "type": "string"
                            },
                            "model_unit": {
                              "type": "string"
                            },
                            "model_units_actual": {
                              "type": "number"
                            },
                            "model_units_estimated": {
                              "type": "number"
                            },
                            "pricing_version": {
                              "type": "string"
                            },
                            "provider": {
                              "type": "string"
                            },
                            "provider_cents_per_unit": {
                              "type": "number"
                            },
                            "provider_cost_cents_actual": {
                              "type": "number"
                            },
                            "provider_cost_cents_estimated": {
                              "type": "number"
                            },
                            "provider_credits_actual": {
                              "type": "number"
                            },
                            "provider_credits_estimated": {
                              "type": "number"
                            },
                            "retail_credits_per_higgsfield_credit": {
                              "type": "number"
                            },
                            "retail_credits_per_unit": {
                              "type": "number"
                            },
                            "retail_credits_per_variant": {
                              "type": "number"
                            },
                            "total_credits_charged": {
                              "type": "number"
                            },
                            "total_credits_estimated": {
                              "type": "number"
                            }
                          }
                        },
                        "brand_kit_id": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "brand_kit_name": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "estimated_cost_cents": {
                          "type": "number"
                        },
                        "format": {
                          "anyOf": [
                            {
                              "type": "string",
                              "enum": [
                                "1:1"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "3:4"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "4:5"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "9:16"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "16:9"
                              ]
                            }
                          ]
                        },
                        "frame_prompt": {
                          "type": "string"
                        },
                        "language": {
                          "type": "string"
                        },
                        "num_variants": {
                          "type": "integer"
                        },
                        "objective": {
                          "anyOf": [
                            {
                              "type": "string",
                              "enum": [
                                "sales"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "awareness"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "traffic"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "leads"
                              ]
                            }
                          ]
                        },
                        "resolution": {
                          "anyOf": [
                            {
                              "type": "string",
                              "enum": [
                                "720p"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "1080p"
                              ]
                            }
                          ]
                        }
                      }
                    },
                    "status": {
                      "anyOf": [
                        {
                          "type": "string",
                          "enum": [
                            "queued"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "processing"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "completed"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "failed"
                          ]
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      },
      "delete": {
        "operationId": "creativeHubDeleteImageCreativeGeneration",
        "summary": "Delete one image creative generation",
        "tags": [
          "creative-hub",
          "creative-generation"
        ],
        "description": "Soft-deletes one terminal image creative generation and its generated assets. Queued or processing generations cannot be deleted from the UI until they finish.",
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "assets_deleted",
                    "deleted"
                  ],
                  "properties": {
                    "assets_deleted": {
                      "type": "integer"
                    },
                    "deleted": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "Conflict - resource state prevents the operation",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/creative-hub/image-creatives/assets/{id}": {
      "delete": {
        "operationId": "creativeHubDeleteImageCreativeAsset",
        "summary": "Delete one image creative asset",
        "tags": [
          "creative-hub",
          "creative-generation"
        ],
        "description": "Soft-deletes one generated image creative asset owned by the authenticated user. If the parent generation has no visible assets left, it is soft-deleted too.",
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "deleted",
                    "generation_deleted"
                  ],
                  "properties": {
                    "deleted": {
                      "type": "boolean"
                    },
                    "generation_deleted": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/creative-hub/image-studio/generate": {
      "post": {
        "operationId": "creativeHubGenerateCinematicImage",
        "summary": "Generate a cinematic image (async)",
        "tags": [
          "creative-hub",
          "creative-generation"
        ],
        "description": "Starts an asynchronous cinematic image generation and returns the queued generation metadata for polling. When one or more reference images are supplied (reference_image_url and/or reference_image_urls, capped at 4) the generation runs in image-to-image mode and is priced accordingly.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "prompt"
                ],
                "properties": {
                  "prompt": {
                    "minLength": 1,
                    "maxLength": 4000,
                    "type": "string"
                  },
                  "style": {
                    "maxLength": 64,
                    "type": "string"
                  },
                  "language": {
                    "maxLength": 16,
                    "type": "string"
                  },
                  "aspect_ratio": {
                    "anyOf": [
                      {
                        "type": "string",
                        "enum": [
                          "9:16"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "1:1"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "4:5"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "16:9"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "3:4"
                        ]
                      }
                    ]
                  },
                  "resolution": {
                    "anyOf": [
                      {
                        "type": "string",
                        "enum": [
                          "720p"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "1080p"
                        ]
                      }
                    ]
                  },
                  "num_variants": {
                    "minimum": 1,
                    "maximum": 4,
                    "type": "integer"
                  },
                  "brand_colors": {
                    "maxItems": 5,
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  },
                  "brand_kit_id": {
                    "minLength": 1,
                    "maxLength": 100,
                    "type": "string"
                  },
                  "reference_image_url": {
                    "maxLength": 2000,
                    "type": "string"
                  },
                  "reference_image_urls": {
                    "maxItems": 4,
                    "type": "array",
                    "items": {
                      "maxLength": 2000,
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "202": {
            "description": "Accepted - processing asynchronously",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "created_at",
                    "credits_estimated",
                    "estimated_cost_cents",
                    "generation_id",
                    "polling_interval_ms",
                    "status"
                  ],
                  "properties": {
                    "created_at": {
                      "type": "string"
                    },
                    "credits_estimated": {
                      "type": "integer"
                    },
                    "estimated_cost_cents": {
                      "type": "number"
                    },
                    "generation_id": {
                      "type": "string"
                    },
                    "polling_interval_ms": {
                      "type": "integer"
                    },
                    "status": {
                      "anyOf": [
                        {
                          "type": "string",
                          "enum": [
                            "queued"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "processing"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "completed"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "failed"
                          ]
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "402": {
            "description": "Response 402",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "Too many requests - rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "Service unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/creative-hub/image-studio/estimate": {
      "post": {
        "operationId": "creativeHubEstimateCinematicImage",
        "summary": "Estimate cinematic image generation credit cost",
        "tags": [
          "creative-hub",
          "creative-generation"
        ],
        "description": "Returns the deterministic credit hold estimate for a cinematic image generation. The estimate resolves the SAME catalog model the generation will run on, so the style preset (which routes to different, differently-priced models) and any reference image are both reflected in the amount.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "num_variants"
                ],
                "properties": {
                  "num_variants": {
                    "minimum": 1,
                    "maximum": 4,
                    "type": "integer"
                  },
                  "resolution": {
                    "anyOf": [
                      {
                        "type": "string",
                        "enum": [
                          "720p"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "1080p"
                        ]
                      }
                    ]
                  },
                  "style": {
                    "maxLength": 64,
                    "type": "string"
                  },
                  "reference_image_url": {
                    "maxLength": 2000,
                    "type": "string"
                  },
                  "reference_image_urls": {
                    "maxItems": 4,
                    "type": "array",
                    "items": {
                      "maxLength": 2000,
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "credits",
                    "model_id"
                  ],
                  "properties": {
                    "credits": {
                      "type": "integer"
                    },
                    "model_id": {
                      "description": "Catalog model the generation will be priced and run on.",
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/creative-hub/image-studio/generations": {
      "get": {
        "operationId": "creativeHubListCinematicImageGenerations",
        "summary": "List cinematic image generations",
        "tags": [
          "creative-hub",
          "creative-generation"
        ],
        "description": "Lists cinematic image generations for the authenticated user and joins generated assets.",
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "batch_id",
            "required": false
          },
          {
            "schema": {
              "minimum": 1,
              "maximum": 100,
              "type": "integer"
            },
            "in": "query",
            "name": "limit",
            "required": false
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "cursor",
            "required": false
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "generations",
                    "next_cursor"
                  ],
                  "properties": {
                    "generations": {
                      "type": "array",
                      "items": {
                        "additionalProperties": false,
                        "type": "object",
                        "required": [
                          "assets",
                          "batch_id",
                          "completed_at",
                          "created_at",
                          "credits_charged",
                          "credits_estimated",
                          "error_message",
                          "id",
                          "input",
                          "result_asset_ids",
                          "settings",
                          "status"
                        ],
                        "properties": {
                          "assets": {
                            "type": "array",
                            "items": {
                              "additionalProperties": false,
                              "type": "object",
                              "required": [
                                "format",
                                "height",
                                "id",
                                "kind",
                                "name",
                                "thumbnail_url",
                                "url",
                                "width"
                              ],
                              "properties": {
                                "format": {
                                  "anyOf": [
                                    {
                                      "type": "string"
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "height": {
                                  "anyOf": [
                                    {
                                      "type": "number"
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "id": {
                                  "type": "string"
                                },
                                "kind": {
                                  "type": "string"
                                },
                                "name": {
                                  "anyOf": [
                                    {
                                      "type": "string"
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "thumbnail_url": {
                                  "anyOf": [
                                    {
                                      "type": "string"
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "url": {
                                  "type": "string"
                                },
                                "width": {
                                  "anyOf": [
                                    {
                                      "type": "number"
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                }
                              }
                            }
                          },
                          "batch_id": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "completed_at": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "created_at": {
                            "type": "string"
                          },
                          "credits_charged": {
                            "anyOf": [
                              {
                                "type": "integer"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "credits_estimated": {
                            "type": "integer"
                          },
                          "error_message": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "id": {
                            "type": "string"
                          },
                          "input": {
                            "additionalProperties": false,
                            "type": "object",
                            "properties": {
                              "prompt": {
                                "anyOf": [
                                  {
                                    "type": "string"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "style": {
                                "anyOf": [
                                  {
                                    "type": "string"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              }
                            }
                          },
                          "result_asset_ids": {
                            "anyOf": [
                              {
                                "type": "array",
                                "items": {
                                  "type": "string"
                                }
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "settings": {
                            "additionalProperties": false,
                            "type": "object",
                            "properties": {
                              "aspect_ratio": {
                                "anyOf": [
                                  {
                                    "type": "string",
                                    "enum": [
                                      "9:16"
                                    ]
                                  },
                                  {
                                    "type": "string",
                                    "enum": [
                                      "1:1"
                                    ]
                                  },
                                  {
                                    "type": "string",
                                    "enum": [
                                      "4:5"
                                    ]
                                  },
                                  {
                                    "type": "string",
                                    "enum": [
                                      "16:9"
                                    ]
                                  },
                                  {
                                    "type": "string",
                                    "enum": [
                                      "3:4"
                                    ]
                                  }
                                ]
                              },
                              "estimated_cost_cents": {
                                "type": "number"
                              },
                              "num_variants": {
                                "type": "integer"
                              },
                              "resolution": {
                                "anyOf": [
                                  {
                                    "type": "string",
                                    "enum": [
                                      "720p"
                                    ]
                                  },
                                  {
                                    "type": "string",
                                    "enum": [
                                      "1080p"
                                    ]
                                  }
                                ]
                              },
                              "style": {
                                "anyOf": [
                                  {
                                    "type": "string"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              }
                            }
                          },
                          "status": {
                            "anyOf": [
                              {
                                "type": "string",
                                "enum": [
                                  "queued"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "processing"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "completed"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "failed"
                                ]
                              }
                            ]
                          }
                        }
                      }
                    },
                    "next_cursor": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      },
      "delete": {
        "operationId": "creativeHubDeleteCinematicImageGenerations",
        "summary": "Delete cinematic image generations",
        "tags": [
          "creative-hub",
          "creative-generation"
        ],
        "description": "Soft-deletes selected cinematic image generations for the authenticated user and soft-deletes their generated assets.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "ids"
                ],
                "properties": {
                  "ids": {
                    "minItems": 1,
                    "maxItems": 100,
                    "type": "array",
                    "items": {
                      "minLength": 1,
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "deleted"
                  ],
                  "properties": {
                    "deleted": {
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/creative-hub/image-studio/generations/{id}": {
      "get": {
        "operationId": "creativeHubGetCinematicImageGeneration",
        "summary": "Get cinematic image generation",
        "tags": [
          "creative-hub",
          "creative-generation"
        ],
        "description": "Returns one cinematic image generation for polling/detail views.",
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "assets",
                    "batch_id",
                    "completed_at",
                    "created_at",
                    "credits_charged",
                    "credits_estimated",
                    "error_message",
                    "id",
                    "input",
                    "result_asset_ids",
                    "settings",
                    "status"
                  ],
                  "properties": {
                    "assets": {
                      "type": "array",
                      "items": {
                        "additionalProperties": false,
                        "type": "object",
                        "required": [
                          "format",
                          "height",
                          "id",
                          "kind",
                          "name",
                          "thumbnail_url",
                          "url",
                          "width"
                        ],
                        "properties": {
                          "format": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "height": {
                            "anyOf": [
                              {
                                "type": "number"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "id": {
                            "type": "string"
                          },
                          "kind": {
                            "type": "string"
                          },
                          "name": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "thumbnail_url": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "url": {
                            "type": "string"
                          },
                          "width": {
                            "anyOf": [
                              {
                                "type": "number"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          }
                        }
                      }
                    },
                    "batch_id": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "completed_at": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "created_at": {
                      "type": "string"
                    },
                    "credits_charged": {
                      "anyOf": [
                        {
                          "type": "integer"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "credits_estimated": {
                      "type": "integer"
                    },
                    "error_message": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "id": {
                      "type": "string"
                    },
                    "input": {
                      "additionalProperties": false,
                      "type": "object",
                      "properties": {
                        "prompt": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "style": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        }
                      }
                    },
                    "result_asset_ids": {
                      "anyOf": [
                        {
                          "type": "array",
                          "items": {
                            "type": "string"
                          }
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "settings": {
                      "additionalProperties": false,
                      "type": "object",
                      "properties": {
                        "aspect_ratio": {
                          "anyOf": [
                            {
                              "type": "string",
                              "enum": [
                                "9:16"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "1:1"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "4:5"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "16:9"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "3:4"
                              ]
                            }
                          ]
                        },
                        "estimated_cost_cents": {
                          "type": "number"
                        },
                        "num_variants": {
                          "type": "integer"
                        },
                        "resolution": {
                          "anyOf": [
                            {
                              "type": "string",
                              "enum": [
                                "720p"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "1080p"
                              ]
                            }
                          ]
                        },
                        "style": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        }
                      }
                    },
                    "status": {
                      "anyOf": [
                        {
                          "type": "string",
                          "enum": [
                            "queued"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "processing"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "completed"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "failed"
                          ]
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/creative-hub/library/folders": {
      "get": {
        "operationId": "creativeHubListFolders",
        "summary": "List Creative Hub library folders",
        "tags": [
          "creative-hub",
          "creative-library"
        ],
        "description": "Lists Creative Hub library folders for the active team, optionally scoped to a parent folder for nested campaign or asset folders.",
        "parameters": [
          {
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "enum": [
                    "campaign"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "asset"
                  ]
                }
              ]
            },
            "in": "query",
            "name": "kind",
            "required": true
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "parent_id",
            "required": false
          },
          {
            "schema": {
              "maxLength": 200,
              "type": "string"
            },
            "in": "query",
            "name": "search",
            "required": false
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "items"
                  ],
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "id",
                          "name",
                          "kind",
                          "parent_id",
                          "created_at"
                        ],
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "name": {
                            "type": "string"
                          },
                          "kind": {
                            "type": "string"
                          },
                          "parent_id": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "created_at": {
                            "format": "date-time",
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "creativeHubCreateFolder",
        "summary": "Create a Creative Hub library folder",
        "tags": [
          "creative-hub",
          "creative-library"
        ],
        "description": "Creates a Creative Hub library folder in the active team. When parent_id is provided, the parent folder must exist in the same team and folder kind.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "kind",
                  "name"
                ],
                "properties": {
                  "kind": {
                    "anyOf": [
                      {
                        "type": "string",
                        "enum": [
                          "campaign"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "asset"
                        ]
                      }
                    ]
                  },
                  "name": {
                    "minLength": 1,
                    "maxLength": 200,
                    "type": "string"
                  },
                  "parent_id": {
                    "anyOf": [
                      {
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "201": {
            "description": "Resource created",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "id",
                    "name",
                    "kind",
                    "parent_id",
                    "created_at"
                  ],
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "name": {
                      "type": "string"
                    },
                    "kind": {
                      "type": "string"
                    },
                    "parent_id": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "created_at": {
                      "format": "date-time",
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/creative-hub/library/folders/{id}": {
      "patch": {
        "operationId": "creativeHubRenameFolder",
        "summary": "Rename a Creative Hub library folder",
        "tags": [
          "creative-hub",
          "creative-library"
        ],
        "description": "Renames a Creative Hub library folder in the active team. Returns 404 when the folder does not exist or is outside the caller scope.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "name"
                ],
                "properties": {
                  "name": {
                    "minLength": 1,
                    "maxLength": 200,
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "204": {
            "description": "No content"
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      },
      "delete": {
        "operationId": "creativeHubDeleteFolder",
        "summary": "Delete a Creative Hub library folder",
        "tags": [
          "creative-hub",
          "creative-library"
        ],
        "description": "Soft-deletes a Creative Hub library folder in the active team. Returns 404 when the folder does not exist or is outside the caller scope.",
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "204": {
            "description": "No content"
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/creative-hub/library/assets": {
      "get": {
        "operationId": "creativeHubListAssets",
        "summary": "List Creative Hub library assets",
        "tags": [
          "creative-hub",
          "creative-library"
        ],
        "description": "Lists Creative Hub assets for the active team with optional kind, folder and search filters. Results are cursor-paginated.",
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "kinds",
            "required": false
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "folder_id",
            "required": false
          },
          {
            "schema": {
              "maxLength": 200,
              "type": "string"
            },
            "in": "query",
            "name": "search",
            "required": false
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "cursor",
            "required": false
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "items",
                    "next_cursor"
                  ],
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "additionalProperties": false,
                        "type": "object",
                        "required": [
                          "id",
                          "name",
                          "kind",
                          "url",
                          "thumbnail_url",
                          "format",
                          "width",
                          "height",
                          "duration",
                          "size_bytes",
                          "folder_id",
                          "source",
                          "provider",
                          "metadata",
                          "created_at"
                        ],
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "name": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "kind": {
                            "type": "string"
                          },
                          "url": {
                            "type": "string"
                          },
                          "thumbnail_url": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "format": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "width": {
                            "anyOf": [
                              {
                                "type": "integer"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "height": {
                            "anyOf": [
                              {
                                "type": "integer"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "duration": {
                            "anyOf": [
                              {
                                "type": "number"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "size_bytes": {
                            "anyOf": [
                              {
                                "type": "integer"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "folder_id": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "source": {
                            "type": "string"
                          },
                          "provider": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "metadata": {
                            "description": "JSON object with nested arrays and objects.",
                            "type": "object",
                            "additionalProperties": {
                              "$comment": "json-value",
                              "description": "Arbitrary JSON value with nested arrays and objects."
                            }
                          },
                          "created_at": {
                            "format": "date-time",
                            "type": "string"
                          }
                        }
                      }
                    },
                    "next_cursor": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/creative-hub/library/assets/upload": {
      "post": {
        "operationId": "creativeHubUploadAsset",
        "summary": "Upload an asset into the Creative Hub library",
        "tags": [
          "creative-hub",
          "creative-library"
        ],
        "description": "Uploads one image, video or audio file into the active team library, validates MIME type and magic bytes where supported, and returns the created asset record.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "201": {
            "description": "Resource created",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "id",
                    "name",
                    "kind",
                    "url",
                    "thumbnail_url",
                    "format",
                    "width",
                    "height",
                    "duration",
                    "size_bytes",
                    "folder_id",
                    "source",
                    "provider",
                    "metadata",
                    "created_at"
                  ],
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "name": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "kind": {
                      "type": "string"
                    },
                    "url": {
                      "type": "string"
                    },
                    "thumbnail_url": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "format": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "width": {
                      "anyOf": [
                        {
                          "type": "integer"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "height": {
                      "anyOf": [
                        {
                          "type": "integer"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "duration": {
                      "anyOf": [
                        {
                          "type": "number"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "size_bytes": {
                      "anyOf": [
                        {
                          "type": "integer"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "folder_id": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "source": {
                      "type": "string"
                    },
                    "provider": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "metadata": {
                      "description": "JSON object with nested arrays and objects.",
                      "type": "object",
                      "additionalProperties": {
                        "$comment": "json-value",
                        "description": "Arbitrary JSON value with nested arrays and objects."
                      }
                    },
                    "created_at": {
                      "format": "date-time",
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "413": {
            "description": "Payload too large",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "415": {
            "description": "Response 415",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        },
        "requestBody": {
          "content": {
            "multipart/form-data": {
              "schema": {
                "type": "object",
                "required": [
                  "file"
                ],
                "properties": {
                  "file": {
                    "type": "string",
                    "format": "binary",
                    "description": "Image, video, or audio asset."
                  }
                },
                "additionalProperties": false
              }
            }
          }
        }
      }
    },
    "/api/v1/creative-hub/library/assets/import": {
      "post": {
        "operationId": "creativeHubImportAsset",
        "summary": "Import an existing creative URL into the library",
        "tags": [
          "creative-hub",
          "creative-library"
        ],
        "description": "Registers an already generated or externally hosted creative URL as a Creative Hub library asset for the active team.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "source_url",
                  "kind"
                ],
                "properties": {
                  "source_url": {
                    "minLength": 1,
                    "type": "string"
                  },
                  "kind": {
                    "anyOf": [
                      {
                        "type": "string",
                        "enum": [
                          "image"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "video"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "audio"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "voiceover"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "rich_media"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "avatar"
                        ]
                      }
                    ]
                  },
                  "name": {
                    "maxLength": 200,
                    "type": "string"
                  },
                  "generation_id": {
                    "anyOf": [
                      {
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "provider": {
                    "anyOf": [
                      {
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "rehost": {
                    "type": "boolean"
                  },
                  "folder_id": {
                    "anyOf": [
                      {
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "201": {
            "description": "Resource created",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "id",
                    "name",
                    "kind",
                    "url",
                    "thumbnail_url",
                    "format",
                    "width",
                    "height",
                    "duration",
                    "size_bytes",
                    "folder_id",
                    "source",
                    "provider",
                    "metadata",
                    "created_at"
                  ],
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "name": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "kind": {
                      "type": "string"
                    },
                    "url": {
                      "type": "string"
                    },
                    "thumbnail_url": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "format": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "width": {
                      "anyOf": [
                        {
                          "type": "integer"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "height": {
                      "anyOf": [
                        {
                          "type": "integer"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "duration": {
                      "anyOf": [
                        {
                          "type": "number"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "size_bytes": {
                      "anyOf": [
                        {
                          "type": "integer"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "folder_id": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "source": {
                      "type": "string"
                    },
                    "provider": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "metadata": {
                      "description": "JSON object with nested arrays and objects.",
                      "type": "object",
                      "additionalProperties": {
                        "$comment": "json-value",
                        "description": "Arbitrary JSON value with nested arrays and objects."
                      }
                    },
                    "created_at": {
                      "format": "date-time",
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/creative-hub/library/assets/{id}": {
      "patch": {
        "operationId": "creativeHubRenameAsset",
        "summary": "Rename a Creative Hub library asset",
        "tags": [
          "creative-hub",
          "creative-library"
        ],
        "description": "Renames one Creative Hub library asset in the active team. Returns 404 when the asset does not exist or is outside the caller scope.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "name"
                ],
                "properties": {
                  "name": {
                    "minLength": 1,
                    "maxLength": 200,
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "204": {
            "description": "No content"
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/creative-hub/library/assets/move": {
      "post": {
        "operationId": "creativeHubMoveAssets",
        "summary": "Move Creative Hub library assets",
        "tags": [
          "creative-hub",
          "creative-library"
        ],
        "description": "Moves one or more Creative Hub library assets into another folder, or to the library root when folder_id is null.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "ids",
                  "folder_id"
                ],
                "properties": {
                  "ids": {
                    "minItems": 1,
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  },
                  "folder_id": {
                    "anyOf": [
                      {
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "moved"
                  ],
                  "properties": {
                    "moved": {
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/creative-hub/library/assets/delete": {
      "post": {
        "operationId": "creativeHubDeleteAssets",
        "summary": "Delete Creative Hub library assets",
        "tags": [
          "creative-hub",
          "creative-library"
        ],
        "description": "Soft-deletes one or more Creative Hub library assets in the active team.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "ids"
                ],
                "properties": {
                  "ids": {
                    "minItems": 1,
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "deleted"
                  ],
                  "properties": {
                    "deleted": {
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/creative-hub/library/assets/{id}/save-to-drive": {
      "post": {
        "operationId": "creativeHubSaveAssetToDrive",
        "summary": "Save a Creative Hub library asset into the caller's Drive folder",
        "tags": [
          "creative-hub",
          "creative-library"
        ],
        "description": "Copies a Creative Hub library asset into the current user's personal Google Drive folder, provisioning that folder on first use. Returns the created Drive file.",
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "file"
                  ],
                  "properties": {
                    "file": {
                      "type": "object",
                      "required": [
                        "id",
                        "name",
                        "mimeType",
                        "size",
                        "createdTime",
                        "modifiedTime",
                        "thumbnailUrl",
                        "contentUrl",
                        "viewUrl",
                        "downloadUrl",
                        "isVideo",
                        "isImage",
                        "isFolder",
                        "parents"
                      ],
                      "properties": {
                        "id": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "name": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "mimeType": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "size": {
                          "type": "integer"
                        },
                        "createdTime": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "modifiedTime": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "thumbnailUrl": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "contentUrl": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "viewUrl": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "downloadUrl": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "isVideo": {
                          "type": "boolean"
                        },
                        "isImage": {
                          "type": "boolean"
                        },
                        "isFolder": {
                          "type": "boolean"
                        },
                        "parents": {
                          "anyOf": [
                            {
                              "type": "array",
                              "items": {
                                "type": "string"
                              }
                            },
                            {
                              "type": "null"
                            }
                          ]
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/creative-hub/thumbnail/{fileId}": {
      "get": {
        "operationId": "creativeHubThumbnail",
        "summary": "Proxy thumbnail image from Google Drive (images) or S3 cache (videos)",
        "tags": [
          "creative-hub"
        ],
        "description": "Serves a thumbnail for a Drive file as raw image bytes, gated on a signed capability token (?cap=) bound to the fileId. Uses in-memory cache, then S3 cache for videos, then Drive thumbnail link for images. Response body is binary image data (image/jpeg or image/png); error responses are JSON.",
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "cap",
            "required": false,
            "description": "Required signed, expiring capability token bound to this fileId and the issuing tenant. Minted by the authenticated Creative Hub file list/library responses or the media-capabilities endpoint. Missing/invalid/expired/wrong-file tokens are rejected with 403."
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "path",
            "name": "fileId",
            "required": true
          }
        ],
        "responses": {
          "200": {
            "description": "Drive file thumbnail image.",
            "content": {
              "image/jpeg": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              },
              "image/png": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ]
      }
    },
    "/api/v1/creative-hub/files/{fileId}/content": {
      "get": {
        "operationId": "creativeHubFileContent",
        "summary": "Stream file content for preview (supports Range requests for video)",
        "tags": [
          "creative-hub"
        ],
        "description": "Proxies file content from Google Drive for browser preview as a streamed body, gated on a signed capability token (?cap=) bound to the fileId. Supports HTTP Range requests for video seeking (returns 206 Partial Content with Content-Range header). Response body is the raw file stream with the file's original Content-Type; error responses are JSON.",
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "cap",
            "required": false,
            "description": "Required signed, expiring capability token bound to this fileId and the issuing tenant. Minted by the authenticated Creative Hub file list/library responses or the media-capabilities endpoint. Missing/invalid/expired/wrong-file tokens are rejected with 403."
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "path",
            "name": "fileId",
            "required": true
          }
        ],
        "responses": {
          "200": {
            "description": "Drive file content stream. Honors Range requests (returns 206 Partial Content with Content-Range for video seeking). Content-Type matches the original file.",
            "content": {
              "application/octet-stream": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              },
              "video/*": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              },
              "image/*": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              }
            }
          },
          "206": {
            "description": "Drive file content stream. Honors Range requests (returns 206 Partial Content with Content-Range for video seeking). Content-Type matches the original file. Partial content response for HTTP Range requests.",
            "content": {
              "application/octet-stream": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              },
              "video/*": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              },
              "image/*": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ]
      }
    },
    "/api/v1/creative-hub/products": {
      "get": {
        "operationId": "getApiV1CreativeHubProducts",
        "summary": "List Creative Hub products",
        "tags": [
          "creative-hub"
        ],
        "description": "Returns the active workspace scope team product catalog for Creative Hub generation flows.",
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "q",
            "required": false
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "items"
                  ],
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "additionalProperties": false,
                        "type": "object",
                        "required": [
                          "id",
                          "team_id",
                          "created_by",
                          "name",
                          "description",
                          "source",
                          "external_ref",
                          "image_url",
                          "images",
                          "price",
                          "currency",
                          "metadata",
                          "created_at",
                          "updated_at",
                          "deleted_at"
                        ],
                        "properties": {
                          "id": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "team_id": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "created_by": {
                            "anyOf": [
                              {
                                "format": "uuid",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "name": {
                            "type": "string"
                          },
                          "description": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "source": {
                            "type": "string"
                          },
                          "external_ref": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "image_url": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "images": {
                            "type": "array",
                            "items": {
                              "type": "string"
                            }
                          },
                          "price": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "currency": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "metadata": {
                            "type": "object",
                            "additionalProperties": {
                              "$comment": "json-value"
                            }
                          },
                          "created_at": {
                            "format": "date-time",
                            "type": "string"
                          },
                          "updated_at": {
                            "format": "date-time",
                            "type": "string"
                          },
                          "deleted_at": {
                            "anyOf": [
                              {
                                "format": "date-time",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "postApiV1CreativeHubProducts",
        "summary": "Create Creative Hub product",
        "tags": [
          "creative-hub"
        ],
        "description": "Creates a product entry in the active workspace scope team catalog.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "name"
                ],
                "properties": {
                  "name": {
                    "minLength": 1,
                    "maxLength": 200,
                    "type": "string"
                  },
                  "description": {
                    "anyOf": [
                      {
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "source": {
                    "anyOf": [
                      {
                        "type": "string",
                        "enum": [
                          "shopify"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "url"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "manual"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "feed"
                        ]
                      }
                    ]
                  },
                  "external_ref": {
                    "anyOf": [
                      {
                        "maxLength": 300,
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "image_url": {
                    "anyOf": [
                      {
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "images": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  },
                  "price": {
                    "anyOf": [
                      {
                        "maxLength": 60,
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "metadata": {
                    "type": "object",
                    "additionalProperties": {
                      "$comment": "json-value"
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "201": {
            "description": "Resource created",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "id",
                    "team_id",
                    "created_by",
                    "name",
                    "description",
                    "source",
                    "external_ref",
                    "image_url",
                    "images",
                    "price",
                    "currency",
                    "metadata",
                    "created_at",
                    "updated_at",
                    "deleted_at"
                  ],
                  "properties": {
                    "id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "team_id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "created_by": {
                      "anyOf": [
                        {
                          "format": "uuid",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "name": {
                      "type": "string"
                    },
                    "description": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "source": {
                      "type": "string"
                    },
                    "external_ref": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "image_url": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "images": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "price": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "currency": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "metadata": {
                      "type": "object",
                      "additionalProperties": {
                        "$comment": "json-value"
                      }
                    },
                    "created_at": {
                      "format": "date-time",
                      "type": "string"
                    },
                    "updated_at": {
                      "format": "date-time",
                      "type": "string"
                    },
                    "deleted_at": {
                      "anyOf": [
                        {
                          "format": "date-time",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/creative-hub/products/{id}": {
      "patch": {
        "operationId": "patchApiV1CreativeHubProductsById",
        "summary": "Update Creative Hub product",
        "tags": [
          "creative-hub"
        ],
        "description": "Updates a product entry in the active workspace scope team catalog.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "properties": {
                  "name": {
                    "minLength": 1,
                    "maxLength": 200,
                    "type": "string"
                  },
                  "description": {
                    "anyOf": [
                      {
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "source": {
                    "anyOf": [
                      {
                        "type": "string",
                        "enum": [
                          "shopify"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "url"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "manual"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "feed"
                        ]
                      }
                    ]
                  },
                  "external_ref": {
                    "anyOf": [
                      {
                        "maxLength": 300,
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "image_url": {
                    "anyOf": [
                      {
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "images": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  },
                  "price": {
                    "anyOf": [
                      {
                        "maxLength": 60,
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "metadata": {
                    "type": "object",
                    "additionalProperties": {
                      "$comment": "json-value"
                    }
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "id",
                    "team_id",
                    "created_by",
                    "name",
                    "description",
                    "source",
                    "external_ref",
                    "image_url",
                    "images",
                    "price",
                    "currency",
                    "metadata",
                    "created_at",
                    "updated_at",
                    "deleted_at"
                  ],
                  "properties": {
                    "id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "team_id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "created_by": {
                      "anyOf": [
                        {
                          "format": "uuid",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "name": {
                      "type": "string"
                    },
                    "description": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "source": {
                      "type": "string"
                    },
                    "external_ref": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "image_url": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "images": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "price": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "currency": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "metadata": {
                      "type": "object",
                      "additionalProperties": {
                        "$comment": "json-value"
                      }
                    },
                    "created_at": {
                      "format": "date-time",
                      "type": "string"
                    },
                    "updated_at": {
                      "format": "date-time",
                      "type": "string"
                    },
                    "deleted_at": {
                      "anyOf": [
                        {
                          "format": "date-time",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      },
      "delete": {
        "operationId": "deleteApiV1CreativeHubProductsById",
        "summary": "Delete Creative Hub product",
        "tags": [
          "creative-hub"
        ],
        "description": "Soft-deletes a product entry from the active workspace scope team catalog.",
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "204": {
            "description": "No content"
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/creative-hub/products/import-url": {
      "post": {
        "operationId": "postApiV1CreativeHubProductsImportUrl",
        "summary": "Preview product import from URL",
        "tags": [
          "creative-hub"
        ],
        "description": "Scrapes a product URL and returns a non-persisted product preview for user confirmation.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "url"
                ],
                "properties": {
                  "url": {
                    "minLength": 4,
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "name",
                    "description",
                    "source",
                    "external_ref",
                    "image_url",
                    "images",
                    "price",
                    "metadata"
                  ],
                  "properties": {
                    "name": {
                      "type": "string"
                    },
                    "description": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "source": {
                      "type": "string",
                      "enum": [
                        "url"
                      ]
                    },
                    "external_ref": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "image_url": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "images": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "price": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "metadata": {
                      "type": "object",
                      "additionalProperties": {
                        "$comment": "json-value"
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "422": {
            "description": "Unprocessable entity - semantic validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/creative-hub/products/import-feed": {
      "post": {
        "operationId": "postApiV1CreativeHubProductsImportFeed",
        "summary": "Import products from CSV feed",
        "tags": [
          "creative-hub"
        ],
        "description": "Parses and imports product rows from a CSV feed into the active workspace scope team catalog.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "csv"
                ],
                "properties": {
                  "csv": {
                    "minLength": 1,
                    "maxLength": 2000000,
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "201": {
            "description": "Resource created",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "imported"
                  ],
                  "properties": {
                    "imported": {
                      "minimum": 0,
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "422": {
            "description": "Unprocessable entity - semantic validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/creative-hub/projects": {
      "get": {
        "operationId": "creativeHubListProjects",
        "summary": "List Creative Hub editor projects",
        "tags": [
          "creative-hub",
          "creative-editors"
        ],
        "description": "Lists video-editor / rich-media projects for the active team (paginated by created_at cursor).",
        "parameters": [
          {
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "enum": [
                    "video_editor"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "rich_media"
                  ]
                }
              ]
            },
            "in": "query",
            "name": "kind",
            "required": false
          },
          {
            "schema": {
              "minimum": 1,
              "maximum": 100,
              "default": 30,
              "type": "integer"
            },
            "in": "query",
            "name": "limit",
            "required": false
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "cursor",
            "required": false
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "items",
                    "next_cursor"
                  ],
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "id",
                          "kind",
                          "name",
                          "status",
                          "document",
                          "export_asset_ids",
                          "thumbnail_url",
                          "created_at",
                          "updated_at"
                        ],
                        "properties": {
                          "id": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "kind": {
                            "type": "string"
                          },
                          "name": {
                            "type": "string"
                          },
                          "status": {
                            "type": "string"
                          },
                          "document": {
                            "$comment": "json-value",
                            "description": "Arbitrary JSON value with nested arrays and objects."
                          },
                          "export_asset_ids": {
                            "type": "array",
                            "items": {
                              "type": "string"
                            }
                          },
                          "thumbnail_url": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "created_at": {
                            "format": "date-time",
                            "type": "string"
                          },
                          "updated_at": {
                            "format": "date-time",
                            "type": "string"
                          }
                        }
                      }
                    },
                    "next_cursor": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "creativeHubCreateProject",
        "summary": "Create a Creative Hub editor project",
        "tags": [
          "creative-hub",
          "creative-editors"
        ],
        "description": "Creates a video-editor or rich-media project for the active team and stores the optional editor document JSON envelope.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "kind",
                  "name"
                ],
                "properties": {
                  "kind": {
                    "anyOf": [
                      {
                        "type": "string",
                        "enum": [
                          "video_editor"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "rich_media"
                        ]
                      }
                    ]
                  },
                  "name": {
                    "minLength": 1,
                    "maxLength": 255,
                    "type": "string"
                  },
                  "document": {
                    "anyOf": [
                      {
                        "description": "JSON object with nested arrays and objects.",
                        "type": "object",
                        "additionalProperties": {
                          "$comment": "json-value",
                          "description": "Arbitrary JSON value with nested arrays and objects."
                        }
                      },
                      {
                        "type": "null"
                      }
                    ]
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "201": {
            "description": "Resource created",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "id",
                    "kind",
                    "name",
                    "status",
                    "document",
                    "export_asset_ids",
                    "thumbnail_url",
                    "created_at",
                    "updated_at"
                  ],
                  "properties": {
                    "id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "kind": {
                      "type": "string"
                    },
                    "name": {
                      "type": "string"
                    },
                    "status": {
                      "type": "string"
                    },
                    "document": {
                      "$comment": "json-value",
                      "description": "Arbitrary JSON value with nested arrays and objects."
                    },
                    "export_asset_ids": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "thumbnail_url": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "created_at": {
                      "format": "date-time",
                      "type": "string"
                    },
                    "updated_at": {
                      "format": "date-time",
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/creative-hub/projects/{id}": {
      "get": {
        "operationId": "creativeHubGetProject",
        "summary": "Get a Creative Hub editor project",
        "tags": [
          "creative-hub",
          "creative-editors"
        ],
        "description": "Returns one video-editor or rich-media project owned by an accessible team, including the saved editor document JSON.",
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "id",
                    "kind",
                    "name",
                    "status",
                    "document",
                    "export_asset_ids",
                    "thumbnail_url",
                    "created_at",
                    "updated_at"
                  ],
                  "properties": {
                    "id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "kind": {
                      "type": "string"
                    },
                    "name": {
                      "type": "string"
                    },
                    "status": {
                      "type": "string"
                    },
                    "document": {
                      "$comment": "json-value",
                      "description": "Arbitrary JSON value with nested arrays and objects."
                    },
                    "export_asset_ids": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "thumbnail_url": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "created_at": {
                      "format": "date-time",
                      "type": "string"
                    },
                    "updated_at": {
                      "format": "date-time",
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      },
      "patch": {
        "operationId": "creativeHubUpdateProject",
        "summary": "Update a Creative Hub editor project (name / document / thumbnail)",
        "tags": [
          "creative-hub",
          "creative-editors"
        ],
        "description": "Updates mutable project fields for a video-editor or rich-media project, preserving team ownership and returning the saved project.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "properties": {
                  "name": {
                    "minLength": 1,
                    "maxLength": 255,
                    "type": "string"
                  },
                  "document": {
                    "anyOf": [
                      {
                        "description": "JSON object with nested arrays and objects.",
                        "type": "object",
                        "additionalProperties": {
                          "$comment": "json-value",
                          "description": "Arbitrary JSON value with nested arrays and objects."
                        }
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "thumbnail_url": {
                    "anyOf": [
                      {
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "id",
                    "kind",
                    "name",
                    "status",
                    "document",
                    "export_asset_ids",
                    "thumbnail_url",
                    "created_at",
                    "updated_at"
                  ],
                  "properties": {
                    "id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "kind": {
                      "type": "string"
                    },
                    "name": {
                      "type": "string"
                    },
                    "status": {
                      "type": "string"
                    },
                    "document": {
                      "$comment": "json-value",
                      "description": "Arbitrary JSON value with nested arrays and objects."
                    },
                    "export_asset_ids": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "thumbnail_url": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "created_at": {
                      "format": "date-time",
                      "type": "string"
                    },
                    "updated_at": {
                      "format": "date-time",
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      },
      "delete": {
        "operationId": "creativeHubDeleteProject",
        "summary": "Soft-delete a Creative Hub editor project",
        "tags": [
          "creative-hub",
          "creative-editors"
        ],
        "description": "Soft-deletes one accessible Creative Hub editor project. The project is hidden from subsequent list and get calls.",
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "204": {
            "description": "No content"
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/creative-hub/projects/{id}/export": {
      "post": {
        "operationId": "creativeHubExportProject",
        "summary": "Link exported creative_asset ids to a project and mark it exported",
        "tags": [
          "creative-hub",
          "creative-editors"
        ],
        "description": "Records already produced Creative Hub asset IDs on a project and returns the updated project marked as exported.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "asset_ids"
                ],
                "properties": {
                  "asset_ids": {
                    "minItems": 1,
                    "type": "array",
                    "items": {
                      "format": "uuid",
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "id",
                    "kind",
                    "name",
                    "status",
                    "document",
                    "export_asset_ids",
                    "thumbnail_url",
                    "created_at",
                    "updated_at"
                  ],
                  "properties": {
                    "id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "kind": {
                      "type": "string"
                    },
                    "name": {
                      "type": "string"
                    },
                    "status": {
                      "type": "string"
                    },
                    "document": {
                      "$comment": "json-value",
                      "description": "Arbitrary JSON value with nested arrays and objects."
                    },
                    "export_asset_ids": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "thumbnail_url": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "created_at": {
                      "format": "date-time",
                      "type": "string"
                    },
                    "updated_at": {
                      "format": "date-time",
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/creative-hub/share": {
      "post": {
        "operationId": "creativeHubShare",
        "summary": "Share user folder with a Gmail/Workspace account",
        "tags": [
          "creative-hub"
        ],
        "description": "Grants writer access to the user's Drive folder for the specified email and saves the sharing record. Returns a localized message and the updated list of authorized emails.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "email"
                ],
                "properties": {
                  "email": {
                    "format": "email",
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "message",
                    "emails"
                  ],
                  "properties": {
                    "message": {
                      "type": "string"
                    },
                    "emails": {
                      "type": "array",
                      "items": {
                        "format": "email",
                        "type": "string"
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "Too many requests - rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/creative-hub/unshare": {
      "post": {
        "operationId": "creativeHubUnshare",
        "summary": "Remove sharing access for a Gmail/Workspace account",
        "tags": [
          "creative-hub"
        ],
        "description": "Revokes Drive folder access for the specified email and removes the sharing record. Returns a localized message and the updated list of remaining authorized emails.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "email"
                ],
                "properties": {
                  "email": {
                    "format": "email",
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "message",
                    "emails"
                  ],
                  "properties": {
                    "message": {
                      "type": "string"
                    },
                    "emails": {
                      "type": "array",
                      "items": {
                        "format": "email",
                        "type": "string"
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/creative-hub/shared-emails": {
      "get": {
        "operationId": "creativeHubListSharedEmails",
        "summary": "Get list of emails with access to user folder",
        "tags": [
          "creative-hub"
        ],
        "description": "Returns the list of email addresses that currently have access to the user's Drive folder.",
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "emails"
                  ],
                  "properties": {
                    "emails": {
                      "type": "array",
                      "items": {
                        "format": "email",
                        "type": "string"
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/creative-hub/subtitles/estimate": {
      "get": {
        "operationId": "creativeHubEstimateSubtitles",
        "summary": "Estimate subtitle generation credits",
        "tags": [
          "creative-hub",
          "creative-generation"
        ],
        "description": "Returns the credit estimate for burning subtitles into a video (transcription is billed per second). Pass asset_id to price an uploaded team video asset: when that asset carries a recorded duration the estimate reads it, which is the same value the generation hold uses. Otherwise the estimate echoes the declared duration_seconds — asset_id never turns a successful estimate into an error.",
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "query",
            "name": "asset_id",
            "required": false
          },
          {
            "schema": {
              "minimum": 1,
              "maximum": 600,
              "type": "number"
            },
            "in": "query",
            "name": "duration_seconds",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "duration_seconds",
                    "estimated_credits"
                  ],
                  "properties": {
                    "duration_seconds": {
                      "type": "integer"
                    },
                    "estimated_credits": {
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/creative-hub/subtitles/generate": {
      "post": {
        "operationId": "creativeHubGenerateSubtitles",
        "summary": "Burn subtitles into an uploaded video",
        "tags": [
          "creative-hub",
          "creative-generation"
        ],
        "description": "Starts an asynchronous subtitle generation for a team video asset: the audio track is transcribed with Whisper, optionally translated to the requested language, and burned into the video. Returns a polling handle for GET /creative-hub/generations/{id}.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "asset_id",
                  "duration_seconds"
                ],
                "properties": {
                  "asset_id": {
                    "format": "uuid",
                    "type": "string"
                  },
                  "duration_seconds": {
                    "minimum": 1,
                    "maximum": 600,
                    "type": "number"
                  },
                  "language": {
                    "maxLength": 32,
                    "type": "string"
                  },
                  "text_color": {
                    "pattern": "^#[0-9a-fA-F]{6}$",
                    "type": "string"
                  },
                  "position": {
                    "anyOf": [
                      {
                        "type": "string",
                        "enum": [
                          "top"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "middle"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "bottom"
                        ]
                      }
                    ]
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "202": {
            "description": "Accepted - processing asynchronously",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "generation_id",
                    "status",
                    "estimated_credits",
                    "polling_interval_ms"
                  ],
                  "properties": {
                    "generation_id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "status": {
                      "type": "string",
                      "enum": [
                        "queued"
                      ]
                    },
                    "estimated_credits": {
                      "type": "integer"
                    },
                    "polling_interval_ms": {
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "402": {
            "description": "Response 402",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "Too many requests - rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "Service unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/creative-hub/credits": {
      "get": {
        "operationId": "creativeHubGetCredits",
        "summary": "Creative Hub credit balance",
        "tags": [
          "creative-hub"
        ],
        "description": "Returns spendable AI credits for Creative Hub generation, including purchased credits and weekly grant credits.",
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "balance",
                    "grant_balance",
                    "monthly_cap",
                    "monthly_used",
                    "spendable",
                    "total_purchased",
                    "total_used"
                  ],
                  "properties": {
                    "balance": {
                      "type": "number"
                    },
                    "grant_balance": {
                      "type": "number"
                    },
                    "monthly_cap": {
                      "anyOf": [
                        {
                          "type": "number"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "monthly_used": {
                      "type": "number"
                    },
                    "spendable": {
                      "type": "number"
                    },
                    "total_purchased": {
                      "type": "number"
                    },
                    "total_used": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/creative-hub/ugc/products/upload": {
      "post": {
        "operationId": "creativeHubUploadUgcProductImage",
        "summary": "Upload a product image for UGC product-hand mode",
        "tags": [
          "creative-hub",
          "creative-generation"
        ],
        "description": "Uploads one JPEG, PNG or WebP product image for the UGC product-hand generation mode and stores it in team-scoped creative asset storage.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "201": {
            "description": "Resource created",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "image_url",
                    "storage_key"
                  ],
                  "properties": {
                    "image_url": {
                      "type": "string"
                    },
                    "storage_key": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "413": {
            "description": "Payload too large",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        },
        "requestBody": {
          "content": {
            "multipart/form-data": {
              "schema": {
                "type": "object",
                "required": [
                  "file"
                ],
                "properties": {
                  "file": {
                    "type": "string",
                    "format": "binary",
                    "description": "JPEG, PNG, or WebP product image."
                  }
                },
                "additionalProperties": false
              }
            }
          }
        }
      }
    },
    "/api/v1/creative-hub/ugc/audio/upload": {
      "post": {
        "operationId": "creativeHubUploadUgcAudio",
        "summary": "Upload an audio track to the voiceover library",
        "tags": [
          "creative-hub",
          "creative-generation"
        ],
        "description": "Uploads one MP3 or WAV audio track into the team voiceover library (Voices page) and returns the stored URL plus a best-effort duration probe.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "201": {
            "description": "Resource created",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "audio_url",
                    "storage_key"
                  ],
                  "properties": {
                    "audio_url": {
                      "type": "string"
                    },
                    "duration_seconds": {
                      "type": "number"
                    },
                    "storage_key": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "413": {
            "description": "Payload too large",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        },
        "requestBody": {
          "content": {
            "multipart/form-data": {
              "schema": {
                "type": "object",
                "required": [
                  "file"
                ],
                "properties": {
                  "file": {
                    "type": "string",
                    "format": "binary",
                    "description": "MP3 or WAV audio track."
                  }
                },
                "additionalProperties": false
              }
            }
          }
        }
      }
    },
    "/api/v1/creative-hub/ugc/models": {
      "get": {
        "operationId": "creativeHubListUgcModels",
        "summary": "List available UGC avatar/lip-sync models and Marketing Studio generation modes",
        "tags": [
          "creative-hub",
          "creative-generation"
        ],
        "description": "Returns the curated UGC avatar/lip-sync model choices and the hardcoded Higgsfield Marketing Studio `mode` catalog (talking head, product review, how-to, unboxing, showcase) available to the composer.",
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "items",
                    "marketing_studio_modes"
                  ],
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "id",
                          "label",
                          "description",
                          "is_default"
                        ],
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "label": {
                            "type": "string"
                          },
                          "description": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "is_default": {
                            "type": "boolean"
                          }
                        }
                      }
                    },
                    "marketing_studio_modes": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "id",
                          "label",
                          "description",
                          "is_default"
                        ],
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "label": {
                            "type": "string"
                          },
                          "description": {
                            "type": "string"
                          },
                          "is_default": {
                            "type": "boolean"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/creative-hub/ugc/generate": {
      "post": {
        "operationId": "creativeHubGenerateUgc",
        "summary": "Generate a UGC video (async)",
        "tags": [
          "creative-hub",
          "creative-generation"
        ],
        "description": "Starts an asynchronous UGC video generation. When brand_kit_id is provided, the selected team Brand Kit is folded into the script, frame and motion prompt context.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "mode",
                  "settings"
                ],
                "properties": {
                  "mode": {
                    "anyOf": [
                      {
                        "type": "string",
                        "enum": [
                          "your_script"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "ai_script"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "product_hand"
                        ]
                      }
                    ]
                  },
                  "icp_type": {
                    "anyOf": [
                      {
                        "type": "string",
                        "enum": [
                          "ecom"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "affiliate"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "leadgen"
                        ]
                      }
                    ]
                  },
                  "avatar_id": {
                    "type": "string"
                  },
                  "brand_kit_id": {
                    "minLength": 1,
                    "maxLength": 100,
                    "type": "string"
                  },
                  "product_id": {
                    "type": "string"
                  },
                  "product_description": {
                    "maxLength": 2000,
                    "type": "string"
                  },
                  "script": {
                    "maxLength": 4000,
                    "type": "string"
                  },
                  "hook_key": {
                    "type": "string"
                  },
                  "product_image_url": {
                    "type": "string"
                  },
                  "settings": {
                    "type": "object",
                    "properties": {
                      "platform": {
                        "anyOf": [
                          {
                            "type": "string",
                            "enum": [
                              "meta"
                            ]
                          },
                          {
                            "type": "string",
                            "enum": [
                              "tiktok"
                            ]
                          },
                          {
                            "type": "string",
                            "enum": [
                              "instagram"
                            ]
                          },
                          {
                            "type": "string",
                            "enum": [
                              "youtube"
                            ]
                          }
                        ]
                      },
                      "format": {
                        "anyOf": [
                          {
                            "type": "string",
                            "enum": [
                              "9:16"
                            ]
                          },
                          {
                            "type": "string",
                            "enum": [
                              "1:1"
                            ]
                          },
                          {
                            "type": "string",
                            "enum": [
                              "4:5"
                            ]
                          },
                          {
                            "type": "string",
                            "enum": [
                              "16:9"
                            ]
                          }
                        ]
                      },
                      "resolution": {
                        "anyOf": [
                          {
                            "type": "string",
                            "enum": [
                              "480p"
                            ]
                          },
                          {
                            "type": "string",
                            "enum": [
                              "720p"
                            ]
                          },
                          {
                            "type": "string",
                            "enum": [
                              "1080p"
                            ]
                          }
                        ]
                      },
                      "language": {
                        "type": "string"
                      },
                      "captions": {
                        "type": "boolean"
                      },
                      "duration_seconds": {
                        "minimum": 3,
                        "maximum": 15,
                        "type": "integer"
                      },
                      "marketing_studio_mode": {
                        "anyOf": [
                          {
                            "type": "string",
                            "enum": [
                              "ugc"
                            ]
                          },
                          {
                            "type": "string",
                            "enum": [
                              "product_review"
                            ]
                          },
                          {
                            "type": "string",
                            "enum": [
                              "ugc_how_to"
                            ]
                          },
                          {
                            "type": "string",
                            "enum": [
                              "ugc_unboxing"
                            ]
                          },
                          {
                            "type": "string",
                            "enum": [
                              "product_showcase"
                            ]
                          }
                        ]
                      }
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "202": {
            "description": "Accepted - processing asynchronously",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "created_at",
                    "credits_estimated",
                    "estimated_cost_cents",
                    "generation_id",
                    "polling_interval_ms",
                    "status"
                  ],
                  "properties": {
                    "created_at": {
                      "type": "string"
                    },
                    "credits_estimated": {
                      "type": "integer"
                    },
                    "estimated_cost_cents": {
                      "type": "integer"
                    },
                    "generation_id": {
                      "type": "string"
                    },
                    "polling_interval_ms": {
                      "type": "integer"
                    },
                    "status": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "402": {
            "description": "Response 402",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "code",
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string",
                      "enum": [
                        "INSUFFICIENT_CREDITS"
                      ]
                    },
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "Too many requests - rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "Service unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/creative-hub/ugc/estimate": {
      "post": {
        "operationId": "creativeHubEstimateUgc",
        "summary": "Estimate UGC generation credit cost",
        "tags": [
          "creative-hub",
          "creative-generation"
        ],
        "description": "Returns the deterministic credit estimate for a UGC generation request without starting a provider job. The estimate is computed from the SAME resolved billing input the generate endpoint charges from, so it accounts for the two effects that used to make the charge exceed the quote: a spoken script longer than the requested duration extends the billable duration (up to 15s, reported as duration_source), and a product photo adds a product-description line. Supply script_word_count and has_product_image to get the exact amount that will be charged; omitting them yields the floor of that amount — and in that case credits_max is the ceiling the charge can never exceed for this request, so the guaranteed invariant is credits <= charged <= credits_max. script_word_count_declared says which of the two you are looking at.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "mode",
                  "duration_seconds"
                ],
                "properties": {
                  "mode": {
                    "anyOf": [
                      {
                        "type": "string",
                        "enum": [
                          "your_script"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "ai_script"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "product_hand"
                        ]
                      }
                    ]
                  },
                  "duration_seconds": {
                    "minimum": 3,
                    "maximum": 15,
                    "type": "integer"
                  },
                  "resolution": {
                    "anyOf": [
                      {
                        "type": "string",
                        "enum": [
                          "480p"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "720p"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "1080p"
                        ]
                      }
                    ]
                  },
                  "captions": {
                    "type": "boolean"
                  },
                  "has_product_image": {
                    "description": "Whether a product photo will be attached. It triggers a real product-description model call, so it raises the estimate. mode=product_hand implies true (the photo is mandatory there).",
                    "type": "boolean"
                  },
                  "script_word_count": {
                    "minimum": 0,
                    "maximum": 2000,
                    "description": "Word count of the user-supplied script (not the script itself — this endpoint performs no I/O and stores nothing). Used to detect a spoken duration longer than duration_seconds. Ignored for mode=ai_script, where the script is written to fit the requested duration.",
                    "type": "integer"
                  },
                  "model_id": {
                    "deprecated": true,
                    "description": "DEPRECATED and ignored: the UGC engine model is not caller-selectable. Kept so existing SDK clients that still send it do not start failing schema validation. It will be removed in a future major version.",
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "credits",
                    "credits_max",
                    "script_word_count_declared",
                    "breakdown",
                    "billable_seconds",
                    "duration_source",
                    "resolution_multiplier",
                    "pricing_version"
                  ],
                  "properties": {
                    "credits": {
                      "description": "Total credits that will be held and charged.",
                      "type": "integer"
                    },
                    "credits_max": {
                      "description": "Upper bound of what generate can charge for this exact request. It folds the only two inputs this endpoint cannot see: a spoken script that stretches the billable duration to the 15s product cap, and an attached product photo. Equal to credits when neither can apply.",
                      "type": "integer"
                    },
                    "script_word_count_declared": {
                      "description": "False when script_word_count was omitted (or 0) on a mode that can be extended by the spoken script: the quote is then a floor, not the exact charge. Always true for mode=ai_script, where the script is written to fit the requested duration and never extends it.",
                      "type": "boolean"
                    },
                    "breakdown": {
                      "description": "Per catalog line contribution to the total.",
                      "type": "array",
                      "items": {
                        "additionalProperties": false,
                        "type": "object",
                        "required": [
                          "model_id",
                          "retail_credits",
                          "unit",
                          "units"
                        ],
                        "properties": {
                          "model_id": {
                            "type": "string"
                          },
                          "retail_credits": {
                            "type": "integer"
                          },
                          "unit": {
                            "type": "string"
                          },
                          "units": {
                            "type": "number"
                          }
                        }
                      }
                    },
                    "billable_seconds": {
                      "description": "Seconds actually billed (minimum 8s, capped at 15s).",
                      "type": "integer"
                    },
                    "duration_source": {
                      "description": "extended_to_spoken means the spoken script is longer than the requested duration, so the billable duration was raised to fit it.",
                      "anyOf": [
                        {
                          "type": "string",
                          "enum": [
                            "requested"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "extended_to_spoken"
                          ]
                        }
                      ]
                    },
                    "resolution_multiplier": {
                      "type": "number"
                    },
                    "pricing_version": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/creative-hub/ugc/generations": {
      "get": {
        "operationId": "creativeHubListUgcGenerations",
        "summary": "List UGC video generations",
        "tags": [
          "creative-hub",
          "creative-generation"
        ],
        "description": "Returns paginated UGC video generation records for the authenticated user, including linked generated assets when available.",
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "batch_id",
            "required": false
          },
          {
            "schema": {
              "minimum": 1,
              "maximum": 100,
              "type": "integer"
            },
            "in": "query",
            "name": "limit",
            "required": false
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "cursor",
            "required": false
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "generations",
                    "next_cursor"
                  ],
                  "properties": {
                    "generations": {
                      "type": "array",
                      "items": {
                        "additionalProperties": false,
                        "type": "object",
                        "required": [
                          "id",
                          "mode",
                          "status",
                          "batch_id",
                          "settings",
                          "result_asset_ids",
                          "credits_estimated",
                          "credits_charged",
                          "error_message",
                          "created_at",
                          "completed_at",
                          "assets"
                        ],
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "mode": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "status": {
                            "type": "string"
                          },
                          "batch_id": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "settings": {
                            "$comment": "json-value",
                            "description": "Arbitrary JSON value with nested arrays and objects."
                          },
                          "result_asset_ids": {
                            "type": "array",
                            "items": {
                              "type": "string"
                            }
                          },
                          "credits_estimated": {
                            "type": "integer"
                          },
                          "credits_charged": {
                            "type": "integer"
                          },
                          "error_message": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "created_at": {
                            "format": "date-time",
                            "type": "string"
                          },
                          "completed_at": {
                            "anyOf": [
                              {
                                "format": "date-time",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "assets": {
                            "type": "array",
                            "items": {
                              "additionalProperties": false,
                              "type": "object",
                              "required": [
                                "id",
                                "kind",
                                "format",
                                "url",
                                "thumbnail_url",
                                "duration"
                              ],
                              "properties": {
                                "id": {
                                  "type": "string"
                                },
                                "kind": {
                                  "type": "string"
                                },
                                "format": {
                                  "anyOf": [
                                    {
                                      "type": "string"
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "url": {
                                  "type": "string"
                                },
                                "thumbnail_url": {
                                  "anyOf": [
                                    {
                                      "type": "string"
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "duration": {
                                  "anyOf": [
                                    {
                                      "type": "number"
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                }
                              }
                            }
                          }
                        }
                      }
                    },
                    "next_cursor": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/creative-hub/ugc/generations/{id}": {
      "get": {
        "operationId": "creativeHubGetUgcGeneration",
        "summary": "Get one UGC video generation",
        "tags": [
          "creative-hub",
          "creative-generation"
        ],
        "description": "Returns the current status, settings and generated assets for one UGC video generation owned by the authenticated user.",
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "id",
                    "mode",
                    "status",
                    "batch_id",
                    "settings",
                    "result_asset_ids",
                    "credits_estimated",
                    "credits_charged",
                    "error_message",
                    "created_at",
                    "completed_at",
                    "assets"
                  ],
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "mode": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "status": {
                      "type": "string"
                    },
                    "batch_id": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "settings": {
                      "$comment": "json-value",
                      "description": "Arbitrary JSON value with nested arrays and objects."
                    },
                    "result_asset_ids": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "credits_estimated": {
                      "type": "integer"
                    },
                    "credits_charged": {
                      "type": "integer"
                    },
                    "error_message": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "created_at": {
                      "format": "date-time",
                      "type": "string"
                    },
                    "completed_at": {
                      "anyOf": [
                        {
                          "format": "date-time",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "assets": {
                      "type": "array",
                      "items": {
                        "additionalProperties": false,
                        "type": "object",
                        "required": [
                          "id",
                          "kind",
                          "format",
                          "url",
                          "thumbnail_url",
                          "duration"
                        ],
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "kind": {
                            "type": "string"
                          },
                          "format": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "url": {
                            "type": "string"
                          },
                          "thumbnail_url": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "duration": {
                            "anyOf": [
                              {
                                "type": "number"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      },
      "delete": {
        "operationId": "creativeHubDeleteUgcGeneration",
        "summary": "Delete one UGC generation",
        "tags": [
          "creative-hub",
          "creative-generation"
        ],
        "description": "Soft-deletes one terminal UGC video generation owned by the authenticated user and soft-deletes any generated assets linked to it. Queued or processing generations cannot be deleted until they finish.",
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "assets_deleted",
                    "deleted"
                  ],
                  "properties": {
                    "assets_deleted": {
                      "type": "integer"
                    },
                    "deleted": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "Conflict - resource state prevents the operation",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/creative-hub/ugc/hooks": {
      "get": {
        "operationId": "creativeHubListUgcHooks",
        "summary": "List UGC script hooks",
        "tags": [
          "creative-hub",
          "creative-generation"
        ],
        "description": "Returns the curated script hook options for the requested ICP type, used by the UGC composer.",
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "icp_type",
            "required": false
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "hooks"
                  ],
                  "properties": {
                    "hooks": {
                      "type": "array",
                      "items": {
                        "additionalProperties": false,
                        "type": "object",
                        "required": [
                          "key",
                          "label"
                        ],
                        "properties": {
                          "key": {
                            "type": "string"
                          },
                          "label": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/creative-hub/video-editor/clips": {
      "get": {
        "operationId": "creativeHubListVideoEditorClips",
        "summary": "List team video clips available to the video editor",
        "tags": [
          "creative-hub",
          "creative-editors"
        ],
        "description": "Lists recent team-scoped Creative Hub video assets that can be selected as clips in the video editor timeline.",
        "parameters": [
          {
            "schema": {
              "minimum": 1,
              "maximum": 100,
              "default": 60,
              "type": "integer"
            },
            "in": "query",
            "name": "limit",
            "required": false
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "items"
                  ],
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "id",
                          "name",
                          "url",
                          "thumbnail_url",
                          "duration"
                        ],
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "name": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "url": {
                            "type": "string"
                          },
                          "thumbnail_url": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "duration": {
                            "anyOf": [
                              {
                                "type": "number"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/creative-hub/video-editor/render": {
      "post": {
        "operationId": "creativeHubRenderVideoEditor",
        "summary": "Concatenate selected clips into a single mp4 (sync)",
        "tags": [
          "creative-hub",
          "creative-editors"
        ],
        "description": "Synchronously renders the selected team video clips into a single MP4, stores the result as a Creative Hub asset and links it to a video-editor project.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "asset_ids"
                ],
                "properties": {
                  "asset_ids": {
                    "minItems": 1,
                    "maxItems": 30,
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  },
                  "title": {
                    "maxLength": 200,
                    "type": "string"
                  },
                  "music_url": {
                    "maxLength": 2000,
                    "type": "string"
                  },
                  "project_id": {
                    "format": "uuid",
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "asset",
                    "project_id"
                  ],
                  "properties": {
                    "asset": {
                      "type": "object",
                      "required": [
                        "id",
                        "url",
                        "thumbnail_url",
                        "duration"
                      ],
                      "properties": {
                        "id": {
                          "type": "string"
                        },
                        "url": {
                          "type": "string"
                        },
                        "thumbnail_url": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "duration": {
                          "anyOf": [
                            {
                              "type": "number"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        }
                      }
                    },
                    "project_id": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "402": {
            "description": "Response 402",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error",
                    "code"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "Too many requests - rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "Service unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error",
                    "code"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/creative-hub/video-studio/generate": {
      "post": {
        "operationId": "creativeHubGenerateCinematicVideo",
        "summary": "Generate a cinematic video clip (async)",
        "tags": [
          "creative-hub",
          "creative-generation"
        ],
        "description": "Starts an asynchronous cinematic image-to-video generation. BREAKING: a start-frame image_url is now REQUIRED for every provider and text-to-video is no longer supported. Returns queued generation metadata for polling. The resolution field was removed: provider output resolution is fixed and not configurable via the Higgsfield CLI (DA CONFERMARE in staging).",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "prompt",
                  "image_url"
                ],
                "properties": {
                  "prompt": {
                    "minLength": 1,
                    "maxLength": 4000,
                    "type": "string"
                  },
                  "image_url": {
                    "minLength": 1,
                    "maxLength": 2000,
                    "type": "string"
                  },
                  "provider": {
                    "anyOf": [
                      {
                        "type": "string",
                        "enum": [
                          "kling_3_0"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "veo_3_1"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "seedance_pro"
                        ]
                      }
                    ]
                  },
                  "duration": {
                    "anyOf": [
                      {
                        "type": "number",
                        "enum": [
                          4
                        ]
                      },
                      {
                        "type": "number",
                        "enum": [
                          5
                        ]
                      },
                      {
                        "type": "number",
                        "enum": [
                          6
                        ]
                      },
                      {
                        "type": "number",
                        "enum": [
                          8
                        ]
                      },
                      {
                        "type": "number",
                        "enum": [
                          10
                        ]
                      }
                    ]
                  },
                  "aspect_ratio": {
                    "anyOf": [
                      {
                        "type": "string",
                        "enum": [
                          "16:9"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "9:16"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "1:1"
                        ]
                      }
                    ]
                  },
                  "style": {
                    "maxLength": 64,
                    "type": "string"
                  },
                  "brand_kit_id": {
                    "minLength": 1,
                    "maxLength": 100,
                    "type": "string"
                  },
                  "brand_colors": {
                    "maxItems": 5,
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "202": {
            "description": "Accepted - processing asynchronously",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "created_at",
                    "credits_estimated",
                    "estimated_cost_cents",
                    "generation_id",
                    "polling_interval_ms",
                    "status"
                  ],
                  "properties": {
                    "created_at": {
                      "type": "string"
                    },
                    "credits_estimated": {
                      "type": "integer"
                    },
                    "estimated_cost_cents": {
                      "type": "number"
                    },
                    "generation_id": {
                      "type": "string"
                    },
                    "polling_interval_ms": {
                      "type": "integer"
                    },
                    "status": {
                      "anyOf": [
                        {
                          "type": "string",
                          "enum": [
                            "queued"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "processing"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "completed"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "failed"
                          ]
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "402": {
            "description": "Response 402",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "Too many requests - rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "Service unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/creative-hub/video-studio/estimate": {
      "post": {
        "operationId": "creativeHubEstimateCinematicVideo",
        "summary": "Estimate cinematic video generation credit cost",
        "tags": [
          "creative-hub",
          "creative-generation"
        ],
        "description": "Returns the deterministic credit hold estimate for a cinematic video generation, from the same catalog rates the generation is charged at.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "properties": {
                  "duration": {
                    "anyOf": [
                      {
                        "type": "number",
                        "enum": [
                          4
                        ]
                      },
                      {
                        "type": "number",
                        "enum": [
                          5
                        ]
                      },
                      {
                        "type": "number",
                        "enum": [
                          6
                        ]
                      },
                      {
                        "type": "number",
                        "enum": [
                          8
                        ]
                      },
                      {
                        "type": "number",
                        "enum": [
                          10
                        ]
                      }
                    ]
                  },
                  "provider": {
                    "anyOf": [
                      {
                        "type": "string",
                        "enum": [
                          "kling_3_0"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "veo_3_1"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "seedance_pro"
                        ]
                      }
                    ]
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "credits"
                  ],
                  "properties": {
                    "credits": {
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/creative-hub/video-studio/generations": {
      "get": {
        "operationId": "creativeHubListCinematicVideoGenerations",
        "summary": "List cinematic video generations",
        "tags": [
          "creative-hub",
          "creative-generation"
        ],
        "description": "Lists cinematic video generations for the authenticated user and joins generated video assets.",
        "parameters": [
          {
            "schema": {
              "minimum": 1,
              "maximum": 100,
              "type": "integer"
            },
            "in": "query",
            "name": "limit",
            "required": false
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "cursor",
            "required": false
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "generations",
                    "next_cursor"
                  ],
                  "properties": {
                    "generations": {
                      "type": "array",
                      "items": {
                        "additionalProperties": false,
                        "type": "object",
                        "required": [
                          "assets",
                          "completed_at",
                          "created_at",
                          "credits_charged",
                          "credits_estimated",
                          "error_message",
                          "id",
                          "mode",
                          "result_asset_ids",
                          "settings",
                          "status"
                        ],
                        "properties": {
                          "assets": {
                            "type": "array",
                            "items": {
                              "additionalProperties": false,
                              "type": "object",
                              "required": [
                                "duration",
                                "format",
                                "id",
                                "kind",
                                "name",
                                "thumbnail_url",
                                "url"
                              ],
                              "properties": {
                                "duration": {
                                  "anyOf": [
                                    {
                                      "type": "number"
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "format": {
                                  "anyOf": [
                                    {
                                      "type": "string"
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "id": {
                                  "type": "string"
                                },
                                "kind": {
                                  "type": "string"
                                },
                                "name": {
                                  "anyOf": [
                                    {
                                      "type": "string"
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "thumbnail_url": {
                                  "anyOf": [
                                    {
                                      "type": "string"
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "url": {
                                  "type": "string"
                                }
                              }
                            }
                          },
                          "completed_at": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "created_at": {
                            "type": "string"
                          },
                          "credits_charged": {
                            "anyOf": [
                              {
                                "type": "integer"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "credits_estimated": {
                            "type": "integer"
                          },
                          "error_message": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "id": {
                            "type": "string"
                          },
                          "mode": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "result_asset_ids": {
                            "anyOf": [
                              {
                                "type": "array",
                                "items": {
                                  "type": "string"
                                }
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "settings": {
                            "additionalProperties": false,
                            "type": "object",
                            "properties": {
                              "aspect_ratio": {
                                "anyOf": [
                                  {
                                    "type": "string",
                                    "enum": [
                                      "16:9"
                                    ]
                                  },
                                  {
                                    "type": "string",
                                    "enum": [
                                      "9:16"
                                    ]
                                  },
                                  {
                                    "type": "string",
                                    "enum": [
                                      "1:1"
                                    ]
                                  }
                                ]
                              },
                              "duration_seconds": {
                                "type": "integer"
                              },
                              "provider": {
                                "anyOf": [
                                  {
                                    "type": "string",
                                    "enum": [
                                      "kling_3_0"
                                    ]
                                  },
                                  {
                                    "type": "string",
                                    "enum": [
                                      "veo_3_1"
                                    ]
                                  },
                                  {
                                    "type": "string",
                                    "enum": [
                                      "seedance_pro"
                                    ]
                                  }
                                ]
                              }
                            }
                          },
                          "status": {
                            "anyOf": [
                              {
                                "type": "string",
                                "enum": [
                                  "queued"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "processing"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "completed"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "failed"
                                ]
                              }
                            ]
                          }
                        }
                      }
                    },
                    "next_cursor": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      },
      "delete": {
        "operationId": "creativeHubDeleteCinematicVideoGenerations",
        "summary": "Delete cinematic video generations",
        "tags": [
          "creative-hub",
          "creative-generation"
        ],
        "description": "Soft-deletes selected cinematic video generations for the authenticated user and soft-deletes their generated assets.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "ids"
                ],
                "properties": {
                  "ids": {
                    "minItems": 1,
                    "maxItems": 100,
                    "type": "array",
                    "items": {
                      "minLength": 1,
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "deleted"
                  ],
                  "properties": {
                    "deleted": {
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/creative-hub/video-studio/generations/{id}": {
      "get": {
        "operationId": "creativeHubGetCinematicVideoGeneration",
        "summary": "Get cinematic video generation",
        "tags": [
          "creative-hub",
          "creative-generation"
        ],
        "description": "Returns one cinematic video generation for polling/detail views.",
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "assets",
                    "completed_at",
                    "created_at",
                    "credits_charged",
                    "credits_estimated",
                    "error_message",
                    "id",
                    "mode",
                    "result_asset_ids",
                    "settings",
                    "status"
                  ],
                  "properties": {
                    "assets": {
                      "type": "array",
                      "items": {
                        "additionalProperties": false,
                        "type": "object",
                        "required": [
                          "duration",
                          "format",
                          "id",
                          "kind",
                          "name",
                          "thumbnail_url",
                          "url"
                        ],
                        "properties": {
                          "duration": {
                            "anyOf": [
                              {
                                "type": "number"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "format": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "id": {
                            "type": "string"
                          },
                          "kind": {
                            "type": "string"
                          },
                          "name": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "thumbnail_url": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "url": {
                            "type": "string"
                          }
                        }
                      }
                    },
                    "completed_at": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "created_at": {
                      "type": "string"
                    },
                    "credits_charged": {
                      "anyOf": [
                        {
                          "type": "integer"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "credits_estimated": {
                      "type": "integer"
                    },
                    "error_message": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "id": {
                      "type": "string"
                    },
                    "mode": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "result_asset_ids": {
                      "anyOf": [
                        {
                          "type": "array",
                          "items": {
                            "type": "string"
                          }
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "settings": {
                      "additionalProperties": false,
                      "type": "object",
                      "properties": {
                        "aspect_ratio": {
                          "anyOf": [
                            {
                              "type": "string",
                              "enum": [
                                "16:9"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "9:16"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "1:1"
                              ]
                            }
                          ]
                        },
                        "duration_seconds": {
                          "type": "integer"
                        },
                        "provider": {
                          "anyOf": [
                            {
                              "type": "string",
                              "enum": [
                                "kling_3_0"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "veo_3_1"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "seedance_pro"
                              ]
                            }
                          ]
                        }
                      }
                    },
                    "status": {
                      "anyOf": [
                        {
                          "type": "string",
                          "enum": [
                            "queued"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "processing"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "completed"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "failed"
                          ]
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/creative-hub/voices": {
      "get": {
        "operationId": "creativeHubListVoices",
        "summary": "List Creative Hub voiceover voices",
        "tags": [
          "creative-hub",
          "creative-generation"
        ],
        "description": "Lists library and team-scoped voices available for Creative Hub voiceover generation, with optional gender, language, text search and scope filters.",
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "gender",
            "required": false
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "language",
            "required": false
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "q",
            "required": false
          },
          {
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "enum": [
                    "library"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "mine"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "all"
                  ]
                }
              ]
            },
            "in": "query",
            "name": "scope",
            "required": false
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "items"
                  ],
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "additionalProperties": false,
                        "type": "object",
                        "required": [
                          "id",
                          "team_id",
                          "created_by",
                          "name",
                          "provider",
                          "provider_voice_id",
                          "language",
                          "gender",
                          "accent",
                          "descriptor",
                          "preview_url",
                          "is_library",
                          "metadata",
                          "created_at",
                          "updated_at",
                          "deleted_at"
                        ],
                        "properties": {
                          "id": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "team_id": {
                            "anyOf": [
                              {
                                "format": "uuid",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "created_by": {
                            "anyOf": [
                              {
                                "format": "uuid",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "name": {
                            "type": "string"
                          },
                          "provider": {
                            "type": "string"
                          },
                          "provider_voice_id": {
                            "type": "string"
                          },
                          "language": {
                            "type": "string"
                          },
                          "gender": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "accent": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "descriptor": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "preview_url": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "is_library": {
                            "type": "boolean"
                          },
                          "metadata": {
                            "$comment": "json-value",
                            "description": "Arbitrary JSON value with nested arrays and objects."
                          },
                          "created_at": {
                            "format": "date-time",
                            "type": "string"
                          },
                          "updated_at": {
                            "format": "date-time",
                            "type": "string"
                          },
                          "deleted_at": {
                            "anyOf": [
                              {
                                "format": "date-time",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/creative-hub/voiceover/voices/{id}/preview": {
      "post": {
        "operationId": "creativeHubVoicePreview",
        "summary": "Get or lazily generate a short audio preview for a voice",
        "tags": [
          "creative-hub",
          "creative-generation"
        ],
        "description": "Returns a cached voice preview URL or generates and stores a short preview sample for the selected voice without charging credits.",
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "url"
                  ],
                  "properties": {
                    "url": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "Too many requests - rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "Service unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/creative-hub/voiceover/estimate": {
      "post": {
        "operationId": "creativeHubEstimateVoiceover",
        "summary": "Estimate voiceover generation credits",
        "tags": [
          "creative-hub",
          "creative-generation"
        ],
        "description": "Calculates character count, estimated credit cost and estimated duration for a single-voice or multi-voice voiceover request. The price is resolved from the provider of the selected voice (voice_id), which is the same provider the generation job will bill from — supplying a different voice can change the estimate by up to 6.6x.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "properties": {
                  "text": {
                    "maxLength": 5000,
                    "type": "string"
                  },
                  "voice_id": {
                    "type": "string"
                  },
                  "language": {
                    "maxLength": 10,
                    "type": "string"
                  },
                  "speed": {
                    "minimum": 0.7,
                    "maximum": 1.2,
                    "type": "number"
                  },
                  "sentiment": {
                    "maxLength": 30,
                    "type": "string"
                  },
                  "multi_voice": {
                    "maxItems": 20,
                    "type": "array",
                    "items": {
                      "additionalProperties": false,
                      "type": "object",
                      "required": [
                        "voice_id",
                        "text"
                      ],
                      "properties": {
                        "voice_id": {
                          "type": "string"
                        },
                        "text": {
                          "minLength": 1,
                          "maxLength": 5000,
                          "type": "string"
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "characters",
                    "estimated_credits",
                    "estimated_duration_s"
                  ],
                  "properties": {
                    "characters": {
                      "type": "integer"
                    },
                    "estimated_credits": {
                      "type": "integer"
                    },
                    "estimated_duration_s": {
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/creative-hub/voiceover/generate": {
      "post": {
        "operationId": "creativeHubGenerateVoiceover",
        "summary": "Generate a voiceover asset",
        "tags": [
          "creative-hub",
          "creative-generation"
        ],
        "description": "Starts an asynchronous Creative Hub voiceover generation for single-voice text or multi-voice dialogue and returns a polling handle.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "properties": {
                  "text": {
                    "maxLength": 5000,
                    "type": "string"
                  },
                  "voice_id": {
                    "type": "string"
                  },
                  "language": {
                    "maxLength": 10,
                    "type": "string"
                  },
                  "speed": {
                    "minimum": 0.7,
                    "maximum": 1.2,
                    "type": "number"
                  },
                  "sentiment": {
                    "maxLength": 30,
                    "type": "string"
                  },
                  "multi_voice": {
                    "maxItems": 20,
                    "type": "array",
                    "items": {
                      "additionalProperties": false,
                      "type": "object",
                      "required": [
                        "voice_id",
                        "text"
                      ],
                      "properties": {
                        "voice_id": {
                          "type": "string"
                        },
                        "text": {
                          "minLength": 1,
                          "maxLength": 5000,
                          "type": "string"
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "202": {
            "description": "Accepted - processing asynchronously",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "generation_id",
                    "status",
                    "estimated_credits",
                    "polling_interval_ms"
                  ],
                  "properties": {
                    "generation_id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "status": {
                      "type": "string",
                      "enum": [
                        "queued"
                      ]
                    },
                    "estimated_credits": {
                      "type": "integer"
                    },
                    "polling_interval_ms": {
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "402": {
            "description": "Response 402",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "Too many requests - rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "Service unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/creative-hub/generations/{id}": {
      "get": {
        "operationId": "creativeHubGetGenerationStatus",
        "summary": "Get Creative Hub generation status",
        "tags": [
          "creative-hub",
          "creative-generation"
        ],
        "description": "Returns polling status for a Creative Hub voiceover or avatar generation and includes generated asset URLs once completed.",
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "id",
                    "kind",
                    "status",
                    "credits_charged",
                    "error_message",
                    "assets"
                  ],
                  "properties": {
                    "id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "kind": {
                      "type": "string"
                    },
                    "status": {
                      "type": "string"
                    },
                    "credits_charged": {
                      "type": "integer"
                    },
                    "error_message": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "assets": {
                      "type": "array",
                      "items": {
                        "additionalProperties": false,
                        "type": "object",
                        "required": [
                          "id",
                          "kind",
                          "name",
                          "url",
                          "thumbnail_url",
                          "duration"
                        ],
                        "properties": {
                          "id": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "kind": {
                            "type": "string"
                          },
                          "name": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "url": {
                            "type": "string"
                          },
                          "thumbnail_url": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "duration": {
                            "anyOf": [
                              {
                                "type": "number"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/cron/collect-insights": {
      "post": {
        "operationId": "triggerInsightCollection",
        "summary": "Trigger insight collection",
        "tags": [
          "cron"
        ],
        "description": "Manually triggers insight collection from Meta API for the authenticated user and their team. Runs asynchronously in the background.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "from_date": {
                    "type": "string"
                  },
                  "to_date": {
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "message",
                    "job_id",
                    "from_date",
                    "to_date"
                  ],
                  "properties": {
                    "message": {
                      "type": "string"
                    },
                    "job_id": {
                      "type": "string"
                    },
                    "from_date": {
                      "type": "string"
                    },
                    "to_date": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/cron/collect-account-extended": {
      "post": {
        "operationId": "triggerAccountExtendedCollection",
        "summary": "Trigger account extended data collection",
        "tags": [
          "cron"
        ],
        "description": "Triggers collection of extended account data (spend_cap, balance, payment method) from Meta API for all team accounts.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "message",
                    "job_id"
                  ],
                  "properties": {
                    "message": {
                      "type": "string"
                    },
                    "job_id": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/cron/status": {
      "get": {
        "operationId": "getCronStatus",
        "summary": "Get latest collection status",
        "tags": [
          "cron"
        ],
        "description": "Returns the status of the most recent insight collection or other cron job for the user's team.",
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "job_type",
            "required": false
          }
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "status",
                    "created_at",
                    "completed_at",
                    "data"
                  ],
                  "properties": {
                    "status": {
                      "description": "Lifecycle state of a job_result row. \"NONE\" means no job has been recorded yet.",
                      "anyOf": [
                        {
                          "type": "string",
                          "enum": [
                            "PENDING"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "RUNNING"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "COMPLETED"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "FAILED"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "NONE"
                          ]
                        }
                      ]
                    },
                    "created_at": {
                      "anyOf": [
                        {
                          "format": "date-time",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "completed_at": {
                      "anyOf": [
                        {
                          "format": "date-time",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "data": {
                      "anyOf": [
                        {
                          "$comment": "json-value",
                          "description": "Arbitrary JSON value with nested arrays and objects."
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/cron/fetch-exchange-rates": {
      "post": {
        "operationId": "fetchExchangeRates",
        "summary": "Fetch exchange rates from ExchangeRate-API",
        "tags": [
          "cron"
        ],
        "description": "Fetches and stores exchange rates from ExchangeRate-API.com for the specified date (or today). Used for currency conversion in insights.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "date": {
                    "description": "YYYY-MM-DD, defaults to today",
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "message",
                    "date"
                  ],
                  "properties": {
                    "message": {
                      "type": "string"
                    },
                    "date": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/cron/check-notifications": {
      "post": {
        "operationId": "triggerNotificationChecker",
        "summary": "Trigger notification checker",
        "tags": [
          "cron"
        ],
        "description": "Triggers the notification checker for disapproved campaigns/adsets and spend cap alerts. Runs asynchronously for all team sessions.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "message",
                    "job_id"
                  ],
                  "properties": {
                    "message": {
                      "type": "string"
                    },
                    "job_id": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/cron/health": {
      "get": {
        "operationId": "getApiV1CronHealth",
        "summary": "Get cron jobs health status",
        "tags": [
          "cron"
        ],
        "description": "Returns health status of all cron job types, including latest run status and 24-hour job/failure counts.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "insight_collection",
                    "account_extended",
                    "notification_checker",
                    "total_jobs_24h",
                    "failed_jobs_24h"
                  ],
                  "properties": {
                    "insight_collection": {
                      "type": "object",
                      "required": [
                        "status"
                      ],
                      "properties": {
                        "job_type": {
                          "type": "string"
                        },
                        "status": {
                          "description": "Status of the latest run for this job type. \"UNKNOWN\" means no recent run was found.",
                          "anyOf": [
                            {
                              "type": "string",
                              "enum": [
                                "PENDING"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "RUNNING"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "COMPLETED"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "FAILED"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "UNKNOWN"
                              ]
                            }
                          ]
                        },
                        "created_at": {
                          "anyOf": [
                            {
                              "format": "date-time",
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "completed_at": {
                          "anyOf": [
                            {
                              "format": "date-time",
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "error": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        }
                      }
                    },
                    "account_extended": {
                      "type": "object",
                      "required": [
                        "status"
                      ],
                      "properties": {
                        "job_type": {
                          "type": "string"
                        },
                        "status": {
                          "description": "Status of the latest run for this job type. \"UNKNOWN\" means no recent run was found.",
                          "anyOf": [
                            {
                              "type": "string",
                              "enum": [
                                "PENDING"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "RUNNING"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "COMPLETED"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "FAILED"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "UNKNOWN"
                              ]
                            }
                          ]
                        },
                        "created_at": {
                          "anyOf": [
                            {
                              "format": "date-time",
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "completed_at": {
                          "anyOf": [
                            {
                              "format": "date-time",
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "error": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        }
                      }
                    },
                    "notification_checker": {
                      "type": "object",
                      "required": [
                        "status"
                      ],
                      "properties": {
                        "job_type": {
                          "type": "string"
                        },
                        "status": {
                          "description": "Status of the latest run for this job type. \"UNKNOWN\" means no recent run was found.",
                          "anyOf": [
                            {
                              "type": "string",
                              "enum": [
                                "PENDING"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "RUNNING"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "COMPLETED"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "FAILED"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "UNKNOWN"
                              ]
                            }
                          ]
                        },
                        "created_at": {
                          "anyOf": [
                            {
                              "format": "date-time",
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "completed_at": {
                          "anyOf": [
                            {
                              "format": "date-time",
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "error": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        }
                      }
                    },
                    "total_jobs_24h": {
                      "type": "number"
                    },
                    "failed_jobs_24h": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/cron/backfill-insights": {
      "post": {
        "operationId": "postApiV1CronBackfillInsights",
        "summary": "Trigger historical insights backfill",
        "tags": [
          "cron"
        ],
        "description": "Triggers a historical insights backfill via SQS workers. Splits the date range into 30-day chunks. Super admin only.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "from_date",
                  "to_date"
                ],
                "properties": {
                  "from_date": {
                    "description": "Start date YYYY-MM-DD",
                    "type": "string"
                  },
                  "to_date": {
                    "description": "End date YYYY-MM-DD",
                    "type": "string"
                  },
                  "user_id": {
                    "format": "uuid",
                    "description": "Specific session to backfill. Omit for all accessible sessions.",
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "message",
                    "runs",
                    "from_date",
                    "to_date",
                    "chunks"
                  ],
                  "properties": {
                    "message": {
                      "type": "string"
                    },
                    "runs": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "user_id",
                          "worker_run_id",
                          "chunks"
                        ],
                        "properties": {
                          "user_id": {
                            "type": "string"
                          },
                          "worker_run_id": {
                            "type": "string"
                          },
                          "chunks": {
                            "type": "number"
                          }
                        }
                      }
                    },
                    "from_date": {
                      "type": "string"
                    },
                    "to_date": {
                      "type": "string"
                    },
                    "chunks": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/cron/backfill-geo-insights": {
      "post": {
        "operationId": "postApiV1CronBackfillGeoInsights",
        "summary": "Trigger historical per-country (geo) insights backfill",
        "tags": [
          "cron"
        ],
        "description": "Enqueues a historical campaign_country_daily_insight backfill via SQS, splitting the range into 30-day chunks. Fire-and-forget (BACKFILL_GEO_INSIGHTS is not a DB worker_type, so no worker_run is created); geo collection is idempotent. Super admin only. Omit user_id to backfill every accessible session.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "from_date",
                  "to_date"
                ],
                "properties": {
                  "from_date": {
                    "description": "Start date YYYY-MM-DD",
                    "type": "string"
                  },
                  "to_date": {
                    "description": "End date YYYY-MM-DD",
                    "type": "string"
                  },
                  "user_id": {
                    "format": "uuid",
                    "description": "Specific session to backfill. Omit for all accessible sessions.",
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "message",
                    "sessions",
                    "enqueued",
                    "from_date",
                    "to_date",
                    "chunks"
                  ],
                  "properties": {
                    "message": {
                      "type": "string"
                    },
                    "sessions": {
                      "type": "number"
                    },
                    "enqueued": {
                      "type": "number"
                    },
                    "from_date": {
                      "type": "string"
                    },
                    "to_date": {
                      "type": "string"
                    },
                    "chunks": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/exchange-rates/latest": {
      "get": {
        "operationId": "getApiV1ExchangeRatesLatest",
        "summary": "Get latest exchange rates",
        "tags": [
          "cron"
        ],
        "description": "Returns the most recent stored exchange rates for the given base currency (default EUR).",
        "parameters": [
          {
            "schema": {
              "default": "EUR",
              "type": "string"
            },
            "in": "query",
            "name": "base",
            "required": false
          }
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "rates",
                    "date",
                    "base"
                  ],
                  "properties": {
                    "rates": {
                      "type": "object",
                      "additionalProperties": {
                        "type": "number"
                      }
                    },
                    "date": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "base": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/cross-account-compare/metrics": {
      "get": {
        "operationId": "getCrossAccountMetrics",
        "summary": "Compare metrics across multiple Meta ad accounts",
        "tags": [
          "analytics"
        ],
        "description": "Returns aggregated spend, CTR, ROAS, CPA and other metrics for 2-10 selected ad accounts in a given period.",
        "parameters": [
          {
            "schema": {
              "minItems": 2,
              "maxItems": 10,
              "type": "array",
              "items": {
                "type": "string"
              }
            },
            "in": "query",
            "name": "account_ids",
            "required": true
          },
          {
            "schema": {
              "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
              "type": "string"
            },
            "in": "query",
            "name": "from_date",
            "required": true
          },
          {
            "schema": {
              "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
              "type": "string"
            },
            "in": "query",
            "name": "to_date",
            "required": true
          },
          {
            "schema": {
              "anyOf": [
                {
                  "minLength": 3,
                  "maxLength": 3,
                  "type": "string"
                },
                {
                  "type": "string",
                  "enum": [
                    "account"
                  ]
                }
              ]
            },
            "in": "query",
            "name": "currency",
            "required": false
          }
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "accounts",
                    "period",
                    "currency"
                  ],
                  "properties": {
                    "accounts": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "account_id",
                          "account_name",
                          "currency",
                          "spend",
                          "impressions",
                          "clicks",
                          "ctr",
                          "cpc",
                          "cpm",
                          "roas",
                          "cpa",
                          "conversions",
                          "revenue"
                        ],
                        "properties": {
                          "account_id": {
                            "type": "string"
                          },
                          "account_name": {
                            "type": "string"
                          },
                          "currency": {
                            "type": "string"
                          },
                          "spend": {
                            "type": "number"
                          },
                          "impressions": {
                            "type": "number"
                          },
                          "clicks": {
                            "type": "number"
                          },
                          "ctr": {
                            "type": "number"
                          },
                          "cpc": {
                            "type": "number"
                          },
                          "cpm": {
                            "type": "number"
                          },
                          "roas": {
                            "type": "number"
                          },
                          "cpa": {
                            "type": "number"
                          },
                          "conversions": {
                            "type": "number"
                          },
                          "revenue": {
                            "type": "number"
                          }
                        }
                      }
                    },
                    "period": {
                      "type": "object",
                      "required": [
                        "from_date",
                        "to_date"
                      ],
                      "properties": {
                        "from_date": {
                          "type": "string"
                        },
                        "to_date": {
                          "type": "string"
                        }
                      }
                    },
                    "currency": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/cross-account-compare/trend": {
      "get": {
        "operationId": "getCrossAccountTrend",
        "summary": "Get overlay trend data for multiple Meta ad accounts",
        "tags": [
          "analytics"
        ],
        "description": "Returns time-series data per account for rendering a multi-line overlay chart.",
        "parameters": [
          {
            "schema": {
              "minItems": 2,
              "maxItems": 10,
              "type": "array",
              "items": {
                "type": "string"
              }
            },
            "in": "query",
            "name": "account_ids",
            "required": true
          },
          {
            "schema": {
              "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
              "type": "string"
            },
            "in": "query",
            "name": "from_date",
            "required": true
          },
          {
            "schema": {
              "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
              "type": "string"
            },
            "in": "query",
            "name": "to_date",
            "required": true
          },
          {
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "enum": [
                    "spend"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "roas"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "cpa"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "ctr"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "conversions"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "impressions"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "clicks"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "revenue"
                  ]
                }
              ]
            },
            "in": "query",
            "name": "metric",
            "required": true
          },
          {
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "enum": [
                    "day"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "week"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "month"
                  ]
                }
              ]
            },
            "in": "query",
            "name": "granularity",
            "required": false
          },
          {
            "schema": {
              "anyOf": [
                {
                  "minLength": 3,
                  "maxLength": 3,
                  "type": "string"
                },
                {
                  "type": "string",
                  "enum": [
                    "account"
                  ]
                }
              ]
            },
            "in": "query",
            "name": "currency",
            "required": false
          }
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "metric",
                    "granularity",
                    "series"
                  ],
                  "properties": {
                    "metric": {
                      "type": "string"
                    },
                    "granularity": {
                      "type": "string"
                    },
                    "series": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "account_id",
                          "account_name",
                          "data"
                        ],
                        "properties": {
                          "account_id": {
                            "type": "string"
                          },
                          "account_name": {
                            "type": "string"
                          },
                          "data": {
                            "type": "array",
                            "items": {
                              "type": "object",
                              "required": [
                                "date",
                                "value"
                              ],
                              "properties": {
                                "date": {
                                  "type": "string"
                                },
                                "value": {
                                  "type": "number"
                                }
                              }
                            }
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/webhooks/customerio/reporting": {
      "post": {
        "operationId": "postApiV1WebhooksCustomerioReporting",
        "summary": "Customer.io reporting webhook (delivery reconciliation)",
        "tags": [
          "webhooks"
        ],
        "description": "Receives Customer.io delivery-state events and records them in cio_delivery_event. Verified via the CIO v0:<timestamp>:<body> HMAC-SHA256 signature against CIO_REPORTING_WEBHOOK_SECRET.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": true,
                "description": "Customer.io Reporting Webhook payload. Permissive on extra fields because the schema varies by object_type/metric and CIO may add fields without notice.",
                "type": "object",
                "required": [
                  "event_id",
                  "metric"
                ],
                "properties": {
                  "event_id": {
                    "type": "string"
                  },
                  "object_type": {
                    "type": "string"
                  },
                  "metric": {
                    "type": "string"
                  },
                  "timestamp": {
                    "type": "number"
                  },
                  "data": {
                    "additionalProperties": true,
                    "type": "object",
                    "properties": {
                      "delivery_id": {
                        "type": "string"
                      },
                      "customer_id": {
                        "type": "string"
                      },
                      "recipient": {
                        "type": "string"
                      },
                      "failure_message": {
                        "type": "string"
                      },
                      "identifiers": {
                        "$comment": "json-value",
                        "description": "Arbitrary JSON value with nested arrays and objects."
                      }
                    }
                  }
                }
              }
            }
          },
          "description": "Customer.io Reporting Webhook payload. Permissive on extra fields because the schema varies by object_type/metric and CIO may add fields without notice."
        },
        "security": [
          {
            "cioReportingSignature": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object",
                  "required": [
                    "status"
                  ],
                  "properties": {
                    "status": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/dashboard-filter-presets": {
      "get": {
        "operationId": "listDashboardFilterPresets",
        "summary": "List dashboard filter presets",
        "tags": [
          "dashboard-filter-presets"
        ],
        "description": "Returns the saved filter presets for the authenticated user on a dashboard page. Defaults to the main dashboard page when no page is provided.",
        "parameters": [
          {
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "enum": [
                    "dashboard"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "analytics"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "reports"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "compare"
                  ]
                }
              ]
            },
            "in": "query",
            "name": "page",
            "required": false
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "items"
                  ],
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "id",
                          "name",
                          "filters",
                          "page",
                          "sort_order",
                          "created_at",
                          "updated_at"
                        ],
                        "properties": {
                          "id": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "name": {
                            "type": "string"
                          },
                          "filters": {
                            "additionalProperties": false,
                            "type": "object",
                            "properties": {
                              "period": {
                                "anyOf": [
                                  {
                                    "type": "string",
                                    "enum": [
                                      "today"
                                    ]
                                  },
                                  {
                                    "type": "string",
                                    "enum": [
                                      "yesterday"
                                    ]
                                  },
                                  {
                                    "type": "string",
                                    "enum": [
                                      "last_7d"
                                    ]
                                  },
                                  {
                                    "type": "string",
                                    "enum": [
                                      "last_14d"
                                    ]
                                  },
                                  {
                                    "type": "string",
                                    "enum": [
                                      "last_30d"
                                    ]
                                  },
                                  {
                                    "type": "string",
                                    "enum": [
                                      "this_week"
                                    ]
                                  },
                                  {
                                    "type": "string",
                                    "enum": [
                                      "last_week"
                                    ]
                                  },
                                  {
                                    "type": "string",
                                    "enum": [
                                      "this_month"
                                    ]
                                  },
                                  {
                                    "type": "string",
                                    "enum": [
                                      "last_month"
                                    ]
                                  },
                                  {
                                    "type": "string",
                                    "enum": [
                                      "custom"
                                    ]
                                  }
                                ]
                              },
                              "from_date": {
                                "format": "date",
                                "type": "string"
                              },
                              "to_date": {
                                "format": "date",
                                "type": "string"
                              },
                              "account_ids": {
                                "type": "array",
                                "items": {
                                  "type": "string"
                                }
                              },
                              "team_member_id": {
                                "type": "string"
                              },
                              "currency": {
                                "type": "string"
                              },
                              "entity_filters": {
                                "type": "object",
                                "additionalProperties": {
                                  "type": "array",
                                  "items": {
                                    "type": "string"
                                  }
                                }
                              },
                              "level": {
                                "maxLength": 20,
                                "type": "string"
                              },
                              "platform": {
                                "maxLength": 20,
                                "type": "string"
                              },
                              "connected_only": {
                                "type": "boolean"
                              }
                            }
                          },
                          "page": {
                            "type": "string"
                          },
                          "sort_order": {
                            "type": "number"
                          },
                          "created_at": {
                            "format": "date-time",
                            "type": "string"
                          },
                          "updated_at": {
                            "anyOf": [
                              {
                                "format": "date-time",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "createDashboardFilterPreset",
        "summary": "Create dashboard filter preset",
        "tags": [
          "dashboard-filter-presets"
        ],
        "description": "Creates a named filter preset for the authenticated user. Preset names must be unique per page and user.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "name",
                  "filters",
                  "page"
                ],
                "properties": {
                  "name": {
                    "minLength": 1,
                    "maxLength": 100,
                    "type": "string"
                  },
                  "filters": {
                    "additionalProperties": false,
                    "type": "object",
                    "properties": {
                      "period": {
                        "anyOf": [
                          {
                            "type": "string",
                            "enum": [
                              "today"
                            ]
                          },
                          {
                            "type": "string",
                            "enum": [
                              "yesterday"
                            ]
                          },
                          {
                            "type": "string",
                            "enum": [
                              "last_7d"
                            ]
                          },
                          {
                            "type": "string",
                            "enum": [
                              "last_14d"
                            ]
                          },
                          {
                            "type": "string",
                            "enum": [
                              "last_30d"
                            ]
                          },
                          {
                            "type": "string",
                            "enum": [
                              "this_week"
                            ]
                          },
                          {
                            "type": "string",
                            "enum": [
                              "last_week"
                            ]
                          },
                          {
                            "type": "string",
                            "enum": [
                              "this_month"
                            ]
                          },
                          {
                            "type": "string",
                            "enum": [
                              "last_month"
                            ]
                          },
                          {
                            "type": "string",
                            "enum": [
                              "custom"
                            ]
                          }
                        ]
                      },
                      "from_date": {
                        "format": "date",
                        "type": "string"
                      },
                      "to_date": {
                        "format": "date",
                        "type": "string"
                      },
                      "account_ids": {
                        "type": "array",
                        "items": {
                          "type": "string"
                        }
                      },
                      "team_member_id": {
                        "type": "string"
                      },
                      "currency": {
                        "type": "string"
                      },
                      "entity_filters": {
                        "type": "object",
                        "additionalProperties": {
                          "type": "array",
                          "items": {
                            "type": "string"
                          }
                        }
                      },
                      "level": {
                        "maxLength": 20,
                        "type": "string"
                      },
                      "platform": {
                        "maxLength": 20,
                        "type": "string"
                      },
                      "connected_only": {
                        "type": "boolean"
                      }
                    }
                  },
                  "page": {
                    "anyOf": [
                      {
                        "type": "string",
                        "enum": [
                          "dashboard"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "analytics"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "reports"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "compare"
                        ]
                      }
                    ]
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "201": {
            "description": "Resource created",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "id",
                    "name",
                    "filters",
                    "page",
                    "sort_order",
                    "created_at",
                    "updated_at"
                  ],
                  "properties": {
                    "id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "name": {
                      "type": "string"
                    },
                    "filters": {
                      "additionalProperties": false,
                      "type": "object",
                      "properties": {
                        "period": {
                          "anyOf": [
                            {
                              "type": "string",
                              "enum": [
                                "today"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "yesterday"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "last_7d"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "last_14d"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "last_30d"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "this_week"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "last_week"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "this_month"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "last_month"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "custom"
                              ]
                            }
                          ]
                        },
                        "from_date": {
                          "format": "date",
                          "type": "string"
                        },
                        "to_date": {
                          "format": "date",
                          "type": "string"
                        },
                        "account_ids": {
                          "type": "array",
                          "items": {
                            "type": "string"
                          }
                        },
                        "team_member_id": {
                          "type": "string"
                        },
                        "currency": {
                          "type": "string"
                        },
                        "entity_filters": {
                          "type": "object",
                          "additionalProperties": {
                            "type": "array",
                            "items": {
                              "type": "string"
                            }
                          }
                        },
                        "level": {
                          "maxLength": 20,
                          "type": "string"
                        },
                        "platform": {
                          "maxLength": 20,
                          "type": "string"
                        },
                        "connected_only": {
                          "type": "boolean"
                        }
                      }
                    },
                    "page": {
                      "type": "string"
                    },
                    "sort_order": {
                      "type": "number"
                    },
                    "created_at": {
                      "format": "date-time",
                      "type": "string"
                    },
                    "updated_at": {
                      "anyOf": [
                        {
                          "format": "date-time",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "409": {
            "description": "Conflict - resource state prevents the operation",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/dashboard-filter-presets/{id}": {
      "put": {
        "operationId": "updateDashboardFilterPreset",
        "summary": "Update dashboard filter preset",
        "tags": [
          "dashboard-filter-presets"
        ],
        "description": "Updates a saved dashboard filter preset owned by the authenticated user, including name, filters, page or sort order.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "properties": {
                  "name": {
                    "minLength": 1,
                    "maxLength": 100,
                    "type": "string"
                  },
                  "sort_order": {
                    "minimum": 0,
                    "type": "integer"
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "id",
                    "name",
                    "filters",
                    "page",
                    "sort_order",
                    "created_at",
                    "updated_at"
                  ],
                  "properties": {
                    "id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "name": {
                      "type": "string"
                    },
                    "filters": {
                      "additionalProperties": false,
                      "type": "object",
                      "properties": {
                        "period": {
                          "anyOf": [
                            {
                              "type": "string",
                              "enum": [
                                "today"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "yesterday"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "last_7d"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "last_14d"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "last_30d"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "this_week"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "last_week"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "this_month"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "last_month"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "custom"
                              ]
                            }
                          ]
                        },
                        "from_date": {
                          "format": "date",
                          "type": "string"
                        },
                        "to_date": {
                          "format": "date",
                          "type": "string"
                        },
                        "account_ids": {
                          "type": "array",
                          "items": {
                            "type": "string"
                          }
                        },
                        "team_member_id": {
                          "type": "string"
                        },
                        "currency": {
                          "type": "string"
                        },
                        "entity_filters": {
                          "type": "object",
                          "additionalProperties": {
                            "type": "array",
                            "items": {
                              "type": "string"
                            }
                          }
                        },
                        "level": {
                          "maxLength": 20,
                          "type": "string"
                        },
                        "platform": {
                          "maxLength": 20,
                          "type": "string"
                        },
                        "connected_only": {
                          "type": "boolean"
                        }
                      }
                    },
                    "page": {
                      "type": "string"
                    },
                    "sort_order": {
                      "type": "number"
                    },
                    "created_at": {
                      "format": "date-time",
                      "type": "string"
                    },
                    "updated_at": {
                      "anyOf": [
                        {
                          "format": "date-time",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "Conflict - resource state prevents the operation",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      },
      "delete": {
        "operationId": "deleteDashboardFilterPreset",
        "summary": "Delete dashboard filter preset",
        "tags": [
          "dashboard-filter-presets"
        ],
        "description": "Soft-deletes a dashboard filter preset owned by the authenticated user.",
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "204": {
            "description": "No content"
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/dashboard-layouts": {
      "get": {
        "operationId": "getApiV1DashboardLayouts",
        "summary": "List dashboard layouts",
        "tags": [
          "dashboard-layouts"
        ],
        "description": "Returns all saved dashboard layouts for the authenticated user, including whether any custom layouts exist.",
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "items",
                    "has_custom"
                  ],
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "id",
                          "user_id",
                          "name",
                          "config",
                          "is_default",
                          "created_at",
                          "updated_at"
                        ],
                        "properties": {
                          "id": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "user_id": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "name": {
                            "type": "string"
                          },
                          "config": {
                            "$comment": "json-value",
                            "description": "Arbitrary JSON value with nested arrays and objects."
                          },
                          "is_default": {
                            "type": "boolean"
                          },
                          "created_at": {
                            "format": "date-time",
                            "type": "string"
                          },
                          "updated_at": {
                            "anyOf": [
                              {
                                "format": "date-time",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          }
                        }
                      }
                    },
                    "has_custom": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "postApiV1DashboardLayouts",
        "summary": "Create dashboard layout",
        "tags": [
          "dashboard-layouts"
        ],
        "description": "Creates a new dashboard layout with the provided name and widget configuration. Optionally sets it as the default layout.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "name",
                  "config"
                ],
                "properties": {
                  "name": {
                    "minLength": 1,
                    "maxLength": 255,
                    "type": "string"
                  },
                  "config": {
                    "$comment": "json-value",
                    "description": "Arbitrary JSON value with nested arrays and objects."
                  },
                  "is_default": {
                    "type": "boolean"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "201": {
            "description": "Resource created",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "id",
                    "user_id",
                    "name",
                    "config",
                    "is_default",
                    "created_at",
                    "updated_at"
                  ],
                  "properties": {
                    "id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "user_id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "name": {
                      "type": "string"
                    },
                    "config": {
                      "$comment": "json-value",
                      "description": "Arbitrary JSON value with nested arrays and objects."
                    },
                    "is_default": {
                      "type": "boolean"
                    },
                    "created_at": {
                      "format": "date-time",
                      "type": "string"
                    },
                    "updated_at": {
                      "anyOf": [
                        {
                          "format": "date-time",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "409": {
            "description": "Conflict - resource state prevents the operation",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/dashboard-layouts/active": {
      "get": {
        "operationId": "getApiV1DashboardLayoutsActive",
        "summary": "Get active dashboard layout",
        "tags": [
          "dashboard-layouts"
        ],
        "description": "Returns the currently active dashboard layout. Falls back to the default layout or a virtual layout if none is set.",
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "layout",
                    "config",
                    "is_virtual"
                  ],
                  "properties": {
                    "layout": {
                      "anyOf": [
                        {
                          "type": "object",
                          "required": [
                            "id",
                            "user_id",
                            "name",
                            "config",
                            "is_default",
                            "created_at",
                            "updated_at"
                          ],
                          "properties": {
                            "id": {
                              "format": "uuid",
                              "type": "string"
                            },
                            "user_id": {
                              "format": "uuid",
                              "type": "string"
                            },
                            "name": {
                              "type": "string"
                            },
                            "config": {
                              "$comment": "json-value",
                              "description": "Arbitrary JSON value with nested arrays and objects."
                            },
                            "is_default": {
                              "type": "boolean"
                            },
                            "created_at": {
                              "format": "date-time",
                              "type": "string"
                            },
                            "updated_at": {
                              "anyOf": [
                                {
                                  "format": "date-time",
                                  "type": "string"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            }
                          }
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "config": {
                      "$comment": "json-value",
                      "description": "Arbitrary JSON value with nested arrays and objects."
                    },
                    "is_virtual": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/dashboard-layouts/default-config": {
      "get": {
        "operationId": "getApiV1DashboardLayoutsDefaultConfig",
        "summary": "Get default config for role",
        "tags": [
          "dashboard-layouts"
        ],
        "description": "Returns the default dashboard widget configuration for the authenticated user's role.",
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "config"
                  ],
                  "properties": {
                    "config": {
                      "$comment": "json-value",
                      "description": "Arbitrary JSON value with nested arrays and objects."
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/dashboard-layouts/{id}": {
      "get": {
        "operationId": "getApiV1DashboardLayoutsById",
        "summary": "Get dashboard layout by ID",
        "tags": [
          "dashboard-layouts"
        ],
        "description": "Returns a single dashboard layout by its ID. Only returns layouts owned by the authenticated user.",
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "id",
                    "user_id",
                    "name",
                    "config",
                    "is_default",
                    "created_at",
                    "updated_at"
                  ],
                  "properties": {
                    "id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "user_id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "name": {
                      "type": "string"
                    },
                    "config": {
                      "$comment": "json-value",
                      "description": "Arbitrary JSON value with nested arrays and objects."
                    },
                    "is_default": {
                      "type": "boolean"
                    },
                    "created_at": {
                      "format": "date-time",
                      "type": "string"
                    },
                    "updated_at": {
                      "anyOf": [
                        {
                          "format": "date-time",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      },
      "patch": {
        "operationId": "patchApiV1DashboardLayoutsById",
        "summary": "Update dashboard layout",
        "tags": [
          "dashboard-layouts"
        ],
        "description": "Partially updates a dashboard layout (name, config, and/or default flag). Returns 409 if the new name conflicts with an existing layout.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "properties": {
                  "name": {
                    "minLength": 1,
                    "maxLength": 255,
                    "type": "string"
                  },
                  "config": {
                    "$comment": "json-value",
                    "description": "Arbitrary JSON value with nested arrays and objects."
                  },
                  "is_default": {
                    "type": "boolean"
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "id",
                    "user_id",
                    "name",
                    "config",
                    "is_default",
                    "created_at",
                    "updated_at"
                  ],
                  "properties": {
                    "id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "user_id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "name": {
                      "type": "string"
                    },
                    "config": {
                      "$comment": "json-value",
                      "description": "Arbitrary JSON value with nested arrays and objects."
                    },
                    "is_default": {
                      "type": "boolean"
                    },
                    "created_at": {
                      "format": "date-time",
                      "type": "string"
                    },
                    "updated_at": {
                      "anyOf": [
                        {
                          "format": "date-time",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "Conflict - resource state prevents the operation",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      },
      "delete": {
        "operationId": "deleteApiV1DashboardLayoutsById",
        "summary": "Delete dashboard layout",
        "tags": [
          "dashboard-layouts"
        ],
        "description": "Soft-deletes a dashboard layout by ID. Returns 404 if the layout does not exist or does not belong to the user.",
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "message"
                  ],
                  "properties": {
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/dashboard/stats": {
      "get": {
        "operationId": "getDashboardStats",
        "summary": "Get dashboard statistics",
        "tags": [
          "dashboard"
        ],
        "description": "Returns aggregated performance stats from the latest reports.",
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "from_date",
            "required": false
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "to_date",
            "required": false
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "timezone",
            "required": false
          },
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "query",
            "name": "user_id",
            "required": false
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "currency",
            "required": false,
            "description": "Target currency code (e.g. EUR, USD). Use \"account\" or omit for original currency."
          },
          {
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "enum": [
                    "postback"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "all"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "meta"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "google"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "tiktok"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "taboola"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "snapchat"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "outbrain"
                  ]
                }
              ]
            },
            "in": "query",
            "name": "conversion_source",
            "required": false,
            "description": "Revenue/conversion data source. \"postback\" (default) uses postback conversions; \"all\" aggregates platform-native purchase data across every platform; a platform value (e.g. \"meta\", \"google\") scopes platform-native revenue to that platform."
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "total_spend",
                    "total_impressions",
                    "total_clicks",
                    "total_conversions",
                    "total_revenue",
                    "roi",
                    "avg_ctr",
                    "campaigns_active",
                    "campaigns_paused",
                    "campaigns_total",
                    "all_campaigns_active",
                    "all_campaigns_paused",
                    "all_campaigns_total",
                    "currency",
                    "accounts",
                    "last_updated"
                  ],
                  "properties": {
                    "total_spend": {
                      "type": "number"
                    },
                    "total_impressions": {
                      "type": "number"
                    },
                    "total_clicks": {
                      "type": "number"
                    },
                    "total_conversions": {
                      "type": "number"
                    },
                    "total_revenue": {
                      "type": "number"
                    },
                    "roi": {
                      "type": "number"
                    },
                    "avg_ctr": {
                      "type": "number"
                    },
                    "campaigns_active": {
                      "type": "number"
                    },
                    "campaigns_paused": {
                      "type": "number"
                    },
                    "campaigns_total": {
                      "type": "number"
                    },
                    "all_campaigns_active": {
                      "type": "number"
                    },
                    "all_campaigns_paused": {
                      "type": "number"
                    },
                    "all_campaigns_total": {
                      "type": "number"
                    },
                    "currency": {
                      "type": "string"
                    },
                    "accounts": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "account_id",
                          "account_name",
                          "spend",
                          "impressions",
                          "clicks",
                          "campaigns",
                          "currency"
                        ],
                        "properties": {
                          "account_id": {
                            "type": "string"
                          },
                          "account_name": {
                            "type": "string"
                          },
                          "spend": {
                            "type": "number"
                          },
                          "impressions": {
                            "type": "number"
                          },
                          "clicks": {
                            "type": "number"
                          },
                          "campaigns": {
                            "type": "number"
                          },
                          "currency": {
                            "type": "string"
                          },
                          "member_name": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          }
                        }
                      }
                    },
                    "last_updated": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/dashboard/team-stats": {
      "get": {
        "operationId": "getDashboardTeamStats",
        "summary": "Get aggregated team statistics (owner only)",
        "tags": [
          "dashboard"
        ],
        "description": "Returns aggregated performance stats across all team members. Only accessible by team owners and super admins.",
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "from_date",
            "required": false
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "to_date",
            "required": false
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "currency",
            "required": false
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "timezone",
            "required": false
          },
          {
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "enum": [
                    "postback"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "all"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "meta"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "google"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "tiktok"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "taboola"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "snapchat"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "outbrain"
                  ]
                }
              ]
            },
            "in": "query",
            "name": "conversion_source",
            "required": false,
            "description": "Revenue/conversion data source. \"postback\" (default) uses postback conversions; \"all\" aggregates platform-native purchase data across every platform; a platform value (e.g. \"meta\", \"google\") scopes platform-native revenue to that platform."
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "total_spend",
                    "total_impressions",
                    "total_clicks",
                    "total_conversions",
                    "total_revenue",
                    "roi",
                    "avg_ctr",
                    "campaigns_active",
                    "campaigns_paused",
                    "campaigns_total",
                    "all_campaigns_active",
                    "all_campaigns_paused",
                    "all_campaigns_total",
                    "members_count",
                    "currency",
                    "last_updated",
                    "accounts"
                  ],
                  "properties": {
                    "total_spend": {
                      "type": "number"
                    },
                    "total_impressions": {
                      "type": "number"
                    },
                    "total_clicks": {
                      "type": "number"
                    },
                    "total_conversions": {
                      "type": "number"
                    },
                    "total_revenue": {
                      "type": "number"
                    },
                    "roi": {
                      "type": "number"
                    },
                    "avg_ctr": {
                      "type": "number"
                    },
                    "campaigns_active": {
                      "type": "number"
                    },
                    "campaigns_paused": {
                      "type": "number"
                    },
                    "campaigns_total": {
                      "type": "number"
                    },
                    "all_campaigns_active": {
                      "type": "number"
                    },
                    "all_campaigns_paused": {
                      "type": "number"
                    },
                    "all_campaigns_total": {
                      "type": "number"
                    },
                    "members_count": {
                      "type": "number"
                    },
                    "currency": {
                      "type": "string"
                    },
                    "last_updated": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "accounts": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "account_id",
                          "account_name",
                          "spend",
                          "impressions",
                          "clicks",
                          "campaigns",
                          "currency"
                        ],
                        "properties": {
                          "account_id": {
                            "type": "string"
                          },
                          "account_name": {
                            "type": "string"
                          },
                          "spend": {
                            "type": "number"
                          },
                          "impressions": {
                            "type": "number"
                          },
                          "clicks": {
                            "type": "number"
                          },
                          "campaigns": {
                            "type": "number"
                          },
                          "currency": {
                            "type": "string"
                          },
                          "member_name": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/dashboard/daily": {
      "get": {
        "operationId": "getDashboardDaily",
        "summary": "Get daily performance breakdown for charting",
        "tags": [
          "dashboard"
        ],
        "description": "Returns daily spend, revenue, profit, and conversion data for charting. Supports timezone conversion, currency conversion, and team/self scoping.",
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "from_date",
            "required": false
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "to_date",
            "required": false
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "timezone",
            "required": false
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "currency",
            "required": false
          },
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "query",
            "name": "user_id",
            "required": false
          },
          {
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "enum": [
                    "self"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "team"
                  ]
                }
              ]
            },
            "in": "query",
            "name": "scope",
            "required": false
          },
          {
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "enum": [
                    "postback"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "all"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "meta"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "google"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "tiktok"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "taboola"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "snapchat"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "outbrain"
                  ]
                }
              ]
            },
            "in": "query",
            "name": "conversion_source",
            "required": false,
            "description": "Revenue/conversion data source. \"postback\" (default) uses postback conversions; \"all\" aggregates platform-native purchase data across every platform; a platform value (e.g. \"meta\", \"google\") scopes platform-native revenue to that platform."
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "days"
                  ],
                  "properties": {
                    "days": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "date",
                          "spend",
                          "revenue",
                          "profit",
                          "conversions"
                        ],
                        "properties": {
                          "date": {
                            "type": "string"
                          },
                          "spend": {
                            "type": "number"
                          },
                          "revenue": {
                            "type": "number"
                          },
                          "profit": {
                            "type": "number"
                          },
                          "conversions": {
                            "type": "number"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/device-push/register": {
      "post": {
        "operationId": "registerDevicePushToken",
        "summary": "Register a native device push token",
        "tags": [
          "device-push"
        ],
        "description": "Stores the APNs/FCM token of the mobile shell for the authenticated user so the backend can deliver native push notifications. Upserts on the token: a device re-registered by another user is re-assigned to that user.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "token",
                  "platform"
                ],
                "properties": {
                  "token": {
                    "minLength": 1,
                    "maxLength": 512,
                    "description": "APNs/FCM device registration token returned by the native push plugin.",
                    "type": "string"
                  },
                  "platform": {
                    "description": "Native platform of the Capacitor shell that produced the token.",
                    "anyOf": [
                      {
                        "type": "string",
                        "enum": [
                          "ios"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "android"
                        ]
                      }
                    ]
                  },
                  "user_agent": {
                    "maxLength": 1024,
                    "description": "Device label or User-Agent captured at registration.",
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "201": {
            "description": "Resource created",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "ok"
                  ],
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "integer"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "request_id": {
                      "type": "string"
                    },
                    "details": {
                      "type": "object",
                      "additionalProperties": {}
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "integer"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "request_id": {
                      "type": "string"
                    },
                    "details": {
                      "type": "object",
                      "additionalProperties": {}
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/device-push/unregister": {
      "post": {
        "operationId": "unregisterDevicePushToken",
        "summary": "Unregister a native device push token",
        "tags": [
          "device-push"
        ],
        "description": "Deletes the stored device push token, only if it belongs to the authenticated user. Idempotent: returns 200 even if the token was already removed or is owned by another user.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "token"
                ],
                "properties": {
                  "token": {
                    "minLength": 1,
                    "maxLength": 512,
                    "description": "Device registration token to unregister.",
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "ok"
                  ],
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "integer"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "request_id": {
                      "type": "string"
                    },
                    "details": {
                      "type": "object",
                      "additionalProperties": {}
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "integer"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "request_id": {
                      "type": "string"
                    },
                    "details": {
                      "type": "object",
                      "additionalProperties": {}
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/ads/duplicate": {
      "post": {
        "operationId": "duplicateAd",
        "summary": "Duplicate an ad",
        "tags": [
          "campaigns"
        ],
        "description": "Creates a copy of an existing Meta ad. With reuse_post=true / post_id_mode=same_post (default) it uses /{ad_id}/copies when possible to preserve the original post and engagement; if Meta rejects a stored legacy creative, it rebuilds a sanitized creative on the same page. Other modes build a new creative (optionally on a different page) and create a fresh ad. Supports cross-account duplication via destination_account_id. Collection ads (\"inserzioni con raccolta\") reuse their existing Instant Experience (Canvas), which is bound to the original page, so they can only be duplicated on the same page (new_post_new_page to a different page returns 400).",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "ad_id",
                  "account_id"
                ],
                "properties": {
                  "ad_id": {
                    "type": "string"
                  },
                  "account_id": {
                    "type": "string"
                  },
                  "adset_id": {
                    "type": "string"
                  },
                  "name": {
                    "type": "string"
                  },
                  "status": {
                    "anyOf": [
                      {
                        "type": "string",
                        "enum": [
                          "ACTIVE"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "PAUSED"
                        ]
                      }
                    ]
                  },
                  "reuse_post": {
                    "type": "boolean"
                  },
                  "destination_account_id": {
                    "type": "string"
                  },
                  "post_id_mode": {
                    "anyOf": [
                      {
                        "type": "string",
                        "enum": [
                          "same_post"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "new_post_same_page"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "new_post_new_page"
                        ]
                      }
                    ]
                  },
                  "fan_page_id": {
                    "type": "string"
                  },
                  "creative_override": {
                    "additionalProperties": false,
                    "type": "object",
                    "properties": {
                      "primary_text": {
                        "type": "string"
                      },
                      "headline": {
                        "type": "string"
                      },
                      "description": {
                        "type": "string"
                      },
                      "call_to_action": {
                        "type": "string"
                      },
                      "link": {
                        "type": "string"
                      },
                      "url_tags": {
                        "type": "string"
                      },
                      "fan_page_id": {
                        "type": "string"
                      },
                      "media": {
                        "additionalProperties": false,
                        "type": "object",
                        "required": [
                          "type",
                          "source_url"
                        ],
                        "properties": {
                          "type": {
                            "anyOf": [
                              {
                                "type": "string",
                                "enum": [
                                  "image"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "video"
                                ]
                              }
                            ]
                          },
                          "source_url": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "ad_id",
                    "message"
                  ],
                  "properties": {
                    "ad_id": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "rename_failed": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/adsets/duplicate": {
      "post": {
        "operationId": "duplicateAdSet",
        "summary": "Duplicate an ad set",
        "tags": [
          "campaigns"
        ],
        "description": "Creates a copy of an existing Meta ad set. Uses the Graph API /{adset_id}/copies endpoint when possible, and falls back to a sequential rebuild when the source ad set has too many ads or Meta rejects a legacy stored creative during native copy. Supports cross-account duplication and post_id_mode (same_post / new_post_same_page / new_post_new_page).",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "adset_id",
                  "account_id"
                ],
                "properties": {
                  "adset_id": {
                    "type": "string"
                  },
                  "account_id": {
                    "type": "string"
                  },
                  "campaign_id": {
                    "type": "string"
                  },
                  "name": {
                    "type": "string"
                  },
                  "status": {
                    "anyOf": [
                      {
                        "type": "string",
                        "enum": [
                          "ACTIVE"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "PAUSED"
                        ]
                      }
                    ]
                  },
                  "deep_copy": {
                    "type": "boolean"
                  },
                  "destination_account_id": {
                    "type": "string"
                  },
                  "post_id_mode": {
                    "anyOf": [
                      {
                        "type": "string",
                        "enum": [
                          "same_post"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "new_post_same_page"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "new_post_new_page"
                        ]
                      }
                    ]
                  },
                  "fan_page_id": {
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "adset_id",
                    "message"
                  ],
                  "properties": {
                    "adset_id": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "rename_failed": {
                      "type": "boolean"
                    },
                    "rename_error": {
                      "type": "string"
                    },
                    "partial": {
                      "description": "True when the ad set was created but Meta rejected one or more ads. See `failures` for details.",
                      "type": "boolean"
                    },
                    "copied_ads": {
                      "description": "Number of ads copied (only present for sequential/cross-account copies, not the native deep copy).",
                      "type": "integer"
                    },
                    "failures": {
                      "description": "Per-child copy failures, with the Meta error message for each.",
                      "type": "array",
                      "items": {
                        "additionalProperties": false,
                        "type": "object",
                        "required": [
                          "level",
                          "source_id",
                          "error"
                        ],
                        "properties": {
                          "level": {
                            "anyOf": [
                              {
                                "type": "string",
                                "enum": [
                                  "adset"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "ad"
                                ]
                              }
                            ]
                          },
                          "source_id": {
                            "type": "string"
                          },
                          "error": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/campaigns/duplicate": {
      "post": {
        "operationId": "duplicateCampaign",
        "summary": "Duplicate a campaign",
        "tags": [
          "campaigns"
        ],
        "description": "Creates a copy of an existing Meta campaign. Uses the Graph API /{campaign_id}/copies endpoint when possible, and falls back to a sequential rebuild when the source campaign has too many nested objects or Meta rejects a legacy stored creative during native copy. Supports cross-account duplication and post_id_mode (same_post / new_post_same_page / new_post_new_page).",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "campaign_id",
                  "account_id"
                ],
                "properties": {
                  "campaign_id": {
                    "type": "string"
                  },
                  "account_id": {
                    "type": "string"
                  },
                  "name": {
                    "type": "string"
                  },
                  "status": {
                    "anyOf": [
                      {
                        "type": "string",
                        "enum": [
                          "ACTIVE"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "PAUSED"
                        ]
                      }
                    ]
                  },
                  "deep_copy": {
                    "type": "boolean"
                  },
                  "destination_account_id": {
                    "type": "string"
                  },
                  "post_id_mode": {
                    "anyOf": [
                      {
                        "type": "string",
                        "enum": [
                          "same_post"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "new_post_same_page"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "new_post_new_page"
                        ]
                      }
                    ]
                  },
                  "fan_page_id": {
                    "type": "string"
                  },
                  "start_time": {
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "campaign_id",
                    "message"
                  ],
                  "properties": {
                    "campaign_id": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "rename_failed": {
                      "type": "boolean"
                    },
                    "rename_error": {
                      "type": "string"
                    },
                    "start_time_failed": {
                      "type": "boolean"
                    },
                    "start_time_error": {
                      "type": "string"
                    },
                    "partial": {
                      "description": "True when the campaign was created but Meta rejected one or more ad sets/ads. See `failures` for details.",
                      "type": "boolean"
                    },
                    "copied_adsets": {
                      "description": "Number of ad sets copied (only present for sequential/cross-account copies, not the native deep copy).",
                      "type": "integer"
                    },
                    "copied_ads": {
                      "description": "Number of ads copied (only present for sequential/cross-account copies, not the native deep copy).",
                      "type": "integer"
                    },
                    "failures": {
                      "description": "Per-child copy failures, with the Meta error message for each.",
                      "type": "array",
                      "items": {
                        "additionalProperties": false,
                        "type": "object",
                        "required": [
                          "level",
                          "source_id",
                          "error"
                        ],
                        "properties": {
                          "level": {
                            "anyOf": [
                              {
                                "type": "string",
                                "enum": [
                                  "adset"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "ad"
                                ]
                              }
                            ]
                          },
                          "source_id": {
                            "type": "string"
                          },
                          "error": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/campaigns/duplicate/compatibility": {
      "post": {
        "operationId": "checkCampaignDuplicateCompatibility",
        "summary": "Pre-flight check for cross-account campaign duplication",
        "tags": [
          "campaigns"
        ],
        "description": "Read-only check (does not duplicate anything): reports whether the destination Meta ad account has access to the Page, Pixel(s), Custom Audience(s) and Product Catalog(s) the source campaign depends on. A missing Page is blocking — nothing would be created in the destination account. A missing Pixel/Audience/Catalog is degraded — only the ad sets/ads that use it would fail to copy, the rest of the campaign still would.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "campaign_id",
                  "account_id",
                  "destination_account_id"
                ],
                "properties": {
                  "campaign_id": {
                    "type": "string"
                  },
                  "account_id": {
                    "type": "string"
                  },
                  "destination_account_id": {
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "compatible",
                    "missing"
                  ],
                  "properties": {
                    "compatible": {
                      "description": "False only when a blocking item (the Page) is inaccessible.",
                      "type": "boolean"
                    },
                    "missing": {
                      "type": "array",
                      "items": {
                        "additionalProperties": false,
                        "type": "object",
                        "required": [
                          "type",
                          "id",
                          "severity"
                        ],
                        "properties": {
                          "type": {
                            "anyOf": [
                              {
                                "type": "string",
                                "enum": [
                                  "page"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "pixel"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "audience"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "product_catalog"
                                ]
                              }
                            ]
                          },
                          "id": {
                            "type": "string"
                          },
                          "name": {
                            "type": "string"
                          },
                          "severity": {
                            "anyOf": [
                              {
                                "type": "string",
                                "enum": [
                                  "blocking"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "degraded"
                                ]
                              }
                            ]
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/fan-pages": {
      "get": {
        "operationId": "getApiV1FanPages",
        "summary": "Get fan pages (server-side paginated)",
        "tags": [
          "fan-pages"
        ],
        "description": "Returns a server-side paginated, filtered, sorted list of Meta Fan Pages. Supports offset pagination, search, and multiple filter dimensions.",
        "parameters": [
          {
            "schema": {
              "minimum": 1,
              "maximum": 100,
              "default": 50,
              "type": "integer"
            },
            "in": "query",
            "name": "limit",
            "required": false
          },
          {
            "schema": {
              "minimum": 0,
              "default": 0,
              "type": "integer"
            },
            "in": "query",
            "name": "offset",
            "required": false
          },
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "query",
            "name": "member_id",
            "required": false
          },
          {
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "enum": [
                    "fan_page_name"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "business_name"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "connected"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "is_active"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "created_at"
                  ]
                }
              ]
            },
            "in": "query",
            "name": "sort_by",
            "required": false
          },
          {
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "enum": [
                    "asc"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "desc"
                  ]
                }
              ]
            },
            "in": "query",
            "name": "sort_order",
            "required": false
          },
          {
            "schema": {
              "minLength": 2,
              "maxLength": 200,
              "type": "string"
            },
            "in": "query",
            "name": "search",
            "required": false
          },
          {
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "enum": [
                    "connected"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "disconnected"
                  ]
                }
              ]
            },
            "in": "query",
            "name": "connected",
            "required": false
          },
          {
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "enum": [
                    "active"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "inactive"
                  ]
                }
              ]
            },
            "in": "query",
            "name": "status",
            "required": false
          },
          {
            "schema": {
              "maxLength": 100,
              "type": "string"
            },
            "in": "query",
            "name": "business_id",
            "required": false
          },
          {
            "schema": {
              "maxLength": 20,
              "type": "string"
            },
            "in": "query",
            "name": "ownership_type",
            "required": false
          },
          {
            "schema": {
              "maxLength": 10,
              "type": "string"
            },
            "in": "query",
            "name": "platform",
            "required": false
          },
          {
            "schema": {
              "format": "date-time",
              "type": "string"
            },
            "in": "query",
            "name": "created_from",
            "required": false
          },
          {
            "schema": {
              "format": "date-time",
              "type": "string"
            },
            "in": "query",
            "name": "created_to",
            "required": false
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "items",
                    "total",
                    "counts"
                  ],
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "id",
                          "fan_page_id",
                          "fan_page_name",
                          "business_id",
                          "business_name",
                          "connected",
                          "is_active",
                          "created_at",
                          "updated_at"
                        ],
                        "properties": {
                          "id": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "fan_page_id": {
                            "type": "string"
                          },
                          "fan_page_name": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "business_id": {
                            "type": "string"
                          },
                          "business_name": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "connected": {
                            "type": "boolean"
                          },
                          "is_active": {
                            "anyOf": [
                              {
                                "type": "boolean"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "platform": {
                            "type": "string"
                          },
                          "created_at": {
                            "format": "date-time",
                            "type": "string"
                          },
                          "updated_at": {
                            "anyOf": [
                              {
                                "format": "date-time",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "sheet_id": {
                            "type": "string"
                          },
                          "member_name": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "member_email": {
                            "type": "string"
                          },
                          "team_name": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          }
                        }
                      }
                    },
                    "total": {
                      "type": "integer"
                    },
                    "counts": {
                      "type": "object",
                      "required": [
                        "total",
                        "connected",
                        "active"
                      ],
                      "properties": {
                        "total": {
                          "type": "integer"
                        },
                        "connected": {
                          "type": "integer"
                        },
                        "active": {
                          "type": "integer"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/fan-pages/businesses": {
      "get": {
        "operationId": "getApiV1FanPagesBusinesses",
        "summary": "List businesses available for fan pages",
        "tags": [
          "fan-pages"
        ],
        "description": "Returns distinct Meta Business Manager ids and names represented by fan pages visible to the caller, respecting admin/team scoping.",
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "items"
                  ],
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "id",
                          "name"
                        ],
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "name": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/fan-pages/{fanPageId}/posts": {
      "get": {
        "operationId": "getApiV1FanPagesByFanPageIdPosts",
        "summary": "Get selectable posts for a fan page",
        "tags": [
          "fan-pages"
        ],
        "description": "Returns the posts of a Meta fan page that can be used as an ad creative: published timeline posts plus the unpublished dark posts created inline by existing ads. Use is_published to tell them apart.",
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "in": "path",
            "name": "fanPageId",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "posts"
                  ],
                  "properties": {
                    "posts": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "id",
                          "message",
                          "full_picture",
                          "created_time",
                          "permalink_url",
                          "is_published"
                        ],
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "message": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "full_picture": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "created_time": {
                            "type": "string"
                          },
                          "permalink_url": {
                            "type": "string"
                          },
                          "is_published": {
                            "description": "False for dark posts — page posts created inline as ad creatives. They are selectable as creative but have no publicly reachable permalink.",
                            "type": "boolean"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/fan-pages/connect": {
      "post": {
        "operationId": "postApiV1FanPagesConnect",
        "summary": "Connect non-Meta fan pages",
        "tags": [
          "fan-pages"
        ],
        "description": "Marks selected non-Meta fan pages or Snapchat public profiles as connected for sessions accessible to the current user.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "fan_page_ids"
                ],
                "properties": {
                  "fan_page_ids": {
                    "minItems": 1,
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "updated"
                  ],
                  "properties": {
                    "updated": {
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/fan-pages/disconnect": {
      "post": {
        "operationId": "postApiV1FanPagesDisconnect",
        "summary": "Disconnect non-Meta fan pages",
        "tags": [
          "fan-pages"
        ],
        "description": "Marks selected non-Meta fan pages or Snapchat public profiles as disconnected for sessions accessible to the current user.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "fan_page_ids"
                ],
                "properties": {
                  "fan_page_ids": {
                    "minItems": 1,
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "updated"
                  ],
                  "properties": {
                    "updated": {
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/featurebase/changelog/ingest": {
      "post": {
        "operationId": "ingestFeaturebaseChangelog",
        "summary": "Create and publish a changelog from CI (shared-secret)",
        "tags": [
          "featurebase"
        ],
        "description": "Webhook-style endpoint called by the GitHub Actions release pipeline. Creates a changelog entry on Featurebase, publishes it (locales default to the bilingual en+it entry, sendEmail opt-in default false) and persists the returned Featurebase post id onto the matching `release_artifact_link` (best-effort) so the publish-followup webhook can correlate status transitions to the release candidate. Auth is **NOT** via JWT - callers present a shared secret in the `x-changelog-ingest-key` header that must match the `CHANGELOG_INGEST_API_KEY` env var (compared with `timingSafeEqual`). Returns 503 when not configured (missing env var or Featurebase plugin), 401 on invalid/missing key, 502 when the Featurebase create/publish call fails. On success returns 201 with the published changelog entry. When the secret is absent the CI workflow falls back to the byte-equivalent direct publish, so this endpoint being unconfigured causes no regression.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "title"
                ],
                "properties": {
                  "title": {
                    "minLength": 1,
                    "type": "string"
                  },
                  "htmlContent": {
                    "minLength": 1,
                    "type": "string"
                  },
                  "markdownContent": {
                    "minLength": 1,
                    "type": "string"
                  },
                  "releaseCandidateId": {
                    "minLength": 1,
                    "type": "string"
                  },
                  "locales": {
                    "minItems": 1,
                    "type": "array",
                    "items": {
                      "minLength": 1,
                      "type": "string"
                    }
                  },
                  "sendEmail": {
                    "type": "boolean"
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "schema": {
              "minLength": 1,
              "type": "string"
            },
            "in": "header",
            "name": "x-changelog-ingest-key",
            "required": true
          }
        ],
        "responses": {
          "201": {
            "description": "Resource created",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object",
                  "required": [
                    "id",
                    "title",
                    "content",
                    "state",
                    "date",
                    "categories"
                  ],
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "title": {
                      "type": "string"
                    },
                    "content": {
                      "type": "string"
                    },
                    "state": {
                      "type": "string"
                    },
                    "date": {
                      "type": "string"
                    },
                    "categories": {
                      "type": "array",
                      "items": {
                        "additionalProperties": true,
                        "type": "object",
                        "required": [
                          "name"
                        ],
                        "properties": {
                          "name": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "502": {
            "description": "Bad gateway - upstream provider failed",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "Service unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ]
      }
    },
    "/api/v1/featurebase/changelog": {
      "get": {
        "operationId": "getApiV1FeaturebaseChangelog",
        "summary": "List published changelogs from Featurebase",
        "tags": [
          "featurebase"
        ],
        "description": "Returns a paginated list of published changelog entries from Featurebase. Public endpoint.",
        "parameters": [
          {
            "schema": {
              "minimum": 1,
              "maximum": 100,
              "default": 20,
              "type": "number"
            },
            "in": "query",
            "name": "limit",
            "required": false
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "cursor",
            "required": false
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "sortBy",
            "required": false
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data"
                  ],
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "additionalProperties": true,
                        "type": "object",
                        "required": [
                          "id",
                          "title",
                          "content",
                          "state",
                          "date",
                          "categories"
                        ],
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "title": {
                            "type": "string"
                          },
                          "content": {
                            "type": "string"
                          },
                          "state": {
                            "type": "string"
                          },
                          "date": {
                            "type": "string"
                          },
                          "categories": {
                            "type": "array",
                            "items": {
                              "additionalProperties": true,
                              "type": "object",
                              "required": [
                                "name"
                              ],
                              "properties": {
                                "name": {
                                  "type": "string"
                                }
                              }
                            }
                          }
                        }
                      }
                    },
                    "nextCursor": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "502": {
            "description": "Bad gateway - upstream provider failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "Service unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "postApiV1FeaturebaseChangelog",
        "summary": "Create a changelog entry on Featurebase",
        "tags": [
          "featurebase"
        ],
        "description": "Creates a new changelog entry on Featurebase and optionally sends a Telegram notification.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "title",
                  "markdownContent"
                ],
                "properties": {
                  "title": {
                    "minLength": 1,
                    "type": "string"
                  },
                  "markdownContent": {
                    "minLength": 1,
                    "type": "string"
                  },
                  "releaseCandidateId": {
                    "minLength": 1,
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "201": {
            "description": "Resource created",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object",
                  "required": [
                    "id",
                    "title",
                    "content",
                    "state",
                    "date",
                    "categories"
                  ],
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "title": {
                      "type": "string"
                    },
                    "content": {
                      "type": "string"
                    },
                    "state": {
                      "type": "string"
                    },
                    "date": {
                      "type": "string"
                    },
                    "categories": {
                      "type": "array",
                      "items": {
                        "additionalProperties": true,
                        "type": "object",
                        "required": [
                          "name"
                        ],
                        "properties": {
                          "name": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "502": {
            "description": "Bad gateway - upstream provider failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "Service unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/featurebase/changelog/{id}": {
      "patch": {
        "operationId": "patchApiV1FeaturebaseChangelogById",
        "summary": "Update a changelog entry on Featurebase",
        "tags": [
          "featurebase"
        ],
        "description": "Updates an existing changelog entry on Featurebase by ID.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "properties": {
                  "title": {
                    "minLength": 1,
                    "type": "string"
                  },
                  "markdownContent": {
                    "minLength": 1,
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "schema": {
              "minLength": 1,
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object",
                  "required": [
                    "id",
                    "title",
                    "content",
                    "state",
                    "date",
                    "categories"
                  ],
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "title": {
                      "type": "string"
                    },
                    "content": {
                      "type": "string"
                    },
                    "state": {
                      "type": "string"
                    },
                    "date": {
                      "type": "string"
                    },
                    "categories": {
                      "type": "array",
                      "items": {
                        "additionalProperties": true,
                        "type": "object",
                        "required": [
                          "name"
                        ],
                        "properties": {
                          "name": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "502": {
            "description": "Bad gateway - upstream provider failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "Service unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/featurebase/changelog/{id}/publish": {
      "post": {
        "operationId": "postApiV1FeaturebaseChangelogByIdPublish",
        "summary": "Publish a changelog entry on Featurebase",
        "tags": [
          "featurebase"
        ],
        "description": "Publishes a draft changelog entry on Featurebase, making it visible to users.",
        "parameters": [
          {
            "schema": {
              "minLength": 1,
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object",
                  "required": [
                    "id",
                    "title",
                    "content",
                    "state",
                    "date",
                    "categories"
                  ],
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "title": {
                      "type": "string"
                    },
                    "content": {
                      "type": "string"
                    },
                    "state": {
                      "type": "string"
                    },
                    "date": {
                      "type": "string"
                    },
                    "categories": {
                      "type": "array",
                      "items": {
                        "additionalProperties": true,
                        "type": "object",
                        "required": [
                          "name"
                        ],
                        "properties": {
                          "name": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "502": {
            "description": "Bad gateway - upstream provider failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "Service unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/featurebase/sso-token": {
      "get": {
        "operationId": "getApiV1FeaturebaseSsoToken",
        "summary": "Generate Featurebase SSO JWT for the current user",
        "tags": [
          "featurebase"
        ],
        "description": "Generates a Featurebase SSO JWT token so the user can be authenticated in the Featurebase widget.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "token"
                  ],
                  "properties": {
                    "token": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "Service unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/featurebase/roadmap": {
      "get": {
        "operationId": "getApiV1FeaturebaseRoadmap",
        "summary": "List roadmap posts from Featurebase",
        "tags": [
          "featurebase"
        ],
        "description": "Returns a paginated list of roadmap posts from Featurebase with optional status and board filters. Public endpoint.",
        "parameters": [
          {
            "schema": {
              "minimum": 1,
              "maximum": 100,
              "default": 50,
              "type": "number"
            },
            "in": "query",
            "name": "limit",
            "required": false
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "cursor",
            "required": false
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "sortBy",
            "required": false
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "status",
            "required": false
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "boardId",
            "required": false
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data"
                  ],
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "additionalProperties": true,
                        "type": "object",
                        "required": [
                          "id",
                          "title",
                          "content",
                          "status",
                          "upvotes",
                          "tags"
                        ],
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "title": {
                            "type": "string"
                          },
                          "content": {
                            "type": "string"
                          },
                          "status": {
                            "type": "string"
                          },
                          "upvotes": {
                            "type": "number"
                          },
                          "tags": {
                            "type": "array",
                            "items": {
                              "type": "string"
                            }
                          }
                        }
                      }
                    },
                    "nextCursor": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "502": {
            "description": "Bad gateway - upstream provider failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "Service unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/featurebase/roadmap/{id}/status": {
      "patch": {
        "operationId": "patchApiV1FeaturebaseRoadmapByIdStatus",
        "summary": "Update roadmap post status on Featurebase",
        "tags": [
          "featurebase"
        ],
        "description": "Updates the status of a roadmap post on Featurebase by post ID.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "statusId"
                ],
                "properties": {
                  "statusId": {
                    "minLength": 1,
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "schema": {
              "minLength": 1,
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object",
                  "required": [
                    "id",
                    "title",
                    "content",
                    "status",
                    "upvotes",
                    "tags"
                  ],
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "title": {
                      "type": "string"
                    },
                    "content": {
                      "type": "string"
                    },
                    "status": {
                      "type": "string"
                    },
                    "upvotes": {
                      "type": "number"
                    },
                    "tags": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "502": {
            "description": "Bad gateway - upstream provider failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "Service unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/webhooks/featurebase": {
      "post": {
        "operationId": "postApiV1WebhooksFeaturebase",
        "summary": "Featurebase webhook endpoint",
        "tags": [
          "webhooks"
        ],
        "description": "Receives Featurebase post/status events. Verified via HMAC-SHA256 over `<X-Webhook-Timestamp>.<raw body>` against FEATUREBASE_WEBHOOK_SECRET, with a 5-minute timestamp tolerance (anti-replay). Both `X-Webhook-Signature` and `X-Webhook-Timestamp` headers are required.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": true,
                "description": "Featurebase webhook payload. Permissive on extra fields because Featurebase may add new event metadata without notice.",
                "type": "object",
                "required": [
                  "topic"
                ],
                "properties": {
                  "topic": {
                    "description": "Featurebase event topic, e.g. `changelog.published` or `post.updated`. Sent unprefixed by Featurebase.",
                    "type": "string"
                  },
                  "post_id": {
                    "type": "string"
                  },
                  "title": {
                    "type": "string"
                  },
                  "content": {
                    "type": "string"
                  },
                  "status": {
                    "type": "string"
                  },
                  "delivery_id": {
                    "type": "string"
                  },
                  "timestamp": {
                    "type": "string"
                  }
                }
              }
            }
          },
          "description": "Featurebase webhook payload. Permissive on extra fields because Featurebase may add new event metadata without notice."
        },
        "security": [
          {
            "featurebaseSignature": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object",
                  "required": [
                    "status"
                  ],
                  "properties": {
                    "status": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "202": {
            "description": "Accepted - processing asynchronously",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object",
                  "required": [
                    "status",
                    "event_id"
                  ],
                  "properties": {
                    "status": {
                      "type": "string"
                    },
                    "event_id": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/ga4/status": {
      "get": {
        "operationId": "getGa4Status",
        "summary": "Get the GA4 data-source connection status",
        "tags": [
          "ga4"
        ],
        "description": "Returns whether the workspace has a Google Analytics 4 read connection, which property is selected, and when it was last read. `configured: false` means the server itself has no GA4 OAuth credentials.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "configured",
                    "connected",
                    "email",
                    "token_status",
                    "last_read_at",
                    "property"
                  ],
                  "properties": {
                    "configured": {
                      "description": "False when the server has no GA4 OAuth credentials.",
                      "type": "boolean"
                    },
                    "connected": {
                      "type": "boolean"
                    },
                    "email": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "token_status": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "last_read_at": {
                      "anyOf": [
                        {
                          "format": "date-time",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "property": {
                      "anyOf": [
                        {
                          "additionalProperties": false,
                          "type": "object",
                          "required": [
                            "id",
                            "name",
                            "currency",
                            "timezone"
                          ],
                          "properties": {
                            "id": {
                              "description": "Numeric GA4 property id.",
                              "type": "string"
                            },
                            "name": {
                              "anyOf": [
                                {
                                  "type": "string"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "currency": {
                              "anyOf": [
                                {
                                  "type": "string"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "timezone": {
                              "anyOf": [
                                {
                                  "type": "string"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            }
                          }
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/ga4/login-url": {
      "get": {
        "operationId": "getGa4LoginUrl",
        "summary": "Start the GA4 read-only OAuth flow",
        "tags": [
          "ga4"
        ],
        "description": "Returns the Google consent URL for the `analytics.readonly` scope. The destination workspace is signed into the OAuth state, so the callback stamps the connection on the active team.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "url"
                  ],
                  "properties": {
                    "url": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "Service unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/ga4/properties": {
      "get": {
        "operationId": "listGa4Properties",
        "summary": "List the GA4 properties visible to the connected Google account",
        "tags": [
          "ga4"
        ],
        "description": "Reads the GA4 Admin API account summaries with the stored consent. Returns 404 when the workspace has no GA4 connection and 401 when the consent was revoked.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "items"
                  ],
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "additionalProperties": false,
                        "type": "object",
                        "required": [
                          "property_id",
                          "display_name",
                          "account_name"
                        ],
                        "properties": {
                          "property_id": {
                            "type": "string"
                          },
                          "display_name": {
                            "type": "string"
                          },
                          "account_name": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "502": {
            "description": "Bad gateway - upstream provider failed",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/ga4/property": {
      "put": {
        "operationId": "selectGa4Property",
        "summary": "Select the GA4 property to read from",
        "tags": [
          "ga4"
        ],
        "description": "Validates the property against the GA4 Admin API with the stored consent, then persists it (with its currency and timezone) on the workspace connection.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "property_id"
                ],
                "properties": {
                  "property_id": {
                    "minLength": 1,
                    "maxLength": 50,
                    "pattern": "^[0-9]+$",
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "property"
                  ],
                  "properties": {
                    "property": {
                      "additionalProperties": false,
                      "type": "object",
                      "required": [
                        "id",
                        "name",
                        "currency",
                        "timezone"
                      ],
                      "properties": {
                        "id": {
                          "description": "Numeric GA4 property id.",
                          "type": "string"
                        },
                        "name": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "currency": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "timezone": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "502": {
            "description": "Bad gateway - upstream provider failed",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/ga4/connection": {
      "delete": {
        "operationId": "disconnectGa4",
        "summary": "Remove the GA4 data-source connection",
        "tags": [
          "ga4"
        ],
        "description": "Deletes the stored consent and property selection for the workspace. Returns `disconnected: false` when there was nothing to remove.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "disconnected"
                  ],
                  "properties": {
                    "disconnected": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/ga4/overview": {
      "get": {
        "operationId": "getGa4Overview",
        "summary": "Read GA4 site metrics for a date range",
        "tags": [
          "ga4"
        ],
        "description": "Runs two GA4 Data API reports on the selected property: totals (sessions, users, new users, page views, key events, revenue) and a breakdown by session source/medium and campaign. Returns 409 when no property is selected yet.",
        "parameters": [
          {
            "schema": {
              "format": "date",
              "type": "string"
            },
            "in": "query",
            "name": "from",
            "required": true,
            "description": "Inclusive start date (YYYY-MM-DD), property timezone."
          },
          {
            "schema": {
              "format": "date",
              "type": "string"
            },
            "in": "query",
            "name": "to",
            "required": true,
            "description": "Inclusive end date (YYYY-MM-DD), property timezone."
          }
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "property",
                    "currency",
                    "date_range",
                    "totals",
                    "breakdown"
                  ],
                  "properties": {
                    "property": {
                      "additionalProperties": false,
                      "type": "object",
                      "required": [
                        "id",
                        "name",
                        "timezone"
                      ],
                      "properties": {
                        "id": {
                          "type": "string"
                        },
                        "name": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "timezone": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        }
                      }
                    },
                    "currency": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "date_range": {
                      "additionalProperties": false,
                      "type": "object",
                      "required": [
                        "from",
                        "to"
                      ],
                      "properties": {
                        "from": {
                          "type": "string"
                        },
                        "to": {
                          "type": "string"
                        }
                      }
                    },
                    "totals": {
                      "additionalProperties": false,
                      "type": "object",
                      "required": [
                        "sessions",
                        "users",
                        "new_users",
                        "page_views",
                        "key_events",
                        "revenue"
                      ],
                      "properties": {
                        "sessions": {
                          "type": "number"
                        },
                        "users": {
                          "type": "number"
                        },
                        "new_users": {
                          "type": "number"
                        },
                        "page_views": {
                          "type": "number"
                        },
                        "key_events": {
                          "type": "number"
                        },
                        "revenue": {
                          "type": "number"
                        }
                      }
                    },
                    "breakdown": {
                      "type": "array",
                      "items": {
                        "additionalProperties": false,
                        "type": "object",
                        "required": [
                          "source_medium",
                          "campaign",
                          "sessions",
                          "key_events",
                          "revenue"
                        ],
                        "properties": {
                          "source_medium": {
                            "type": "string"
                          },
                          "campaign": {
                            "type": "string"
                          },
                          "sessions": {
                            "type": "number"
                          },
                          "key_events": {
                            "type": "number"
                          },
                          "revenue": {
                            "type": "number"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "Conflict - resource state prevents the operation",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "502": {
            "description": "Bad gateway - upstream provider failed",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/geo-search": {
      "get": {
        "operationId": "getApiV1GeoSearch",
        "summary": "Search Meta geo locations for targeting",
        "tags": [
          "targeting"
        ],
        "description": "Proxies Meta Marketing API geo location search for regions and cities.",
        "parameters": [
          {
            "schema": {
              "minLength": 2,
              "maxLength": 100,
              "type": "string"
            },
            "in": "query",
            "name": "q",
            "required": true,
            "description": "Search query (e.g. \"Lombardia\", \"Milano\")"
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "location_types",
            "required": false,
            "description": "Comma-separated location types: region, city"
          },
          {
            "schema": {
              "maxLength": 2,
              "type": "string"
            },
            "in": "query",
            "name": "country_code",
            "required": false,
            "description": "Filter by country code (e.g. IT)"
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "account_id",
            "required": true,
            "description": "Ad account ID to resolve token"
          },
          {
            "schema": {
              "minimum": 1,
              "maximum": 25,
              "default": 10,
              "type": "integer"
            },
            "in": "query",
            "name": "limit",
            "required": false
          }
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "locations"
                  ],
                  "properties": {
                    "locations": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "key",
                          "name",
                          "type",
                          "country_code",
                          "country_name"
                        ],
                        "properties": {
                          "key": {
                            "type": "string"
                          },
                          "name": {
                            "type": "string"
                          },
                          "type": {
                            "type": "string"
                          },
                          "country_code": {
                            "type": "string"
                          },
                          "country_name": {
                            "type": "string"
                          },
                          "region": {
                            "type": "string"
                          },
                          "region_id": {
                            "type": "number"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "integer"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "integer"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/webhooks/github/release-event": {
      "post": {
        "operationId": "postApiV1WebhooksGithubReleaseEvent",
        "summary": "GitHub release-event webhook endpoint",
        "tags": [
          "webhooks"
        ],
        "description": "Receives release candidate events from GitHub Actions. Verified via HMAC-SHA256 signature (`x-hub-signature-256`) on the raw body against GITHUB_WEBHOOK_SECRET.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "pr_id",
                  "title"
                ],
                "properties": {
                  "pr_id": {
                    "type": "string"
                  },
                  "title": {
                    "type": "string"
                  },
                  "body": {
                    "type": "string"
                  },
                  "branch": {
                    "type": "string"
                  },
                  "commit_sha": {
                    "type": "string"
                  },
                  "author": {
                    "type": "string"
                  },
                  "timestamp": {
                    "type": "string"
                  },
                  "clickup_task_id": {
                    "type": "string"
                  },
                  "content_type": {
                    "type": "string"
                  },
                  "product_area": {
                    "type": "string"
                  },
                  "impact_level": {
                    "type": "string"
                  },
                  "user_value_summary": {
                    "type": "string"
                  },
                  "delivery_id": {
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "hmacSha256": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object",
                  "required": [
                    "status"
                  ],
                  "properties": {
                    "status": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "202": {
            "description": "Accepted - processing asynchronously",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object",
                  "required": [
                    "status",
                    "event_id"
                  ],
                  "properties": {
                    "status": {
                      "type": "string"
                    },
                    "event_id": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/google/asset-groups/{assetGroupId}/assets": {
      "get": {
        "operationId": "getGoogleAssetGroupAssets",
        "summary": "Get persisted asset list for a Google PMax asset group",
        "tags": [
          "google"
        ],
        "description": "Returns text + image asset metadata captured at publish time. Status is the snapshot at publish; live status sync is a separate worker.",
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "in": "path",
            "name": "assetGroupId",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "assets"
                  ],
                  "properties": {
                    "assets": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "id",
                          "fieldType",
                          "assetText",
                          "assetImageUrl",
                          "assetVideoId",
                          "assetStatus",
                          "updatedAt"
                        ],
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "fieldType": {
                            "type": "string"
                          },
                          "assetText": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "assetImageUrl": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "assetVideoId": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "assetStatus": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "updatedAt": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/google/search-term-campaigns": {
      "get": {
        "operationId": "listGoogleSearchTermCampaigns",
        "summary": "List Google Ads campaigns with synced search terms",
        "tags": [
          "google"
        ],
        "description": "Returns campaigns discovered from the cached Google Ads search terms. Used as the campaign picker before listing semantic buckets, so buckets and apply-all actions stay campaign-scoped.",
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "customer_id",
            "required": false,
            "description": "Google Ads customer (account) id."
          }
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "items"
                  ],
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "additionalProperties": false,
                        "type": "object",
                        "required": [
                          "campaign_id",
                          "campaign_name",
                          "advertising_channel_type",
                          "term_count",
                          "unreviewed_count",
                          "clicks",
                          "cost_micros",
                          "cost",
                          "conversions"
                        ],
                        "properties": {
                          "campaign_id": {
                            "type": "string"
                          },
                          "campaign_name": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "advertising_channel_type": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "term_count": {
                            "type": "number"
                          },
                          "unreviewed_count": {
                            "type": "number"
                          },
                          "clicks": {
                            "type": "number"
                          },
                          "cost_micros": {
                            "type": "number"
                          },
                          "cost": {
                            "type": "number"
                          },
                          "conversions": {
                            "type": "number"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "Service unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/google/search-term-buckets": {
      "get": {
        "operationId": "listGoogleSearchTermBuckets",
        "summary": "List Google Ads search-term semantic buckets",
        "tags": [
          "google"
        ],
        "description": "Returns semantic buckets built from cached Google Ads search terms. Buckets are denormalized with counts, cost, conversions, representative terms, and AI-generated hints so the UI can review intent groups instead of raw term rows.",
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "customer_id",
            "required": false,
            "description": "Google Ads customer (account) id."
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "campaign_id",
            "required": false,
            "description": "Google Ads campaign id. Required by the UI."
          },
          {
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "enum": [
                    "OPEN"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "EXCLUDED"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "KEPT"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "SNOOZED"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "ARCHIVED"
                  ]
                }
              ]
            },
            "in": "query",
            "name": "status",
            "required": false
          },
          {
            "schema": {
              "minimum": 1,
              "maximum": 200,
              "default": 100,
              "type": "integer"
            },
            "in": "query",
            "name": "limit",
            "required": false
          },
          {
            "schema": {
              "minimum": 0,
              "default": 0,
              "type": "integer"
            },
            "in": "query",
            "name": "offset",
            "required": false
          }
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "items",
                    "total"
                  ],
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "additionalProperties": false,
                        "type": "object",
                        "required": [
                          "id",
                          "customer_id",
                          "campaign_id",
                          "campaign_name",
                          "advertising_channel_type",
                          "label",
                          "hint",
                          "recommended_action",
                          "status",
                          "representative_terms",
                          "term_count",
                          "unreviewed_count",
                          "excluded_count",
                          "kept_count",
                          "snoozed_count",
                          "impressions",
                          "clicks",
                          "cost_micros",
                          "cost",
                          "conversions",
                          "conversions_value",
                          "similarity_threshold",
                          "max_terms",
                          "ai_model",
                          "created_at",
                          "updated_at"
                        ],
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "customer_id": {
                            "type": "string"
                          },
                          "campaign_id": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "campaign_name": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "advertising_channel_type": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "label": {
                            "type": "string"
                          },
                          "hint": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "recommended_action": {
                            "type": "string"
                          },
                          "status": {
                            "type": "string"
                          },
                          "representative_terms": {
                            "type": "array",
                            "items": {
                              "type": "string"
                            }
                          },
                          "term_count": {
                            "type": "number"
                          },
                          "unreviewed_count": {
                            "type": "number"
                          },
                          "excluded_count": {
                            "type": "number"
                          },
                          "kept_count": {
                            "type": "number"
                          },
                          "snoozed_count": {
                            "type": "number"
                          },
                          "impressions": {
                            "type": "number"
                          },
                          "clicks": {
                            "type": "number"
                          },
                          "cost_micros": {
                            "type": "number"
                          },
                          "cost": {
                            "type": "number"
                          },
                          "conversions": {
                            "type": "number"
                          },
                          "conversions_value": {
                            "type": "number"
                          },
                          "similarity_threshold": {
                            "type": "number"
                          },
                          "max_terms": {
                            "type": "number"
                          },
                          "ai_model": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "created_at": {
                            "type": "string"
                          },
                          "updated_at": {
                            "type": "string"
                          }
                        }
                      }
                    },
                    "total": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "Service unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/google/search-term-buckets/{id}/terms": {
      "get": {
        "operationId": "listGoogleSearchTermBucketTerms",
        "summary": "List terms inside a Google Ads search-term bucket",
        "tags": [
          "google"
        ],
        "description": "Returns the raw search-term rows assigned to one semantic bucket. Used by the Review drawer before creating a negative-keyword batch.",
        "parameters": [
          {
            "schema": {
              "minimum": 1,
              "maximum": 500,
              "default": 100,
              "type": "integer"
            },
            "in": "query",
            "name": "limit",
            "required": false
          },
          {
            "schema": {
              "minimum": 0,
              "default": 0,
              "type": "integer"
            },
            "in": "query",
            "name": "offset",
            "required": false
          },
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "items",
                    "total"
                  ],
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "additionalProperties": false,
                        "type": "object",
                        "required": [
                          "id",
                          "customer_id",
                          "source_view",
                          "search_term",
                          "match_type",
                          "review_status",
                          "campaign_id",
                          "campaign_name",
                          "advertising_channel_type",
                          "ad_group_id",
                          "ad_group_name",
                          "clicks",
                          "cost_micros",
                          "conversions",
                          "similarity"
                        ],
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "customer_id": {
                            "type": "string"
                          },
                          "source_view": {
                            "type": "string"
                          },
                          "search_term": {
                            "type": "string"
                          },
                          "match_type": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "review_status": {
                            "type": "string"
                          },
                          "campaign_id": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "campaign_name": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "advertising_channel_type": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "ad_group_id": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "ad_group_name": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "clicks": {
                            "type": "number"
                          },
                          "cost_micros": {
                            "type": "number"
                          },
                          "conversions": {
                            "type": "number"
                          },
                          "similarity": {
                            "anyOf": [
                              {
                                "type": "number"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          }
                        }
                      }
                    },
                    "total": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "Service unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "assignGoogleSearchTermsToBucket",
        "summary": "Save Google Ads search terms in a semantic bucket",
        "tags": [
          "google"
        ],
        "description": "Manually assigns cached search terms to the given bucket (a term belongs to at most one bucket, so this moves them). Bucket and terms must share session and Google account. When the bucket cannot fit the request the call fails with 409 BUCKET_FULL unless create_overflow is set, in which case continuation buckets (\"<label> · 2\") are created on the same account+campaign. Every touched bucket gets its counters refreshed.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "search_term_ids"
                ],
                "properties": {
                  "search_term_ids": {
                    "minItems": 1,
                    "maxItems": 500,
                    "type": "array",
                    "items": {
                      "format": "uuid",
                      "type": "string"
                    }
                  },
                  "create_overflow": {
                    "description": "When the bucket cannot fit the request, create continuation buckets (\"<label> · 2\") instead of failing with BUCKET_FULL. The UI asks the human first.",
                    "type": "boolean"
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "bucket_id",
                    "assigned",
                    "created_buckets"
                  ],
                  "properties": {
                    "bucket_id": {
                      "type": "string"
                    },
                    "assigned": {
                      "description": "Terms actually moved into the bucket (idempotent re-adds excluded).",
                      "type": "number"
                    },
                    "created_buckets": {
                      "description": "Continuation buckets created to absorb the overflow (empty when everything fit).",
                      "type": "array",
                      "items": {
                        "additionalProperties": false,
                        "type": "object",
                        "required": [
                          "id",
                          "label"
                        ],
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "label": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "Conflict - resource state prevents the operation",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error",
                    "code",
                    "capacity_left",
                    "overflow_count",
                    "next_label"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "BUCKET_FULL"
                      ]
                    },
                    "capacity_left": {
                      "type": "number"
                    },
                    "overflow_count": {
                      "type": "number"
                    },
                    "next_label": {
                      "description": "Label of the continuation bucket the retry would create.",
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "Service unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/google/search-terms": {
      "get": {
        "operationId": "listGoogleSearchTerms",
        "summary": "List Google Ads search terms",
        "tags": [
          "google"
        ],
        "description": "Cross-account paginated read of cached Google Ads search terms for the authenticated user, with optional filters (account, campaign, ad group, match type, review status, text, min cost/clicks).",
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "customer_id",
            "required": false,
            "description": "Google Ads customer (account) id."
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "campaign_id",
            "required": false
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "ad_group_id",
            "required": false
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "match_type",
            "required": false,
            "description": "EXACT | PHRASE | BROAD (search_term_view only)."
          },
          {
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "enum": [
                    "search_term_view"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "campaign_search_term_view"
                  ]
                }
              ]
            },
            "in": "query",
            "name": "source_view",
            "required": false
          },
          {
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "enum": [
                    "UNREVIEWED"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "KEPT"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "EXCLUDED"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "SNOOZED"
                  ]
                }
              ]
            },
            "in": "query",
            "name": "review_status",
            "required": false
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "search",
            "required": false,
            "description": "Substring match on the normalized term."
          },
          {
            "schema": {
              "minimum": 0,
              "type": "integer"
            },
            "in": "query",
            "name": "min_cost_micros",
            "required": false
          },
          {
            "schema": {
              "minimum": 0,
              "type": "integer"
            },
            "in": "query",
            "name": "min_clicks",
            "required": false
          },
          {
            "schema": {
              "minimum": 1,
              "maximum": 500,
              "default": 100,
              "type": "integer"
            },
            "in": "query",
            "name": "limit",
            "required": false
          },
          {
            "schema": {
              "minimum": 0,
              "default": 0,
              "type": "integer"
            },
            "in": "query",
            "name": "offset",
            "required": false
          }
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "items",
                    "total"
                  ],
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "additionalProperties": false,
                        "type": "object",
                        "required": [
                          "id",
                          "ai_action",
                          "ai_bucket_id",
                          "ai_bucket_label",
                          "ai_hint",
                          "customer_id",
                          "source_view",
                          "search_term",
                          "normalized_term",
                          "match_type",
                          "term_status",
                          "review_status",
                          "campaign_id",
                          "campaign_name",
                          "advertising_channel_type",
                          "ad_group_id",
                          "ad_group_name",
                          "impressions",
                          "clicks",
                          "cost_micros",
                          "cost",
                          "conversions",
                          "conversions_value",
                          "date_from",
                          "date_to",
                          "synced_at"
                        ],
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "ai_action": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "ai_bucket_id": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "ai_bucket_label": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "ai_hint": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "customer_id": {
                            "type": "string"
                          },
                          "source_view": {
                            "type": "string"
                          },
                          "search_term": {
                            "type": "string"
                          },
                          "normalized_term": {
                            "type": "string"
                          },
                          "match_type": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "term_status": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "review_status": {
                            "type": "string"
                          },
                          "campaign_id": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "campaign_name": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "advertising_channel_type": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "ad_group_id": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "ad_group_name": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "impressions": {
                            "type": "number"
                          },
                          "clicks": {
                            "type": "number"
                          },
                          "cost_micros": {
                            "type": "number"
                          },
                          "cost": {
                            "type": "number"
                          },
                          "conversions": {
                            "type": "number"
                          },
                          "conversions_value": {
                            "type": "number"
                          },
                          "date_from": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "date_to": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "synced_at": {
                            "type": "string"
                          }
                        }
                      }
                    },
                    "total": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "Service unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/google/search-terms/review": {
      "post": {
        "operationId": "reviewGoogleSearchTerms",
        "summary": "Set the review status of Google Ads search terms",
        "tags": [
          "google"
        ],
        "description": "Marks the given cached search terms as KEPT, SNOOZED or back to UNREVIEWED (per-row human decision). EXCLUDED cannot be set here: it is only produced by an applied negative-keyword batch. Rows outside the caller’s accessible sessions are silently skipped.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "ids",
                  "status"
                ],
                "properties": {
                  "ids": {
                    "minItems": 1,
                    "maxItems": 500,
                    "type": "array",
                    "items": {
                      "format": "uuid",
                      "type": "string"
                    }
                  },
                  "status": {
                    "description": "Target review status. EXCLUDED is intentionally absent: it only comes from an applied batch.",
                    "anyOf": [
                      {
                        "type": "string",
                        "enum": [
                          "KEPT"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "SNOOZED"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "UNREVIEWED"
                        ]
                      }
                    ]
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "updated"
                  ],
                  "properties": {
                    "updated": {
                      "description": "Rows actually updated (accessible, not deleted, not EXCLUDED).",
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "Service unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/google/search-term-buckets/{id}/terms/{term_id}": {
      "delete": {
        "operationId": "removeGoogleSearchTermFromBucket",
        "summary": "Remove a Google Ads search term from a semantic bucket",
        "tags": [
          "google"
        ],
        "description": "Detaches one cached search term from the bucket (the term itself is untouched — only the membership is removed). The bucket counters are refreshed.",
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          },
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "term_id",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "removed"
                  ],
                  "properties": {
                    "removed": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "Service unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/google/search-terms/sync": {
      "post": {
        "operationId": "syncGoogleSearchTerms",
        "summary": "Sync Google Ads search terms for an account",
        "tags": [
          "google"
        ],
        "description": "Fetches search_term_view (Search/Shopping) and campaign_search_term_view (Performance Max) for the given connected account and date range, and upserts them into the workspace cache. Preserves prior review decisions.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "account_id",
                  "date_from",
                  "date_to"
                ],
                "properties": {
                  "account_id": {
                    "description": "Google Ads customer (account) id to sync.",
                    "type": "string"
                  },
                  "date_from": {
                    "description": "Inclusive start date (YYYY-MM-DD).",
                    "type": "string"
                  },
                  "date_to": {
                    "description": "Inclusive end date (YYYY-MM-DD).",
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "synced",
                    "customer_id",
                    "classification_queued"
                  ],
                  "properties": {
                    "synced": {
                      "description": "Number of search-term rows upserted.",
                      "type": "number"
                    },
                    "customer_id": {
                      "type": "string"
                    },
                    "classification_queued": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "Service unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/google/term-batches": {
      "get": {
        "operationId": "listGoogleTermBatches",
        "summary": "List Google Ads exclusion batches",
        "tags": [
          "google"
        ],
        "description": "Returns a paginated list of exclusion batches for the authenticated user, with optional account/status filters.",
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "customer_id",
            "required": false
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "status",
            "required": false
          },
          {
            "schema": {
              "minimum": 1,
              "maximum": 100,
              "default": 50,
              "type": "integer"
            },
            "in": "query",
            "name": "limit",
            "required": false
          },
          {
            "schema": {
              "minimum": 0,
              "default": 0,
              "type": "integer"
            },
            "in": "query",
            "name": "offset",
            "required": false
          }
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "items",
                    "total"
                  ],
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "additionalProperties": false,
                        "type": "object",
                        "required": [
                          "id",
                          "customer_id",
                          "status",
                          "name",
                          "total_operations",
                          "succeeded_operations",
                          "failed_operations",
                          "created_at",
                          "applied_at"
                        ],
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "customer_id": {
                            "type": "string"
                          },
                          "status": {
                            "type": "string"
                          },
                          "name": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "total_operations": {
                            "type": "number"
                          },
                          "succeeded_operations": {
                            "type": "number"
                          },
                          "failed_operations": {
                            "type": "number"
                          },
                          "created_at": {
                            "type": "string"
                          },
                          "applied_at": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          }
                        }
                      }
                    },
                    "total": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "Service unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "createGoogleTermBatch",
        "summary": "Create a Google Ads negative-keyword exclusion batch (DRAFT)",
        "tags": [
          "google"
        ],
        "description": "Creates a DRAFT exclusion batch from selected search terms and the chosen scope (ad_group or campaign). Nothing is sent to Google until the batch is validated and approved.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "customer_id",
                  "operations"
                ],
                "properties": {
                  "customer_id": {
                    "description": "Google Ads customer (account) id the negatives apply to.",
                    "type": "string"
                  },
                  "name": {
                    "maxLength": 255,
                    "type": "string"
                  },
                  "source": {
                    "anyOf": [
                      {
                        "type": "string",
                        "enum": [
                          "manual"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "import"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "rule"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "semantic_selection"
                        ]
                      }
                    ]
                  },
                  "operations": {
                    "minItems": 1,
                    "maxItems": 500,
                    "description": "Negative keywords to create (hard cap 500 per batch — a human cannot review more meaningfully).",
                    "type": "array",
                    "items": {
                      "additionalProperties": false,
                      "type": "object",
                      "required": [
                        "scope",
                        "keyword_text",
                        "match_type"
                      ],
                      "properties": {
                        "scope": {
                          "anyOf": [
                            {
                              "type": "string",
                              "enum": [
                                "ad_group"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "campaign"
                              ]
                            }
                          ]
                        },
                        "search_term_id": {
                          "format": "uuid",
                          "type": "string"
                        },
                        "search_term": {
                          "type": "string"
                        },
                        "keyword_text": {
                          "minLength": 1,
                          "maxLength": 80,
                          "type": "string"
                        },
                        "match_type": {
                          "anyOf": [
                            {
                              "type": "string",
                              "enum": [
                                "EXACT"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "PHRASE"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "BROAD"
                              ]
                            }
                          ]
                        },
                        "campaign_id": {
                          "type": "string"
                        },
                        "ad_group_id": {
                          "type": "string"
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "201": {
            "description": "Resource created",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "id",
                    "customer_id",
                    "login_customer_id",
                    "status",
                    "source",
                    "name",
                    "total_operations",
                    "succeeded_operations",
                    "failed_operations",
                    "validate_result",
                    "created_at",
                    "updated_at",
                    "applied_at",
                    "operations"
                  ],
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "customer_id": {
                      "type": "string"
                    },
                    "login_customer_id": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "status": {
                      "type": "string"
                    },
                    "source": {
                      "type": "string"
                    },
                    "name": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "total_operations": {
                      "type": "number"
                    },
                    "succeeded_operations": {
                      "type": "number"
                    },
                    "failed_operations": {
                      "type": "number"
                    },
                    "validate_result": {
                      "anyOf": [
                        {
                          "type": "array",
                          "items": {
                            "additionalProperties": false,
                            "type": "object",
                            "required": [
                              "index",
                              "status",
                              "resourceName",
                              "errorMessage"
                            ],
                            "properties": {
                              "index": {
                                "type": "number"
                              },
                              "status": {
                                "anyOf": [
                                  {
                                    "type": "string",
                                    "enum": [
                                      "SUCCESS"
                                    ]
                                  },
                                  {
                                    "type": "string",
                                    "enum": [
                                      "FAILURE"
                                    ]
                                  }
                                ]
                              },
                              "resourceName": {
                                "anyOf": [
                                  {
                                    "type": "string"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "errorMessage": {
                                "anyOf": [
                                  {
                                    "type": "string"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              }
                            }
                          }
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "created_at": {
                      "type": "string"
                    },
                    "updated_at": {
                      "type": "string"
                    },
                    "applied_at": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "operations": {
                      "type": "array",
                      "items": {
                        "additionalProperties": false,
                        "type": "object",
                        "required": [
                          "id",
                          "scope",
                          "search_term_id",
                          "search_term",
                          "keyword_text",
                          "match_type",
                          "campaign_id",
                          "ad_group_id",
                          "status",
                          "google_resource_name",
                          "error_message"
                        ],
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "scope": {
                            "type": "string"
                          },
                          "search_term_id": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "search_term": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "keyword_text": {
                            "type": "string"
                          },
                          "match_type": {
                            "type": "string"
                          },
                          "campaign_id": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "ad_group_id": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "status": {
                            "type": "string"
                          },
                          "google_resource_name": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "error_message": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "Conflict - resource state prevents the operation",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "502": {
            "description": "Bad gateway - upstream provider failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "Service unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/google/term-batches/{id}/validate": {
      "post": {
        "operationId": "validateGoogleTermBatch",
        "summary": "Validate a Google Ads exclusion batch (validate_only preflight)",
        "tags": [
          "google"
        ],
        "description": "Runs Google validate_only on the batch and stores the per-operation result. Sets the batch to VALIDATED. No mutation is applied.",
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "batch_id",
                    "status",
                    "results"
                  ],
                  "properties": {
                    "batch_id": {
                      "type": "string"
                    },
                    "status": {
                      "type": "string"
                    },
                    "results": {
                      "type": "array",
                      "items": {
                        "additionalProperties": false,
                        "type": "object",
                        "required": [
                          "index",
                          "status",
                          "resourceName",
                          "errorMessage"
                        ],
                        "properties": {
                          "index": {
                            "type": "number"
                          },
                          "status": {
                            "anyOf": [
                              {
                                "type": "string",
                                "enum": [
                                  "SUCCESS"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "FAILURE"
                                ]
                              }
                            ]
                          },
                          "resourceName": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "errorMessage": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "Conflict - resource state prevents the operation",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "502": {
            "description": "Bad gateway - upstream provider failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "Service unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/google/term-batches/{id}/approve": {
      "post": {
        "operationId": "approveGoogleTermBatch",
        "summary": "Approve a Google Ads exclusion batch and apply it asynchronously",
        "tags": [
          "google"
        ],
        "description": "Freezes the batch and enqueues the async apply worker (BULK lane). Idempotency-keyed to dedupe re-submits. Poll GET /term-batches/:id for the terminal status (DONE / PARTIAL / FAILED).",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "properties": {
                  "idempotency_key": {
                    "maxLength": 255,
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "batch_id",
                    "status"
                  ],
                  "properties": {
                    "batch_id": {
                      "type": "string"
                    },
                    "status": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "Conflict - resource state prevents the operation",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "502": {
            "description": "Bad gateway - upstream provider failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "Service unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/google/term-batches/{id}": {
      "get": {
        "operationId": "getGoogleTermBatch",
        "summary": "Get a Google Ads exclusion batch with its operations",
        "tags": [
          "google"
        ],
        "description": "Returns the batch, its status/counters, the stored validate_only result and per-operation results.",
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "id",
                    "customer_id",
                    "login_customer_id",
                    "status",
                    "source",
                    "name",
                    "total_operations",
                    "succeeded_operations",
                    "failed_operations",
                    "validate_result",
                    "created_at",
                    "updated_at",
                    "applied_at",
                    "operations"
                  ],
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "customer_id": {
                      "type": "string"
                    },
                    "login_customer_id": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "status": {
                      "type": "string"
                    },
                    "source": {
                      "type": "string"
                    },
                    "name": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "total_operations": {
                      "type": "number"
                    },
                    "succeeded_operations": {
                      "type": "number"
                    },
                    "failed_operations": {
                      "type": "number"
                    },
                    "validate_result": {
                      "anyOf": [
                        {
                          "type": "array",
                          "items": {
                            "additionalProperties": false,
                            "type": "object",
                            "required": [
                              "index",
                              "status",
                              "resourceName",
                              "errorMessage"
                            ],
                            "properties": {
                              "index": {
                                "type": "number"
                              },
                              "status": {
                                "anyOf": [
                                  {
                                    "type": "string",
                                    "enum": [
                                      "SUCCESS"
                                    ]
                                  },
                                  {
                                    "type": "string",
                                    "enum": [
                                      "FAILURE"
                                    ]
                                  }
                                ]
                              },
                              "resourceName": {
                                "anyOf": [
                                  {
                                    "type": "string"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "errorMessage": {
                                "anyOf": [
                                  {
                                    "type": "string"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              }
                            }
                          }
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "created_at": {
                      "type": "string"
                    },
                    "updated_at": {
                      "type": "string"
                    },
                    "applied_at": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "operations": {
                      "type": "array",
                      "items": {
                        "additionalProperties": false,
                        "type": "object",
                        "required": [
                          "id",
                          "scope",
                          "search_term_id",
                          "search_term",
                          "keyword_text",
                          "match_type",
                          "campaign_id",
                          "ad_group_id",
                          "status",
                          "google_resource_name",
                          "error_message"
                        ],
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "scope": {
                            "type": "string"
                          },
                          "search_term_id": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "search_term": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "keyword_text": {
                            "type": "string"
                          },
                          "match_type": {
                            "type": "string"
                          },
                          "campaign_id": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "ad_group_id": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "status": {
                            "type": "string"
                          },
                          "google_resource_name": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "error_message": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "Conflict - resource state prevents the operation",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "502": {
            "description": "Bad gateway - upstream provider failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "Service unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/hourly-sync": {
      "post": {
        "operationId": "triggerHourlySync",
        "summary": "Sync hourly spend data from Meta",
        "tags": [
          "sync"
        ],
        "description": "Triggers hourly spend data collection from the Meta API for the specified date range. Required for timezone-aware spend calculations.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "from_date",
                  "to_date"
                ],
                "properties": {
                  "from_date": {
                    "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
                    "description": "Date in YYYY-MM-DD",
                    "type": "string"
                  },
                  "to_date": {
                    "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
                    "description": "Date in YYYY-MM-DD",
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "message",
                    "synced"
                  ],
                  "properties": {
                    "message": {
                      "type": "string"
                    },
                    "synced": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/dashboard/hourly-stats": {
      "get": {
        "operationId": "getHourlyStats",
        "summary": "Get hourly spend stats with timezone conversion",
        "tags": [
          "dashboard"
        ],
        "description": "Returns spending data aggregated by day from hourly records, optionally converted to a target timezone.",
        "parameters": [
          {
            "schema": {
              "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
              "type": "string"
            },
            "in": "query",
            "name": "from_date",
            "required": true,
            "description": "Date in YYYY-MM-DD"
          },
          {
            "schema": {
              "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
              "type": "string"
            },
            "in": "query",
            "name": "to_date",
            "required": true,
            "description": "Date in YYYY-MM-DD"
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "timezone",
            "required": false,
            "description": "IANA timezone (e.g. Europe/Rome) or \"account\""
          }
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data",
                    "timezone"
                  ],
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "date",
                          "spend",
                          "impressions",
                          "clicks"
                        ],
                        "properties": {
                          "date": {
                            "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
                            "type": "string"
                          },
                          "spend": {
                            "type": "number"
                          },
                          "impressions": {
                            "type": "number"
                          },
                          "clicks": {
                            "type": "number"
                          }
                        }
                      }
                    },
                    "timezone": {
                      "type": "string"
                    },
                    "total_entries": {
                      "type": "number"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/insights/ads/lookup": {
      "get": {
        "operationId": "lookupInsightsAds",
        "summary": "Search ads for filter comboboxes",
        "tags": [
          "insights"
        ],
        "description": "Returns ad id/name pairs matching the search string for use in filter comboboxes.",
        "parameters": [
          {
            "schema": {
              "minLength": 2,
              "maxLength": 200,
              "type": "string"
            },
            "in": "query",
            "name": "search",
            "required": false
          },
          {
            "schema": {
              "minimum": 1,
              "maximum": 200,
              "default": 50,
              "type": "integer"
            },
            "in": "query",
            "name": "limit",
            "required": false
          },
          {
            "schema": {
              "minimum": 0,
              "default": 0,
              "type": "integer"
            },
            "in": "query",
            "name": "offset",
            "required": false
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "ad_account_id",
            "required": false,
            "description": "Scope ad options to a single ad account (cascade filtering)."
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "adset_id",
            "required": false,
            "description": "Scope ad options to a single ad set (cascade filtering)."
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "platform",
            "required": false,
            "description": "Scope ad options to a single network ('meta', 'google', …). 'all' means no filter."
          },
          {
            "schema": {
              "type": "boolean"
            },
            "in": "query",
            "name": "connected_only",
            "required": false,
            "description": "Restrict ad options to the ad accounts flagged as connected."
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "items",
                    "total"
                  ],
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "value",
                          "label"
                        ],
                        "properties": {
                          "value": {
                            "type": "string"
                          },
                          "label": {
                            "type": "string"
                          }
                        }
                      }
                    },
                    "total": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/insights/ads": {
      "get": {
        "operationId": "listAdInsights",
        "summary": "Get ad insights",
        "tags": [
          "insights"
        ],
        "description": "Returns paginated ad-level performance data with spend, clicks, impressions, postback conversions, and computed metrics. Supports drill-down by adset/campaign, timezone and currency conversion, filtering, and sorting.",
        "parameters": [
          {
            "schema": {
              "format": "date",
              "type": "string"
            },
            "in": "query",
            "name": "from_date",
            "required": true
          },
          {
            "schema": {
              "format": "date",
              "type": "string"
            },
            "in": "query",
            "name": "to_date",
            "required": true
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "adset_id",
            "required": false
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "adset_ids",
            "required": false,
            "description": "Comma-separated adset IDs for multi-drill-down"
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "campaign_id",
            "required": false
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "campaign_ids",
            "required": false,
            "description": "Comma-separated campaign IDs for multi-drill-down"
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "account_id",
            "required": false
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "timezone",
            "required": false
          },
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "query",
            "name": "member_id",
            "required": false,
            "description": "Filter to a single team member. Admins/owners may pass any accessible member id; other roles may only pass their own user id."
          },
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "query",
            "name": "team_owner_id",
            "required": false
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "currency",
            "required": false,
            "description": "Target currency code (e.g. EUR, USD). Use \"account\" or omit for original currency."
          },
          {
            "schema": {
              "minimum": 1,
              "type": "number"
            },
            "in": "query",
            "name": "page",
            "required": false
          },
          {
            "schema": {
              "minimum": 1,
              "maximum": 500,
              "type": "number"
            },
            "in": "query",
            "name": "page_size",
            "required": false
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "sort_by",
            "required": false
          },
          {
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "enum": [
                    "asc"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "desc"
                  ]
                }
              ]
            },
            "in": "query",
            "name": "sort_order",
            "required": false
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "search",
            "required": false
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "filters",
            "required": false
          },
          {
            "schema": {
              "type": "boolean"
            },
            "in": "query",
            "name": "include_filter_options",
            "required": false
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "platform",
            "required": false
          },
          {
            "schema": {
              "type": "boolean"
            },
            "in": "query",
            "name": "connected_only",
            "required": false,
            "description": "Restrict rows to the ad accounts flagged as connected, i.e. the ones the caller actively works on."
          },
          {
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "enum": [
                    "postback"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "all"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "meta"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "google"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "tiktok"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "taboola"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "snapchat"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "outbrain"
                  ]
                }
              ]
            },
            "in": "query",
            "name": "conversion_source",
            "required": false,
            "description": "Revenue/conversion data source. \"postback\" (default) uses postback conversions; \"all\" aggregates platform-native purchase data across every platform; a platform value (e.g. \"meta\", \"google\") scopes platform-native revenue to that platform."
          },
          {
            "schema": {
              "type": "boolean"
            },
            "in": "query",
            "name": "include_tracker",
            "required": false
          },
          {
            "schema": {
              "type": "boolean"
            },
            "in": "query",
            "name": "include_tracker_totals",
            "required": false
          },
          {
            "schema": {
              "type": "boolean"
            },
            "in": "query",
            "name": "include_postback_totals",
            "required": false
          },
          {
            "schema": {
              "type": "boolean"
            },
            "in": "query",
            "name": "include_postback_unattributed",
            "required": false
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "items",
                    "total",
                    "totalCount",
                    "page",
                    "pageSize",
                    "totals"
                  ],
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "additionalProperties": true,
                        "description": "Ad-level insight row. Permissive on extra fields because Meta exposes optional metrics that may be enabled per-account.",
                        "type": "object",
                        "required": [
                          "ad_id",
                          "ad_name",
                          "adset_id",
                          "adset_name",
                          "campaign_id",
                          "campaign_name",
                          "ad_account_id",
                          "account_name",
                          "account_status",
                          "ad_status",
                          "adset_status",
                          "campaign_status",
                          "account_currency",
                          "creative_thumbnail_url",
                          "creative_thumbnail_proxy",
                          "creative_thumbnail_proxy_large",
                          "spend",
                          "impressions",
                          "clicks",
                          "reach",
                          "frequency",
                          "link_clicks",
                          "purchases",
                          "leads",
                          "purchase_value",
                          "add_to_cart",
                          "conversions",
                          "ctr",
                          "cpc",
                          "cpm",
                          "cost_per_purchase",
                          "cost_per_lead",
                          "pb_conversions",
                          "pb_revenue",
                          "pb_profit",
                          "pb_roi",
                          "pixel_conversions",
                          "pixel_conv_value",
                          "member_name",
                          "team_name"
                        ],
                        "properties": {
                          "ad_id": {
                            "type": "string"
                          },
                          "ad_name": {
                            "type": "string"
                          },
                          "adset_id": {
                            "type": "string"
                          },
                          "adset_name": {
                            "type": "string"
                          },
                          "campaign_id": {
                            "type": "string"
                          },
                          "campaign_name": {
                            "type": "string"
                          },
                          "ad_account_id": {
                            "type": "string"
                          },
                          "account_name": {
                            "type": "string"
                          },
                          "account_status": {
                            "anyOf": [
                              {
                                "type": "number"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "ad_status": {
                            "type": "string"
                          },
                          "adset_status": {
                            "type": "string"
                          },
                          "campaign_status": {
                            "type": "string"
                          },
                          "ad_review_feedback": {
                            "description": "Meta ad-review/rejection reasons (global + per-placement reason→text maps). null for non-Meta or approved ads.",
                            "anyOf": [
                              {
                                "$comment": "json-value",
                                "description": "Arbitrary JSON value with nested arrays and objects."
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "account_currency": {
                            "type": "string"
                          },
                          "creative_thumbnail_url": {
                            "type": "string"
                          },
                          "creative_thumbnail_proxy": {
                            "type": "string"
                          },
                          "creative_thumbnail_proxy_large": {
                            "description": "Signed proxy URL for the 320×320 preview, used for hover-card previews in the ads grid.",
                            "type": "string"
                          },
                          "spend": {
                            "description": "Spend in target currency (converted via EUR base when currency param is set).",
                            "type": "number"
                          },
                          "impressions": {
                            "type": "number"
                          },
                          "clicks": {
                            "type": "number"
                          },
                          "reach": {
                            "type": "number"
                          },
                          "frequency": {
                            "type": "number"
                          },
                          "link_clicks": {
                            "type": "number"
                          },
                          "purchases": {
                            "type": "number"
                          },
                          "leads": {
                            "type": "number"
                          },
                          "complete_registration": {
                            "type": "number"
                          },
                          "purchase_value": {
                            "type": "number"
                          },
                          "add_to_cart": {
                            "type": "number"
                          },
                          "initiate_checkout": {
                            "type": "number"
                          },
                          "add_payment_info": {
                            "type": "number"
                          },
                          "subscribe": {
                            "type": "number"
                          },
                          "start_trial": {
                            "type": "number"
                          },
                          "schedule": {
                            "type": "number"
                          },
                          "find_location": {
                            "type": "number"
                          },
                          "submit_application": {
                            "type": "number"
                          },
                          "donate": {
                            "type": "number"
                          },
                          "customize_product": {
                            "type": "number"
                          },
                          "conversions": {
                            "type": "number"
                          },
                          "ctr": {
                            "type": "number"
                          },
                          "cpc": {
                            "type": "number"
                          },
                          "cpm": {
                            "type": "number"
                          },
                          "cost_per_purchase": {
                            "type": "number"
                          },
                          "cost_per_lead": {
                            "type": "number"
                          },
                          "cost_per_complete_registration": {
                            "type": "number"
                          },
                          "pb_conversions": {
                            "description": "Postback conversions (or Meta purchases when conversion_source=meta).",
                            "type": "number"
                          },
                          "pb_revenue": {
                            "type": "number"
                          },
                          "pb_profit": {
                            "type": "number"
                          },
                          "pb_roi": {
                            "description": "Postback ROI (%) = (revenue - spend) / spend * 100.",
                            "type": "number"
                          },
                          "pixel_conversions": {
                            "type": "number"
                          },
                          "pixel_conv_value": {
                            "type": "number"
                          },
                          "member_name": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "member_email": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "team_name": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "structure_synced_at": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "tracker_clicks": {
                            "type": "number"
                          },
                          "tracker_conversions": {
                            "type": "number"
                          },
                          "tracker_revenue": {
                            "type": "number"
                          },
                          "tracker_cost": {
                            "type": "number"
                          },
                          "tracker_profit": {
                            "type": "number"
                          },
                          "tracker_roi": {
                            "type": "number"
                          },
                          "tracker_cr": {
                            "type": "number"
                          },
                          "tracker_cpa": {
                            "anyOf": [
                              {
                                "type": "number"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "tracker_roas": {
                            "anyOf": [
                              {
                                "type": "number"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          }
                        }
                      }
                    },
                    "total": {
                      "type": "number"
                    },
                    "totalCount": {
                      "type": "number"
                    },
                    "page": {
                      "type": "number"
                    },
                    "pageSize": {
                      "type": "number"
                    },
                    "totals": {
                      "additionalProperties": true,
                      "description": "Aggregated totals across all returned ad rows. Permissive on extra fields for forward-compat with new metrics.",
                      "type": "object",
                      "required": [
                        "spend",
                        "impressions",
                        "clicks",
                        "reach",
                        "purchases",
                        "leads",
                        "complete_registration",
                        "purchase_value",
                        "add_to_cart",
                        "initiate_checkout",
                        "add_payment_info",
                        "subscribe",
                        "start_trial",
                        "schedule",
                        "find_location",
                        "submit_application",
                        "donate",
                        "customize_product",
                        "conversions",
                        "link_clicks",
                        "ctr",
                        "cpc",
                        "cpm",
                        "cost_per_purchase",
                        "cost_per_lead",
                        "cost_per_complete_registration",
                        "cost_per_add_to_cart",
                        "cost_per_initiate_checkout",
                        "cost_per_add_payment_info",
                        "cost_per_subscribe",
                        "cost_per_start_trial",
                        "profit",
                        "roi",
                        "roas",
                        "aov",
                        "frequency",
                        "activeCount",
                        "pb_conversions",
                        "pb_revenue",
                        "pb_profit",
                        "pb_roi",
                        "pb_unattributed_conversions",
                        "pb_unattributed_revenue"
                      ],
                      "properties": {
                        "spend": {
                          "type": "number"
                        },
                        "impressions": {
                          "type": "number"
                        },
                        "clicks": {
                          "type": "number"
                        },
                        "reach": {
                          "type": "number"
                        },
                        "purchases": {
                          "type": "number"
                        },
                        "leads": {
                          "type": "number"
                        },
                        "complete_registration": {
                          "type": "number"
                        },
                        "purchase_value": {
                          "type": "number"
                        },
                        "add_to_cart": {
                          "type": "number"
                        },
                        "initiate_checkout": {
                          "type": "number"
                        },
                        "add_payment_info": {
                          "type": "number"
                        },
                        "subscribe": {
                          "type": "number"
                        },
                        "start_trial": {
                          "type": "number"
                        },
                        "schedule": {
                          "type": "number"
                        },
                        "find_location": {
                          "type": "number"
                        },
                        "submit_application": {
                          "type": "number"
                        },
                        "donate": {
                          "type": "number"
                        },
                        "customize_product": {
                          "type": "number"
                        },
                        "conversions": {
                          "type": "number"
                        },
                        "link_clicks": {
                          "type": "number"
                        },
                        "ctr": {
                          "type": "number"
                        },
                        "cpc": {
                          "type": "number"
                        },
                        "cpm": {
                          "type": "number"
                        },
                        "cost_per_purchase": {
                          "type": "number"
                        },
                        "cost_per_lead": {
                          "type": "number"
                        },
                        "cost_per_complete_registration": {
                          "type": "number"
                        },
                        "cost_per_add_to_cart": {
                          "type": "number"
                        },
                        "cost_per_initiate_checkout": {
                          "type": "number"
                        },
                        "cost_per_add_payment_info": {
                          "type": "number"
                        },
                        "cost_per_subscribe": {
                          "type": "number"
                        },
                        "cost_per_start_trial": {
                          "type": "number"
                        },
                        "profit": {
                          "type": "number"
                        },
                        "roi": {
                          "type": "number"
                        },
                        "roas": {
                          "type": "number"
                        },
                        "aov": {
                          "type": "number"
                        },
                        "frequency": {
                          "type": "number"
                        },
                        "activeCount": {
                          "type": "number"
                        },
                        "pb_conversions": {
                          "type": "number"
                        },
                        "pb_revenue": {
                          "type": "number"
                        },
                        "pb_profit": {
                          "type": "number"
                        },
                        "pb_roi": {
                          "type": "number"
                        },
                        "pb_unattributed_conversions": {
                          "type": "number"
                        },
                        "pb_unattributed_revenue": {
                          "type": "number"
                        },
                        "tracker_clicks": {
                          "type": "number"
                        },
                        "tracker_conversions": {
                          "type": "number"
                        },
                        "tracker_revenue": {
                          "type": "number"
                        },
                        "tracker_cost": {
                          "type": "number"
                        },
                        "tracker_profit": {
                          "type": "number"
                        },
                        "tracker_roi": {
                          "type": "number"
                        },
                        "tracker_cr": {
                          "type": "number"
                        },
                        "tracker_cpa": {
                          "anyOf": [
                            {
                              "type": "number"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "tracker_roas": {
                          "anyOf": [
                            {
                              "type": "number"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        }
                      }
                    },
                    "filterOptions": {
                      "description": "Dynamic map of filter field → available options. Typical keys: ad_status, adset_status, campaign_status, account_status, member_name, team_name.",
                      "type": "object",
                      "additionalProperties": {
                        "type": "array",
                        "items": {
                          "type": "object",
                          "required": [
                            "value",
                            "label"
                          ],
                          "properties": {
                            "value": {
                              "type": "string"
                            },
                            "label": {
                              "type": "string"
                            }
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "detail": {
                      "additionalProperties": true,
                      "type": "object",
                      "properties": {
                        "message": {
                          "type": "string"
                        },
                        "code": {
                          "type": "string"
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/insights/adsets/lookup": {
      "get": {
        "operationId": "lookupInsightsAdsets",
        "summary": "Search adsets for filter comboboxes",
        "tags": [
          "insights"
        ],
        "description": "Returns adset id/name pairs matching the search string for use in filter comboboxes.",
        "parameters": [
          {
            "schema": {
              "minLength": 2,
              "maxLength": 200,
              "type": "string"
            },
            "in": "query",
            "name": "search",
            "required": false
          },
          {
            "schema": {
              "minimum": 1,
              "maximum": 200,
              "default": 50,
              "type": "integer"
            },
            "in": "query",
            "name": "limit",
            "required": false
          },
          {
            "schema": {
              "minimum": 0,
              "default": 0,
              "type": "integer"
            },
            "in": "query",
            "name": "offset",
            "required": false
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "ad_account_id",
            "required": false,
            "description": "Scope adset options to a single ad account (cascade filtering)."
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "account_id",
            "required": false,
            "description": "Alias of ad_account_id: scope adset options to a single ad account."
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "campaign_id",
            "required": false,
            "description": "Scope adset options to a single campaign (cascade filtering, takes priority)."
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "platform",
            "required": false,
            "description": "Scope adset options to a single network ('meta', 'google', …). 'all' means no filter."
          },
          {
            "schema": {
              "type": "boolean"
            },
            "in": "query",
            "name": "connected_only",
            "required": false,
            "description": "Restrict adset options to the ad accounts flagged as connected."
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "items",
                    "total"
                  ],
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "value",
                          "label"
                        ],
                        "properties": {
                          "value": {
                            "type": "string"
                          },
                          "label": {
                            "type": "string"
                          }
                        }
                      }
                    },
                    "total": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/insights/adsets": {
      "get": {
        "operationId": "getApiV1InsightsAdsets",
        "summary": "Get adset insights",
        "tags": [
          "insights"
        ],
        "description": "Returns paginated adset performance data with spend, clicks, impressions, postback conversions, and computed metrics. Supports drill-down by campaign, timezone and currency conversion, filtering, and sorting.",
        "parameters": [
          {
            "schema": {
              "format": "date",
              "type": "string"
            },
            "in": "query",
            "name": "from_date",
            "required": true
          },
          {
            "schema": {
              "format": "date",
              "type": "string"
            },
            "in": "query",
            "name": "to_date",
            "required": true
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "campaign_id",
            "required": false
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "campaign_ids",
            "required": false,
            "description": "Comma-separated campaign IDs for multi-drill-down"
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "account_id",
            "required": false
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "timezone",
            "required": false
          },
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "query",
            "name": "member_id",
            "required": false,
            "description": "Filter to a single team member. Admins/owners may pass any accessible member id; other roles may only pass their own user id."
          },
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "query",
            "name": "team_owner_id",
            "required": false
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "currency",
            "required": false,
            "description": "Target currency code (e.g. EUR, USD). Use \"account\" or omit for original currency."
          },
          {
            "schema": {
              "minimum": 1,
              "type": "number"
            },
            "in": "query",
            "name": "page",
            "required": false
          },
          {
            "schema": {
              "minimum": 1,
              "maximum": 500,
              "type": "number"
            },
            "in": "query",
            "name": "page_size",
            "required": false
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "sort_by",
            "required": false
          },
          {
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "enum": [
                    "asc"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "desc"
                  ]
                }
              ]
            },
            "in": "query",
            "name": "sort_order",
            "required": false
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "search",
            "required": false
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "filters",
            "required": false
          },
          {
            "schema": {
              "type": "boolean"
            },
            "in": "query",
            "name": "include_filter_options",
            "required": false
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "platform",
            "required": false
          },
          {
            "schema": {
              "type": "boolean"
            },
            "in": "query",
            "name": "connected_only",
            "required": false,
            "description": "Restrict rows to the ad accounts flagged as connected, i.e. the ones the caller actively works on."
          },
          {
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "enum": [
                    "postback"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "all"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "meta"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "google"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "tiktok"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "taboola"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "snapchat"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "outbrain"
                  ]
                }
              ]
            },
            "in": "query",
            "name": "conversion_source",
            "required": false,
            "description": "Revenue/conversion data source. \"postback\" (default) uses postback conversions; \"all\" aggregates platform-native purchase data across every platform; a platform value (e.g. \"meta\", \"google\") scopes platform-native revenue to that platform."
          },
          {
            "schema": {
              "type": "boolean"
            },
            "in": "query",
            "name": "include_tracker",
            "required": false
          },
          {
            "schema": {
              "type": "boolean"
            },
            "in": "query",
            "name": "include_tracker_totals",
            "required": false
          },
          {
            "schema": {
              "type": "boolean"
            },
            "in": "query",
            "name": "include_postback_totals",
            "required": false
          },
          {
            "schema": {
              "type": "boolean"
            },
            "in": "query",
            "name": "include_postback_unattributed",
            "required": false
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "items",
                    "total",
                    "totalCount",
                    "page",
                    "pageSize",
                    "totals"
                  ],
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "additionalProperties": true,
                        "description": "Adset-level insight row. Permissive on extra fields because Meta exposes optional metrics that may be enabled per-account.",
                        "type": "object",
                        "required": [
                          "adset_id",
                          "adset_name",
                          "campaign_id",
                          "campaign_name",
                          "ad_account_id",
                          "account_name",
                          "account_status",
                          "adset_status",
                          "campaign_status",
                          "account_currency",
                          "bid_strategy",
                          "spend",
                          "impressions",
                          "clicks",
                          "reach",
                          "frequency",
                          "link_clicks",
                          "purchases",
                          "leads",
                          "purchase_value",
                          "add_to_cart",
                          "conversions",
                          "bid_amount",
                          "daily_budget",
                          "lifetime_budget",
                          "ctr",
                          "cpc",
                          "cpm",
                          "cost_per_purchase",
                          "cost_per_lead",
                          "pb_conversions",
                          "pb_revenue",
                          "pb_profit",
                          "pb_roi",
                          "pixel_conversions",
                          "pixel_conv_value",
                          "member_name",
                          "team_name"
                        ],
                        "properties": {
                          "adset_id": {
                            "type": "string"
                          },
                          "adset_name": {
                            "type": "string"
                          },
                          "campaign_id": {
                            "type": "string"
                          },
                          "campaign_name": {
                            "type": "string"
                          },
                          "ad_account_id": {
                            "type": "string"
                          },
                          "account_name": {
                            "type": "string"
                          },
                          "account_status": {
                            "anyOf": [
                              {
                                "type": "number"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "adset_status": {
                            "type": "string"
                          },
                          "campaign_status": {
                            "type": "string"
                          },
                          "account_currency": {
                            "type": "string"
                          },
                          "bid_strategy": {
                            "type": "string"
                          },
                          "spend": {
                            "type": "number"
                          },
                          "impressions": {
                            "type": "number"
                          },
                          "clicks": {
                            "type": "number"
                          },
                          "reach": {
                            "type": "number"
                          },
                          "frequency": {
                            "type": "number"
                          },
                          "link_clicks": {
                            "type": "number"
                          },
                          "purchases": {
                            "type": "number"
                          },
                          "leads": {
                            "type": "number"
                          },
                          "complete_registration": {
                            "type": "number"
                          },
                          "purchase_value": {
                            "type": "number"
                          },
                          "add_to_cart": {
                            "type": "number"
                          },
                          "initiate_checkout": {
                            "type": "number"
                          },
                          "add_payment_info": {
                            "type": "number"
                          },
                          "subscribe": {
                            "type": "number"
                          },
                          "start_trial": {
                            "type": "number"
                          },
                          "schedule": {
                            "type": "number"
                          },
                          "find_location": {
                            "type": "number"
                          },
                          "submit_application": {
                            "type": "number"
                          },
                          "donate": {
                            "type": "number"
                          },
                          "customize_product": {
                            "type": "number"
                          },
                          "conversions": {
                            "type": "number"
                          },
                          "bid_amount": {
                            "type": "number"
                          },
                          "daily_budget": {
                            "type": "number"
                          },
                          "lifetime_budget": {
                            "type": "number"
                          },
                          "ctr": {
                            "type": "number"
                          },
                          "cpc": {
                            "type": "number"
                          },
                          "cpm": {
                            "type": "number"
                          },
                          "cost_per_purchase": {
                            "type": "number"
                          },
                          "cost_per_lead": {
                            "type": "number"
                          },
                          "cost_per_complete_registration": {
                            "type": "number"
                          },
                          "pb_conversions": {
                            "type": "number"
                          },
                          "pb_revenue": {
                            "type": "number"
                          },
                          "pb_profit": {
                            "type": "number"
                          },
                          "pb_roi": {
                            "type": "number"
                          },
                          "pixel_conversions": {
                            "type": "number"
                          },
                          "pixel_conv_value": {
                            "type": "number"
                          },
                          "member_name": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "member_email": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "team_name": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "tracker_clicks": {
                            "type": "number"
                          },
                          "tracker_conversions": {
                            "type": "number"
                          },
                          "tracker_revenue": {
                            "type": "number"
                          },
                          "tracker_cost": {
                            "type": "number"
                          },
                          "tracker_profit": {
                            "type": "number"
                          },
                          "tracker_roi": {
                            "type": "number"
                          },
                          "tracker_cr": {
                            "type": "number"
                          },
                          "tracker_cpa": {
                            "anyOf": [
                              {
                                "type": "number"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "tracker_roas": {
                            "anyOf": [
                              {
                                "type": "number"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          }
                        }
                      }
                    },
                    "total": {
                      "type": "number"
                    },
                    "totalCount": {
                      "type": "number"
                    },
                    "page": {
                      "type": "number"
                    },
                    "pageSize": {
                      "type": "number"
                    },
                    "totals": {
                      "additionalProperties": true,
                      "description": "Aggregated totals across all returned adset rows. Permissive on extra fields for forward-compat with new metrics.",
                      "type": "object",
                      "required": [
                        "spend",
                        "impressions",
                        "clicks",
                        "reach",
                        "purchases",
                        "leads",
                        "complete_registration",
                        "purchase_value",
                        "add_to_cart",
                        "initiate_checkout",
                        "add_payment_info",
                        "subscribe",
                        "start_trial",
                        "schedule",
                        "find_location",
                        "submit_application",
                        "donate",
                        "customize_product",
                        "conversions",
                        "link_clicks",
                        "ctr",
                        "cpc",
                        "cpm",
                        "cost_per_purchase",
                        "cost_per_lead",
                        "cost_per_complete_registration",
                        "cost_per_add_to_cart",
                        "cost_per_initiate_checkout",
                        "cost_per_add_payment_info",
                        "cost_per_subscribe",
                        "cost_per_start_trial",
                        "profit",
                        "roi",
                        "roas",
                        "aov",
                        "frequency",
                        "activeCount",
                        "pb_conversions",
                        "pb_revenue",
                        "pb_profit",
                        "pb_roi",
                        "pb_unattributed_conversions",
                        "pb_unattributed_revenue"
                      ],
                      "properties": {
                        "spend": {
                          "type": "number"
                        },
                        "impressions": {
                          "type": "number"
                        },
                        "clicks": {
                          "type": "number"
                        },
                        "reach": {
                          "type": "number"
                        },
                        "purchases": {
                          "type": "number"
                        },
                        "leads": {
                          "type": "number"
                        },
                        "complete_registration": {
                          "type": "number"
                        },
                        "purchase_value": {
                          "type": "number"
                        },
                        "add_to_cart": {
                          "type": "number"
                        },
                        "initiate_checkout": {
                          "type": "number"
                        },
                        "add_payment_info": {
                          "type": "number"
                        },
                        "subscribe": {
                          "type": "number"
                        },
                        "start_trial": {
                          "type": "number"
                        },
                        "schedule": {
                          "type": "number"
                        },
                        "find_location": {
                          "type": "number"
                        },
                        "submit_application": {
                          "type": "number"
                        },
                        "donate": {
                          "type": "number"
                        },
                        "customize_product": {
                          "type": "number"
                        },
                        "conversions": {
                          "type": "number"
                        },
                        "link_clicks": {
                          "type": "number"
                        },
                        "ctr": {
                          "type": "number"
                        },
                        "cpc": {
                          "type": "number"
                        },
                        "cpm": {
                          "type": "number"
                        },
                        "cost_per_purchase": {
                          "type": "number"
                        },
                        "cost_per_lead": {
                          "type": "number"
                        },
                        "cost_per_complete_registration": {
                          "type": "number"
                        },
                        "cost_per_add_to_cart": {
                          "type": "number"
                        },
                        "cost_per_initiate_checkout": {
                          "type": "number"
                        },
                        "cost_per_add_payment_info": {
                          "type": "number"
                        },
                        "cost_per_subscribe": {
                          "type": "number"
                        },
                        "cost_per_start_trial": {
                          "type": "number"
                        },
                        "profit": {
                          "type": "number"
                        },
                        "roi": {
                          "type": "number"
                        },
                        "roas": {
                          "type": "number"
                        },
                        "aov": {
                          "type": "number"
                        },
                        "frequency": {
                          "type": "number"
                        },
                        "activeCount": {
                          "type": "number"
                        },
                        "pb_conversions": {
                          "type": "number"
                        },
                        "pb_revenue": {
                          "type": "number"
                        },
                        "pb_profit": {
                          "type": "number"
                        },
                        "pb_roi": {
                          "type": "number"
                        },
                        "pb_unattributed_conversions": {
                          "type": "number"
                        },
                        "pb_unattributed_revenue": {
                          "type": "number"
                        },
                        "tracker_clicks": {
                          "type": "number"
                        },
                        "tracker_conversions": {
                          "type": "number"
                        },
                        "tracker_revenue": {
                          "type": "number"
                        },
                        "tracker_cost": {
                          "type": "number"
                        },
                        "tracker_profit": {
                          "type": "number"
                        },
                        "tracker_roi": {
                          "type": "number"
                        },
                        "tracker_cr": {
                          "type": "number"
                        },
                        "tracker_cpa": {
                          "anyOf": [
                            {
                              "type": "number"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "tracker_roas": {
                          "anyOf": [
                            {
                              "type": "number"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        }
                      }
                    },
                    "filterOptions": {
                      "description": "Dynamic map of filter field → available options. Typical keys: adset_status, campaign_status, account_status, bid_strategy, member_name, team_name.",
                      "type": "object",
                      "additionalProperties": {
                        "type": "array",
                        "items": {
                          "type": "object",
                          "required": [
                            "value",
                            "label"
                          ],
                          "properties": {
                            "value": {
                              "type": "string"
                            },
                            "label": {
                              "type": "string"
                            }
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "detail": {}
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/insights/date-range": {
      "get": {
        "operationId": "getInsightsDateRange",
        "summary": "Get available date range for insights",
        "tags": [
          "insights"
        ],
        "description": "Returns the earliest and latest dates available in campaign daily insights for the user's sessions.",
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "min_date",
                    "max_date"
                  ],
                  "properties": {
                    "min_date": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "max_date": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/insights/campaigns/lookup": {
      "get": {
        "operationId": "lookupInsightsCampaigns",
        "summary": "Search campaigns for filter comboboxes",
        "tags": [
          "insights"
        ],
        "description": "Returns campaign id/name pairs matching the search string for use in filter comboboxes.",
        "parameters": [
          {
            "schema": {
              "minLength": 2,
              "maxLength": 200,
              "type": "string"
            },
            "in": "query",
            "name": "search",
            "required": false
          },
          {
            "schema": {
              "minimum": 1,
              "maximum": 200,
              "default": 50,
              "type": "integer"
            },
            "in": "query",
            "name": "limit",
            "required": false
          },
          {
            "schema": {
              "minimum": 0,
              "default": 0,
              "type": "integer"
            },
            "in": "query",
            "name": "offset",
            "required": false
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "account_id",
            "required": false,
            "description": "Scope campaign options to a single ad account (cascade filtering)."
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "platform",
            "required": false,
            "description": "Scope campaign options to a single network ('meta', 'google', …). 'all' means no filter."
          },
          {
            "schema": {
              "type": "boolean"
            },
            "in": "query",
            "name": "connected_only",
            "required": false,
            "description": "Restrict campaign options to the ad accounts flagged as connected."
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "items",
                    "total"
                  ],
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "value",
                          "label"
                        ],
                        "properties": {
                          "value": {
                            "type": "string"
                          },
                          "label": {
                            "type": "string"
                          }
                        }
                      }
                    },
                    "total": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/insights/ad-accounts/lookup": {
      "get": {
        "operationId": "lookupInsightsAdAccounts",
        "summary": "Search ad accounts for filter comboboxes",
        "tags": [
          "insights"
        ],
        "description": "Returns ad account id/name pairs matching the search string for use in filter comboboxes.",
        "parameters": [
          {
            "schema": {
              "minLength": 2,
              "maxLength": 200,
              "type": "string"
            },
            "in": "query",
            "name": "search",
            "required": false
          },
          {
            "schema": {
              "minimum": 1,
              "maximum": 200,
              "default": 50,
              "type": "integer"
            },
            "in": "query",
            "name": "limit",
            "required": false
          },
          {
            "schema": {
              "minimum": 0,
              "default": 0,
              "type": "integer"
            },
            "in": "query",
            "name": "offset",
            "required": false
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "platform",
            "required": false,
            "description": "Scope account options to a single network ('meta', 'google', …). 'all' means no filter."
          },
          {
            "schema": {
              "type": "boolean"
            },
            "in": "query",
            "name": "connected_only",
            "required": false,
            "description": "Restrict account options to the ad accounts flagged as connected."
          },
          {
            "schema": {
              "type": "boolean"
            },
            "in": "query",
            "name": "include_without_data",
            "required": false,
            "description": "Also return the connected ad accounts that have no insight row yet. For pickers that choose a publishing destination, where a brand new account is a legitimate answer."
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "items",
                    "total"
                  ],
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "value",
                          "label"
                        ],
                        "properties": {
                          "value": {
                            "type": "string"
                          },
                          "label": {
                            "type": "string"
                          }
                        }
                      }
                    },
                    "total": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/insights-campaigns/commerce-overlay": {
      "get": {
        "operationId": "getCommerceCampaignOverlay",
        "summary": "Get commerce (CDM) overlay metrics for campaign insights",
        "tags": [
          "insights"
        ],
        "description": "Returns normalized commerce revenue, order, COGS, gross-profit, ROAS, and attribution coverage metrics for up to 200 campaign ids in the requested date range.",
        "parameters": [
          {
            "schema": {
              "anyOf": [
                {
                  "type": "array",
                  "items": {
                    "type": "string"
                  }
                },
                {
                  "type": "string"
                }
              ]
            },
            "in": "query",
            "name": "campaign_ids[]",
            "required": false
          },
          {
            "schema": {
              "anyOf": [
                {
                  "type": "array",
                  "items": {
                    "type": "string"
                  }
                },
                {
                  "type": "string"
                }
              ]
            },
            "in": "query",
            "name": "campaign_ids",
            "required": false
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "currency",
            "required": false
          },
          {
            "schema": {
              "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
              "type": "string"
            },
            "in": "query",
            "name": "from",
            "required": true
          },
          {
            "schema": {
              "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
              "type": "string"
            },
            "in": "query",
            "name": "to",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "required": [
                      "attribution_coverage_pct",
                      "campaign_id",
                      "commerce_cogs",
                      "commerce_gross_profit",
                      "commerce_orders",
                      "commerce_revenue",
                      "commerce_roas",
                      "currency"
                    ],
                    "properties": {
                      "attribution_coverage_pct": {
                        "anyOf": [
                          {
                            "type": "number"
                          },
                          {
                            "type": "null"
                          }
                        ]
                      },
                      "campaign_id": {
                        "type": "string"
                      },
                      "commerce_cogs": {
                        "type": "number"
                      },
                      "commerce_gross_profit": {
                        "type": "number"
                      },
                      "commerce_orders": {
                        "type": "number"
                      },
                      "commerce_revenue": {
                        "type": "number"
                      },
                      "commerce_roas": {
                        "anyOf": [
                          {
                            "type": "number"
                          },
                          {
                            "type": "null"
                          }
                        ]
                      },
                      "currency": {
                        "type": "string"
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/insights/campaigns": {
      "get": {
        "operationId": "getInsightsCampaigns",
        "summary": "Get campaign insights",
        "tags": [
          "insights"
        ],
        "description": "Returns paginated campaign performance data with spend, clicks, impressions, postback conversions, and computed metrics. Supports timezone conversion, currency conversion, filtering, sorting, and team member scoping.",
        "parameters": [
          {
            "schema": {
              "format": "date",
              "type": "string"
            },
            "in": "query",
            "name": "from_date",
            "required": true
          },
          {
            "schema": {
              "format": "date",
              "type": "string"
            },
            "in": "query",
            "name": "to_date",
            "required": true
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "account_id",
            "required": false
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "timezone",
            "required": false
          },
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "query",
            "name": "member_id",
            "required": false,
            "description": "Filter to a single team member. Admins/owners may pass any accessible member id; other roles may only pass their own user id."
          },
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "query",
            "name": "team_owner_id",
            "required": false
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "currency",
            "required": false,
            "description": "Target currency code (e.g. EUR, USD). Use \"account\" or omit for original currency."
          },
          {
            "schema": {
              "minimum": 1,
              "type": "number"
            },
            "in": "query",
            "name": "page",
            "required": false
          },
          {
            "schema": {
              "minimum": 1,
              "maximum": 500,
              "type": "number"
            },
            "in": "query",
            "name": "page_size",
            "required": false
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "sort_by",
            "required": false
          },
          {
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "enum": [
                    "asc"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "desc"
                  ]
                }
              ]
            },
            "in": "query",
            "name": "sort_order",
            "required": false
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "search",
            "required": false
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "filters",
            "required": false
          },
          {
            "schema": {
              "type": "boolean"
            },
            "in": "query",
            "name": "include_filter_options",
            "required": false
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "platform",
            "required": false
          },
          {
            "schema": {
              "type": "boolean"
            },
            "in": "query",
            "name": "connected_only",
            "required": false,
            "description": "Restrict rows to the ad accounts flagged as connected, i.e. the ones the caller actively works on."
          },
          {
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "enum": [
                    "postback"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "all"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "meta"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "google"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "tiktok"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "taboola"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "snapchat"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "outbrain"
                  ]
                }
              ]
            },
            "in": "query",
            "name": "conversion_source",
            "required": false,
            "description": "Revenue/conversion data source. \"postback\" (default) uses postback conversions; \"all\" aggregates platform-native purchase data across every platform; a platform value (e.g. \"meta\", \"google\") scopes platform-native revenue to that platform."
          },
          {
            "schema": {
              "type": "boolean"
            },
            "in": "query",
            "name": "include_tracker",
            "required": false
          },
          {
            "schema": {
              "type": "boolean"
            },
            "in": "query",
            "name": "include_tracker_totals",
            "required": false
          },
          {
            "schema": {
              "type": "boolean"
            },
            "in": "query",
            "name": "include_postback_totals",
            "required": false
          },
          {
            "schema": {
              "type": "boolean"
            },
            "in": "query",
            "name": "include_postback_unattributed",
            "required": false
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "items",
                    "total",
                    "totalCount",
                    "page",
                    "pageSize",
                    "totals"
                  ],
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "additionalProperties": true,
                        "description": "Campaign-level insight row. Permissive on extra fields because Meta exposes optional metrics that may be enabled per-account.",
                        "type": "object",
                        "required": [
                          "campaign_id",
                          "campaign_name",
                          "ad_account_id",
                          "account_name",
                          "account_status",
                          "campaign_status",
                          "objective",
                          "account_currency",
                          "bid_strategy",
                          "spend",
                          "impressions",
                          "clicks",
                          "reach",
                          "frequency",
                          "link_clicks",
                          "purchases",
                          "leads",
                          "purchase_value",
                          "add_to_cart",
                          "conversions",
                          "daily_budget",
                          "lifetime_budget",
                          "ctr",
                          "cpc",
                          "cpm",
                          "cost_per_purchase",
                          "cost_per_lead",
                          "pb_conversions",
                          "pb_revenue",
                          "pb_profit",
                          "pb_roi",
                          "pixel_conversions",
                          "pixel_conv_value",
                          "member_name",
                          "team_name"
                        ],
                        "properties": {
                          "campaign_id": {
                            "type": "string"
                          },
                          "campaign_name": {
                            "type": "string"
                          },
                          "ad_account_id": {
                            "type": "string"
                          },
                          "account_name": {
                            "type": "string"
                          },
                          "account_status": {
                            "anyOf": [
                              {
                                "type": "number"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "campaign_status": {
                            "type": "string"
                          },
                          "objective": {
                            "type": "string"
                          },
                          "account_currency": {
                            "type": "string"
                          },
                          "bid_strategy": {
                            "type": "string"
                          },
                          "spend": {
                            "type": "number"
                          },
                          "impressions": {
                            "type": "number"
                          },
                          "clicks": {
                            "type": "number"
                          },
                          "reach": {
                            "type": "number"
                          },
                          "frequency": {
                            "type": "number"
                          },
                          "link_clicks": {
                            "type": "number"
                          },
                          "purchases": {
                            "type": "number"
                          },
                          "leads": {
                            "type": "number"
                          },
                          "complete_registration": {
                            "type": "number"
                          },
                          "purchase_value": {
                            "type": "number"
                          },
                          "add_to_cart": {
                            "type": "number"
                          },
                          "initiate_checkout": {
                            "type": "number"
                          },
                          "add_payment_info": {
                            "type": "number"
                          },
                          "subscribe": {
                            "type": "number"
                          },
                          "start_trial": {
                            "type": "number"
                          },
                          "schedule": {
                            "type": "number"
                          },
                          "find_location": {
                            "type": "number"
                          },
                          "submit_application": {
                            "type": "number"
                          },
                          "donate": {
                            "type": "number"
                          },
                          "customize_product": {
                            "type": "number"
                          },
                          "conversions": {
                            "type": "number"
                          },
                          "daily_budget": {
                            "type": "number"
                          },
                          "lifetime_budget": {
                            "type": "number"
                          },
                          "ctr": {
                            "type": "number"
                          },
                          "cpc": {
                            "type": "number"
                          },
                          "cpm": {
                            "type": "number"
                          },
                          "cost_per_purchase": {
                            "type": "number"
                          },
                          "cost_per_lead": {
                            "type": "number"
                          },
                          "cost_per_complete_registration": {
                            "type": "number"
                          },
                          "pb_conversions": {
                            "type": "number"
                          },
                          "pb_revenue": {
                            "type": "number"
                          },
                          "pb_profit": {
                            "type": "number"
                          },
                          "pb_roi": {
                            "type": "number"
                          },
                          "pixel_conversions": {
                            "type": "number"
                          },
                          "pixel_conv_value": {
                            "type": "number"
                          },
                          "member_name": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "member_email": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "team_name": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "tracker_clicks": {
                            "type": "number"
                          },
                          "tracker_conversions": {
                            "type": "number"
                          },
                          "tracker_revenue": {
                            "type": "number"
                          },
                          "tracker_cost": {
                            "type": "number"
                          },
                          "tracker_profit": {
                            "type": "number"
                          },
                          "tracker_roi": {
                            "type": "number"
                          },
                          "tracker_cr": {
                            "type": "number"
                          },
                          "tracker_cpa": {
                            "anyOf": [
                              {
                                "type": "number"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "tracker_roas": {
                            "anyOf": [
                              {
                                "type": "number"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          }
                        }
                      }
                    },
                    "total": {
                      "type": "number"
                    },
                    "totalCount": {
                      "type": "number"
                    },
                    "page": {
                      "type": "number"
                    },
                    "pageSize": {
                      "type": "number"
                    },
                    "totals": {
                      "additionalProperties": true,
                      "description": "Aggregated totals across all returned campaign rows. Permissive on extra fields for forward-compat with new metrics.",
                      "type": "object",
                      "required": [
                        "spend",
                        "impressions",
                        "clicks",
                        "reach",
                        "purchases",
                        "leads",
                        "complete_registration",
                        "purchase_value",
                        "add_to_cart",
                        "initiate_checkout",
                        "add_payment_info",
                        "subscribe",
                        "start_trial",
                        "schedule",
                        "find_location",
                        "submit_application",
                        "donate",
                        "customize_product",
                        "conversions",
                        "link_clicks",
                        "ctr",
                        "cpc",
                        "cpm",
                        "cost_per_purchase",
                        "cost_per_lead",
                        "cost_per_complete_registration",
                        "cost_per_add_to_cart",
                        "cost_per_initiate_checkout",
                        "cost_per_add_payment_info",
                        "cost_per_subscribe",
                        "cost_per_start_trial",
                        "profit",
                        "roi",
                        "roas",
                        "aov",
                        "frequency",
                        "activeCount",
                        "pb_conversions",
                        "pb_revenue",
                        "pb_profit",
                        "pb_roi",
                        "pb_unattributed_conversions",
                        "pb_unattributed_revenue"
                      ],
                      "properties": {
                        "spend": {
                          "type": "number"
                        },
                        "impressions": {
                          "type": "number"
                        },
                        "clicks": {
                          "type": "number"
                        },
                        "reach": {
                          "type": "number"
                        },
                        "purchases": {
                          "type": "number"
                        },
                        "leads": {
                          "type": "number"
                        },
                        "complete_registration": {
                          "type": "number"
                        },
                        "purchase_value": {
                          "type": "number"
                        },
                        "add_to_cart": {
                          "type": "number"
                        },
                        "initiate_checkout": {
                          "type": "number"
                        },
                        "add_payment_info": {
                          "type": "number"
                        },
                        "subscribe": {
                          "type": "number"
                        },
                        "start_trial": {
                          "type": "number"
                        },
                        "schedule": {
                          "type": "number"
                        },
                        "find_location": {
                          "type": "number"
                        },
                        "submit_application": {
                          "type": "number"
                        },
                        "donate": {
                          "type": "number"
                        },
                        "customize_product": {
                          "type": "number"
                        },
                        "conversions": {
                          "type": "number"
                        },
                        "link_clicks": {
                          "type": "number"
                        },
                        "ctr": {
                          "type": "number"
                        },
                        "cpc": {
                          "type": "number"
                        },
                        "cpm": {
                          "type": "number"
                        },
                        "cost_per_purchase": {
                          "type": "number"
                        },
                        "cost_per_lead": {
                          "type": "number"
                        },
                        "cost_per_complete_registration": {
                          "type": "number"
                        },
                        "cost_per_add_to_cart": {
                          "type": "number"
                        },
                        "cost_per_initiate_checkout": {
                          "type": "number"
                        },
                        "cost_per_add_payment_info": {
                          "type": "number"
                        },
                        "cost_per_subscribe": {
                          "type": "number"
                        },
                        "cost_per_start_trial": {
                          "type": "number"
                        },
                        "profit": {
                          "type": "number"
                        },
                        "roi": {
                          "type": "number"
                        },
                        "roas": {
                          "type": "number"
                        },
                        "aov": {
                          "type": "number"
                        },
                        "frequency": {
                          "type": "number"
                        },
                        "activeCount": {
                          "type": "number"
                        },
                        "pb_conversions": {
                          "type": "number"
                        },
                        "pb_revenue": {
                          "type": "number"
                        },
                        "pb_profit": {
                          "type": "number"
                        },
                        "pb_roi": {
                          "type": "number"
                        },
                        "pb_unattributed_conversions": {
                          "type": "number"
                        },
                        "pb_unattributed_revenue": {
                          "type": "number"
                        },
                        "tracker_clicks": {
                          "type": "number"
                        },
                        "tracker_conversions": {
                          "type": "number"
                        },
                        "tracker_revenue": {
                          "type": "number"
                        },
                        "tracker_cost": {
                          "type": "number"
                        },
                        "tracker_profit": {
                          "type": "number"
                        },
                        "tracker_roi": {
                          "type": "number"
                        },
                        "tracker_cr": {
                          "type": "number"
                        },
                        "tracker_cpa": {
                          "anyOf": [
                            {
                              "type": "number"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "tracker_roas": {
                          "anyOf": [
                            {
                              "type": "number"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        }
                      }
                    },
                    "filterOptions": {
                      "description": "Dynamic map of filter field → available options. Typical keys: campaign_status, account_status, objective, bid_strategy, member_name, team_name.",
                      "type": "object",
                      "additionalProperties": {
                        "type": "array",
                        "items": {
                          "type": "object",
                          "required": [
                            "value",
                            "label"
                          ],
                          "properties": {
                            "value": {
                              "type": "string"
                            },
                            "label": {
                              "type": "string"
                            }
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "detail": {}
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/insights/sync-campaign-statuses": {
      "post": {
        "operationId": "postApiV1InsightsSyncCampaignStatuses",
        "summary": "Sync campaign statuses from Meta",
        "tags": [
          "insights"
        ],
        "description": "Fetches all campaigns (including archived/deleted) from Meta API and upserts their statuses into campaign_daily_insight. Runs in the background with debouncing.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "synced"
                  ],
                  "properties": {
                    "synced": {
                      "type": "number"
                    },
                    "status": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/insights/backfill": {
      "post": {
        "operationId": "postApiV1InsightsBackfill",
        "summary": "Backfill historical insights from Meta",
        "tags": [
          "insights"
        ],
        "description": "Triggers a historical backfill of campaign insights for the last N days (default 30, max 365). Splits the date range into 30-day chunks distributed via SQS workers.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "days": {
                    "minimum": 1,
                    "maximum": 365,
                    "default": 30,
                    "type": "number"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "status"
                  ],
                  "properties": {
                    "status": {
                      "type": "string"
                    },
                    "worker_run_id": {
                      "type": "string"
                    },
                    "days": {
                      "type": "number"
                    },
                    "chunks": {
                      "type": "number"
                    },
                    "from_date": {
                      "type": "string"
                    },
                    "to_date": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/insights/refresh-now": {
      "post": {
        "operationId": "postApiV1InsightsRefreshNow",
        "summary": "On-demand Meta insight refresh for current user",
        "tags": [
          "insights"
        ],
        "description": "Triggers an immediate insight collection for the current user sessions only. Per-user debounced (5 min). Returns 202 immediately; work happens in the background.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "202": {
            "description": "Accepted - processing asynchronously",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "status",
                    "message"
                  ],
                  "properties": {
                    "status": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "sessions": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/integrations/status": {
      "get": {
        "operationId": "getIntegrationStatuses",
        "summary": "Get active integration statuses",
        "tags": [
          "integrations"
        ],
        "description": "Returns connection/configuration status for active integrations shown in the marketplace. Status is inferred from existing DB rows and server configuration.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "items"
                  ],
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "additionalProperties": false,
                        "type": "object",
                        "required": [
                          "slug",
                          "status",
                          "detail",
                          "connected_at",
                          "last_sync_at"
                        ],
                        "properties": {
                          "slug": {
                            "type": "string"
                          },
                          "status": {
                            "anyOf": [
                              {
                                "type": "string",
                                "enum": [
                                  "connected"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "configured"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "not_connected"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "error"
                                ]
                              }
                            ]
                          },
                          "detail": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "connected_at": {
                            "anyOf": [
                              {
                                "format": "date-time",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "last_sync_at": {
                            "anyOf": [
                              {
                                "format": "date-time",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/integrations/votes": {
      "get": {
        "operationId": "getIntegrationVotes",
        "summary": "Get integration request votes",
        "tags": [
          "integrations"
        ],
        "description": "Returns vote counts for votable marketplace integrations and whether the authenticated user has already voted for each integration.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "items"
                  ],
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "additionalProperties": false,
                        "type": "object",
                        "required": [
                          "integration_slug",
                          "count",
                          "voted"
                        ],
                        "properties": {
                          "integration_slug": {
                            "type": "string"
                          },
                          "count": {
                            "minimum": 0,
                            "type": "integer"
                          },
                          "voted": {
                            "type": "boolean"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/integrations/{slug}/vote": {
      "post": {
        "operationId": "voteIntegrationRequest",
        "summary": "Vote for a coming-soon integration",
        "tags": [
          "integrations"
        ],
        "description": "Adds one idempotent vote from the authenticated user for a coming-soon integration.",
        "parameters": [
          {
            "schema": {
              "minLength": 1,
              "maxLength": 100,
              "type": "string"
            },
            "in": "path",
            "name": "slug",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "integration_slug",
                    "count",
                    "voted"
                  ],
                  "properties": {
                    "integration_slug": {
                      "type": "string"
                    },
                    "count": {
                      "minimum": 0,
                      "type": "integer"
                    },
                    "voted": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      },
      "delete": {
        "operationId": "unvoteIntegrationRequest",
        "summary": "Remove vote for a coming-soon integration",
        "tags": [
          "integrations"
        ],
        "description": "Removes the authenticated user vote for a coming-soon integration.",
        "parameters": [
          {
            "schema": {
              "minLength": 1,
              "maxLength": 100,
              "type": "string"
            },
            "in": "path",
            "name": "slug",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "integration_slug",
                    "count",
                    "voted"
                  ],
                  "properties": {
                    "integration_slug": {
                      "type": "string"
                    },
                    "count": {
                      "minimum": 0,
                      "type": "integer"
                    },
                    "voted": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/integrations/{slug}/connection": {
      "delete": {
        "operationId": "disconnectIntegration",
        "summary": "Disconnect a marketplace integration",
        "tags": [
          "integrations"
        ],
        "description": "Disconnects active personal integrations that can be safely managed from the marketplace. Server-level or shared integrations remain managed from their dedicated settings surface.",
        "parameters": [
          {
            "schema": {
              "minLength": 1,
              "maxLength": 100,
              "type": "string"
            },
            "in": "path",
            "name": "slug",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "slug",
                    "status",
                    "detail",
                    "connected_at",
                    "last_sync_at"
                  ],
                  "properties": {
                    "slug": {
                      "type": "string"
                    },
                    "status": {
                      "anyOf": [
                        {
                          "type": "string",
                          "enum": [
                            "connected"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "configured"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "not_connected"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "error"
                          ]
                        }
                      ]
                    },
                    "detail": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "connected_at": {
                      "anyOf": [
                        {
                          "format": "date-time",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "last_sync_at": {
                      "anyOf": [
                        {
                          "format": "date-time",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "Conflict - resource state prevents the operation",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/intelligence/reports": {
      "get": {
        "operationId": "getApiV1IntelligenceReports",
        "summary": "Get intelligence report",
        "tags": [
          "intelligence-reports"
        ],
        "description": "Returns the matching intelligence report for a dimension, period type, optional date, and optional language.",
        "parameters": [
          {
            "schema": {
              "format": "date",
              "type": "string"
            },
            "in": "query",
            "name": "date",
            "required": false
          },
          {
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "enum": [
                    "competitive"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "market"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "strategic"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "broad"
                  ]
                }
              ]
            },
            "in": "query",
            "name": "dimension",
            "required": true
          },
          {
            "schema": {
              "maxLength": 8,
              "type": "string"
            },
            "in": "query",
            "name": "lang",
            "required": false
          },
          {
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "enum": [
                    "daily"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "weekly"
                  ]
                }
              ]
            },
            "in": "query",
            "name": "period_type",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "report"
                  ],
                  "properties": {
                    "report": {
                      "anyOf": [
                        {
                          "additionalProperties": false,
                          "type": "object",
                          "required": [
                            "id",
                            "team_id",
                            "dimension",
                            "period_type",
                            "period_start",
                            "period_end",
                            "previous_period_start",
                            "previous_period_end",
                            "status",
                            "content",
                            "degraded_dimensions",
                            "model_used",
                            "generated_at",
                            "status_reason",
                            "is_read",
                            "read_at",
                            "created_at",
                            "updated_at",
                            "deleted_at"
                          ],
                          "properties": {
                            "id": {
                              "format": "uuid",
                              "type": "string"
                            },
                            "team_id": {
                              "format": "uuid",
                              "type": "string"
                            },
                            "dimension": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "enum": [
                                    "competitive"
                                  ]
                                },
                                {
                                  "type": "string",
                                  "enum": [
                                    "market"
                                  ]
                                },
                                {
                                  "type": "string",
                                  "enum": [
                                    "strategic"
                                  ]
                                },
                                {
                                  "type": "string",
                                  "enum": [
                                    "broad"
                                  ]
                                }
                              ]
                            },
                            "period_type": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "enum": [
                                    "daily"
                                  ]
                                },
                                {
                                  "type": "string",
                                  "enum": [
                                    "weekly"
                                  ]
                                }
                              ]
                            },
                            "period_start": {
                              "format": "date",
                              "type": "string"
                            },
                            "period_end": {
                              "format": "date",
                              "type": "string"
                            },
                            "previous_period_start": {
                              "anyOf": [
                                {
                                  "format": "date",
                                  "type": "string"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "previous_period_end": {
                              "anyOf": [
                                {
                                  "format": "date",
                                  "type": "string"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "status": {
                              "type": "string"
                            },
                            "content": {
                              "$comment": "json-value"
                            },
                            "degraded_dimensions": {
                              "type": "array",
                              "items": {
                                "type": "string"
                              }
                            },
                            "model_used": {
                              "anyOf": [
                                {
                                  "type": "string"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "generated_at": {
                              "anyOf": [
                                {
                                  "format": "date-time",
                                  "type": "string"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "status_reason": {
                              "anyOf": [
                                {
                                  "type": "string"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "is_read": {
                              "type": "boolean"
                            },
                            "read_at": {
                              "anyOf": [
                                {
                                  "format": "date-time",
                                  "type": "string"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "created_at": {
                              "format": "date-time",
                              "type": "string"
                            },
                            "updated_at": {
                              "format": "date-time",
                              "type": "string"
                            },
                            "deleted_at": {
                              "anyOf": [
                                {
                                  "format": "date-time",
                                  "type": "string"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "translations": {
                              "type": "array",
                              "items": {
                                "additionalProperties": false,
                                "type": "object",
                                "required": [
                                  "lang_code",
                                  "content"
                                ],
                                "properties": {
                                  "lang_code": {
                                    "type": "string"
                                  },
                                  "content": {
                                    "$comment": "json-value"
                                  }
                                }
                              }
                            }
                          }
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/intelligence/reports/latest": {
      "get": {
        "operationId": "getApiV1IntelligenceReportsLatest",
        "summary": "Get latest intelligence report",
        "tags": [
          "intelligence-reports"
        ],
        "description": "Returns the latest ready or generating intelligence report for the requested dimension and period type.",
        "parameters": [
          {
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "enum": [
                    "competitive"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "market"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "strategic"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "broad"
                  ]
                }
              ]
            },
            "in": "query",
            "name": "dimension",
            "required": true
          },
          {
            "schema": {
              "maxLength": 8,
              "type": "string"
            },
            "in": "query",
            "name": "lang",
            "required": false
          },
          {
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "enum": [
                    "daily"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "weekly"
                  ]
                }
              ]
            },
            "in": "query",
            "name": "period_type",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "report"
                  ],
                  "properties": {
                    "report": {
                      "anyOf": [
                        {
                          "additionalProperties": false,
                          "type": "object",
                          "required": [
                            "id",
                            "team_id",
                            "dimension",
                            "period_type",
                            "period_start",
                            "period_end",
                            "previous_period_start",
                            "previous_period_end",
                            "status",
                            "content",
                            "degraded_dimensions",
                            "model_used",
                            "generated_at",
                            "status_reason",
                            "is_read",
                            "read_at",
                            "created_at",
                            "updated_at",
                            "deleted_at"
                          ],
                          "properties": {
                            "id": {
                              "format": "uuid",
                              "type": "string"
                            },
                            "team_id": {
                              "format": "uuid",
                              "type": "string"
                            },
                            "dimension": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "enum": [
                                    "competitive"
                                  ]
                                },
                                {
                                  "type": "string",
                                  "enum": [
                                    "market"
                                  ]
                                },
                                {
                                  "type": "string",
                                  "enum": [
                                    "strategic"
                                  ]
                                },
                                {
                                  "type": "string",
                                  "enum": [
                                    "broad"
                                  ]
                                }
                              ]
                            },
                            "period_type": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "enum": [
                                    "daily"
                                  ]
                                },
                                {
                                  "type": "string",
                                  "enum": [
                                    "weekly"
                                  ]
                                }
                              ]
                            },
                            "period_start": {
                              "format": "date",
                              "type": "string"
                            },
                            "period_end": {
                              "format": "date",
                              "type": "string"
                            },
                            "previous_period_start": {
                              "anyOf": [
                                {
                                  "format": "date",
                                  "type": "string"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "previous_period_end": {
                              "anyOf": [
                                {
                                  "format": "date",
                                  "type": "string"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "status": {
                              "type": "string"
                            },
                            "content": {
                              "$comment": "json-value"
                            },
                            "degraded_dimensions": {
                              "type": "array",
                              "items": {
                                "type": "string"
                              }
                            },
                            "model_used": {
                              "anyOf": [
                                {
                                  "type": "string"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "generated_at": {
                              "anyOf": [
                                {
                                  "format": "date-time",
                                  "type": "string"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "status_reason": {
                              "anyOf": [
                                {
                                  "type": "string"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "is_read": {
                              "type": "boolean"
                            },
                            "read_at": {
                              "anyOf": [
                                {
                                  "format": "date-time",
                                  "type": "string"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "created_at": {
                              "format": "date-time",
                              "type": "string"
                            },
                            "updated_at": {
                              "format": "date-time",
                              "type": "string"
                            },
                            "deleted_at": {
                              "anyOf": [
                                {
                                  "format": "date-time",
                                  "type": "string"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "translations": {
                              "type": "array",
                              "items": {
                                "additionalProperties": false,
                                "type": "object",
                                "required": [
                                  "lang_code",
                                  "content"
                                ],
                                "properties": {
                                  "lang_code": {
                                    "type": "string"
                                  },
                                  "content": {
                                    "$comment": "json-value"
                                  }
                                }
                              }
                            }
                          }
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/intelligence/reports/dates": {
      "get": {
        "operationId": "getApiV1IntelligenceReportsDates",
        "summary": "List intelligence report dates",
        "tags": [
          "intelligence-reports"
        ],
        "description": "Returns available report period end dates for a dimension and period type.",
        "parameters": [
          {
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "enum": [
                    "competitive"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "market"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "strategic"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "broad"
                  ]
                }
              ]
            },
            "in": "query",
            "name": "dimension",
            "required": true
          },
          {
            "schema": {
              "maximum": 90,
              "minimum": 1,
              "type": "number"
            },
            "in": "query",
            "name": "limit",
            "required": false
          },
          {
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "enum": [
                    "daily"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "weekly"
                  ]
                }
              ]
            },
            "in": "query",
            "name": "period_type",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "dates"
                  ],
                  "properties": {
                    "dates": {
                      "type": "array",
                      "items": {
                        "format": "date",
                        "type": "string"
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/intelligence/reports/{id}/read": {
      "post": {
        "operationId": "postApiV1IntelligenceReportsByIdRead",
        "summary": "Mark intelligence report as read",
        "tags": [
          "intelligence-reports"
        ],
        "description": "Marks a single intelligence report as read within the accessible team scope.",
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "204": {
            "description": "No content"
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/intelligence/reports/mark-read": {
      "post": {
        "operationId": "postApiV1IntelligenceReportsMarkRead",
        "summary": "Mark intelligence reports as read",
        "tags": [
          "intelligence-reports"
        ],
        "description": "Marks unread reports for a dimension and optional period type as read.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "dimension"
                ],
                "properties": {
                  "dimension": {
                    "anyOf": [
                      {
                        "type": "string",
                        "enum": [
                          "competitive"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "market"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "strategic"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "broad"
                        ]
                      }
                    ]
                  },
                  "period_type": {
                    "anyOf": [
                      {
                        "type": "string",
                        "enum": [
                          "daily"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "weekly"
                        ]
                      }
                    ]
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "marked"
                  ],
                  "properties": {
                    "marked": {
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/intelligence/reports/unread-count": {
      "get": {
        "operationId": "getApiV1IntelligenceReportsUnreadCount",
        "summary": "Get intelligence report unread counts",
        "tags": [
          "intelligence-reports"
        ],
        "description": "Returns unread intelligence report counts by dimension, with broad counting distinct unread source dates.",
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "broad",
                    "competitive",
                    "market",
                    "strategic"
                  ],
                  "properties": {
                    "broad": {
                      "type": "integer"
                    },
                    "competitive": {
                      "type": "integer"
                    },
                    "market": {
                      "type": "integer"
                    },
                    "strategic": {
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/intelligence/reports/generate": {
      "post": {
        "operationId": "postApiV1IntelligenceReportsGenerate",
        "summary": "Generate intelligence report",
        "tags": [
          "intelligence-reports"
        ],
        "description": "Queues manual intelligence report generation for the requested dimension and period.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "dimension",
                  "period_type"
                ],
                "properties": {
                  "dimension": {
                    "anyOf": [
                      {
                        "type": "string",
                        "enum": [
                          "competitive"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "market"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "strategic"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "broad"
                        ]
                      }
                    ]
                  },
                  "period_end": {
                    "format": "date",
                    "type": "string"
                  },
                  "period_type": {
                    "anyOf": [
                      {
                        "type": "string",
                        "enum": [
                          "daily"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "weekly"
                        ]
                      }
                    ]
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "202": {
            "description": "Accepted - processing asynchronously",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "run_id"
                  ],
                  "properties": {
                    "run_id": {
                      "format": "uuid",
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/intelligence/dashboard": {
      "get": {
        "operationId": "getApiV1IntelligenceDashboard",
        "summary": "Get intelligence dashboard",
        "tags": [
          "intelligence"
        ],
        "description": "Returns prioritized intelligence signal cards and source freshness for the accessible team scope.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "generated_at",
                    "next_30_days",
                    "now",
                    "source_freshness",
                    "strategic",
                    "this_week",
                    "today_briefing"
                  ],
                  "properties": {
                    "generated_at": {
                      "format": "date-time",
                      "type": "string"
                    },
                    "next_30_days": {
                      "type": "array",
                      "items": {
                        "additionalProperties": false,
                        "type": "object",
                        "required": [
                          "actions",
                          "description",
                          "evidence_link",
                          "id",
                          "kind",
                          "source",
                          "title",
                          "urgency_score"
                        ],
                        "properties": {
                          "actions": {
                            "type": "array",
                            "items": {
                              "additionalProperties": false,
                              "type": "object",
                              "required": [
                                "endpoint",
                                "method",
                                "type"
                              ],
                              "properties": {
                                "body": {
                                  "$comment": "json-value"
                                },
                                "endpoint": {
                                  "type": "string"
                                },
                                "method": {
                                  "anyOf": [
                                    {
                                      "type": "string",
                                      "enum": [
                                        "PATCH"
                                      ]
                                    },
                                    {
                                      "type": "string",
                                      "enum": [
                                        "POST"
                                      ]
                                    }
                                  ]
                                },
                                "type": {
                                  "anyOf": [
                                    {
                                      "type": "string",
                                      "enum": [
                                        "dismiss"
                                      ]
                                    },
                                    {
                                      "type": "string",
                                      "enum": [
                                        "mark_read"
                                      ]
                                    },
                                    {
                                      "type": "string",
                                      "enum": [
                                        "snooze_7d"
                                      ]
                                    },
                                    {
                                      "type": "string",
                                      "enum": [
                                        "snooze_30d"
                                      ]
                                    },
                                    {
                                      "type": "string",
                                      "enum": [
                                        "apply"
                                      ]
                                    },
                                    {
                                      "type": "string",
                                      "enum": [
                                        "open_chat"
                                      ]
                                    }
                                  ]
                                }
                              }
                            }
                          },
                          "ai_suggestion": {
                            "type": "string"
                          },
                          "description": {
                            "type": "string"
                          },
                          "detected_at": {
                            "format": "date-time",
                            "type": "string"
                          },
                          "evidence_link": {
                            "type": "string"
                          },
                          "id": {
                            "type": "string"
                          },
                          "kind": {
                            "anyOf": [
                              {
                                "type": "string",
                                "enum": [
                                  "alert"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "recommendation"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "insight"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "observation"
                                ]
                              }
                            ]
                          },
                          "metrics": {
                            "type": "object",
                            "additionalProperties": {
                              "anyOf": [
                                {
                                  "type": "number"
                                },
                                {
                                  "type": "string"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            }
                          },
                          "snoozed_until": {
                            "anyOf": [
                              {
                                "format": "date-time",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "source": {
                            "type": "string"
                          },
                          "title": {
                            "type": "string"
                          },
                          "urgency_score": {
                            "type": "number"
                          }
                        }
                      }
                    },
                    "now": {
                      "type": "array",
                      "items": {
                        "additionalProperties": false,
                        "type": "object",
                        "required": [
                          "actions",
                          "description",
                          "evidence_link",
                          "id",
                          "kind",
                          "source",
                          "title",
                          "urgency_score"
                        ],
                        "properties": {
                          "actions": {
                            "type": "array",
                            "items": {
                              "additionalProperties": false,
                              "type": "object",
                              "required": [
                                "endpoint",
                                "method",
                                "type"
                              ],
                              "properties": {
                                "body": {
                                  "$comment": "json-value"
                                },
                                "endpoint": {
                                  "type": "string"
                                },
                                "method": {
                                  "anyOf": [
                                    {
                                      "type": "string",
                                      "enum": [
                                        "PATCH"
                                      ]
                                    },
                                    {
                                      "type": "string",
                                      "enum": [
                                        "POST"
                                      ]
                                    }
                                  ]
                                },
                                "type": {
                                  "anyOf": [
                                    {
                                      "type": "string",
                                      "enum": [
                                        "dismiss"
                                      ]
                                    },
                                    {
                                      "type": "string",
                                      "enum": [
                                        "mark_read"
                                      ]
                                    },
                                    {
                                      "type": "string",
                                      "enum": [
                                        "snooze_7d"
                                      ]
                                    },
                                    {
                                      "type": "string",
                                      "enum": [
                                        "snooze_30d"
                                      ]
                                    },
                                    {
                                      "type": "string",
                                      "enum": [
                                        "apply"
                                      ]
                                    },
                                    {
                                      "type": "string",
                                      "enum": [
                                        "open_chat"
                                      ]
                                    }
                                  ]
                                }
                              }
                            }
                          },
                          "ai_suggestion": {
                            "type": "string"
                          },
                          "description": {
                            "type": "string"
                          },
                          "detected_at": {
                            "format": "date-time",
                            "type": "string"
                          },
                          "evidence_link": {
                            "type": "string"
                          },
                          "id": {
                            "type": "string"
                          },
                          "kind": {
                            "anyOf": [
                              {
                                "type": "string",
                                "enum": [
                                  "alert"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "recommendation"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "insight"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "observation"
                                ]
                              }
                            ]
                          },
                          "metrics": {
                            "type": "object",
                            "additionalProperties": {
                              "anyOf": [
                                {
                                  "type": "number"
                                },
                                {
                                  "type": "string"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            }
                          },
                          "snoozed_until": {
                            "anyOf": [
                              {
                                "format": "date-time",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "source": {
                            "type": "string"
                          },
                          "title": {
                            "type": "string"
                          },
                          "urgency_score": {
                            "type": "number"
                          }
                        }
                      }
                    },
                    "source_freshness": {
                      "additionalProperties": false,
                      "type": "object",
                      "required": [
                        "saturation_alerts",
                        "competitor_alerts",
                        "competitive_report",
                        "strategic_report",
                        "trend_feed",
                        "broad_report",
                        "cost_trend"
                      ],
                      "properties": {
                        "saturation_alerts": {
                          "anyOf": [
                            {
                              "format": "date-time",
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "competitor_alerts": {
                          "anyOf": [
                            {
                              "format": "date-time",
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "competitive_report": {
                          "anyOf": [
                            {
                              "format": "date-time",
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "strategic_report": {
                          "anyOf": [
                            {
                              "format": "date-time",
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "trend_feed": {
                          "anyOf": [
                            {
                              "format": "date-time",
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "broad_report": {
                          "anyOf": [
                            {
                              "format": "date-time",
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "cost_trend": {
                          "anyOf": [
                            {
                              "format": "date-time",
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        }
                      }
                    },
                    "strategic": {
                      "type": "array",
                      "items": {
                        "additionalProperties": false,
                        "type": "object",
                        "required": [
                          "actions",
                          "description",
                          "evidence_link",
                          "id",
                          "kind",
                          "source",
                          "title",
                          "urgency_score"
                        ],
                        "properties": {
                          "actions": {
                            "type": "array",
                            "items": {
                              "additionalProperties": false,
                              "type": "object",
                              "required": [
                                "endpoint",
                                "method",
                                "type"
                              ],
                              "properties": {
                                "body": {
                                  "$comment": "json-value"
                                },
                                "endpoint": {
                                  "type": "string"
                                },
                                "method": {
                                  "anyOf": [
                                    {
                                      "type": "string",
                                      "enum": [
                                        "PATCH"
                                      ]
                                    },
                                    {
                                      "type": "string",
                                      "enum": [
                                        "POST"
                                      ]
                                    }
                                  ]
                                },
                                "type": {
                                  "anyOf": [
                                    {
                                      "type": "string",
                                      "enum": [
                                        "dismiss"
                                      ]
                                    },
                                    {
                                      "type": "string",
                                      "enum": [
                                        "mark_read"
                                      ]
                                    },
                                    {
                                      "type": "string",
                                      "enum": [
                                        "snooze_7d"
                                      ]
                                    },
                                    {
                                      "type": "string",
                                      "enum": [
                                        "snooze_30d"
                                      ]
                                    },
                                    {
                                      "type": "string",
                                      "enum": [
                                        "apply"
                                      ]
                                    },
                                    {
                                      "type": "string",
                                      "enum": [
                                        "open_chat"
                                      ]
                                    }
                                  ]
                                }
                              }
                            }
                          },
                          "ai_suggestion": {
                            "type": "string"
                          },
                          "description": {
                            "type": "string"
                          },
                          "detected_at": {
                            "format": "date-time",
                            "type": "string"
                          },
                          "evidence_link": {
                            "type": "string"
                          },
                          "id": {
                            "type": "string"
                          },
                          "kind": {
                            "anyOf": [
                              {
                                "type": "string",
                                "enum": [
                                  "alert"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "recommendation"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "insight"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "observation"
                                ]
                              }
                            ]
                          },
                          "metrics": {
                            "type": "object",
                            "additionalProperties": {
                              "anyOf": [
                                {
                                  "type": "number"
                                },
                                {
                                  "type": "string"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            }
                          },
                          "snoozed_until": {
                            "anyOf": [
                              {
                                "format": "date-time",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "source": {
                            "type": "string"
                          },
                          "title": {
                            "type": "string"
                          },
                          "urgency_score": {
                            "type": "number"
                          }
                        }
                      }
                    },
                    "this_week": {
                      "type": "array",
                      "items": {
                        "additionalProperties": false,
                        "type": "object",
                        "required": [
                          "actions",
                          "description",
                          "evidence_link",
                          "id",
                          "kind",
                          "source",
                          "title",
                          "urgency_score"
                        ],
                        "properties": {
                          "actions": {
                            "type": "array",
                            "items": {
                              "additionalProperties": false,
                              "type": "object",
                              "required": [
                                "endpoint",
                                "method",
                                "type"
                              ],
                              "properties": {
                                "body": {
                                  "$comment": "json-value"
                                },
                                "endpoint": {
                                  "type": "string"
                                },
                                "method": {
                                  "anyOf": [
                                    {
                                      "type": "string",
                                      "enum": [
                                        "PATCH"
                                      ]
                                    },
                                    {
                                      "type": "string",
                                      "enum": [
                                        "POST"
                                      ]
                                    }
                                  ]
                                },
                                "type": {
                                  "anyOf": [
                                    {
                                      "type": "string",
                                      "enum": [
                                        "dismiss"
                                      ]
                                    },
                                    {
                                      "type": "string",
                                      "enum": [
                                        "mark_read"
                                      ]
                                    },
                                    {
                                      "type": "string",
                                      "enum": [
                                        "snooze_7d"
                                      ]
                                    },
                                    {
                                      "type": "string",
                                      "enum": [
                                        "snooze_30d"
                                      ]
                                    },
                                    {
                                      "type": "string",
                                      "enum": [
                                        "apply"
                                      ]
                                    },
                                    {
                                      "type": "string",
                                      "enum": [
                                        "open_chat"
                                      ]
                                    }
                                  ]
                                }
                              }
                            }
                          },
                          "ai_suggestion": {
                            "type": "string"
                          },
                          "description": {
                            "type": "string"
                          },
                          "detected_at": {
                            "format": "date-time",
                            "type": "string"
                          },
                          "evidence_link": {
                            "type": "string"
                          },
                          "id": {
                            "type": "string"
                          },
                          "kind": {
                            "anyOf": [
                              {
                                "type": "string",
                                "enum": [
                                  "alert"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "recommendation"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "insight"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "observation"
                                ]
                              }
                            ]
                          },
                          "metrics": {
                            "type": "object",
                            "additionalProperties": {
                              "anyOf": [
                                {
                                  "type": "number"
                                },
                                {
                                  "type": "string"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            }
                          },
                          "snoozed_until": {
                            "anyOf": [
                              {
                                "format": "date-time",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "source": {
                            "type": "string"
                          },
                          "title": {
                            "type": "string"
                          },
                          "urgency_score": {
                            "type": "number"
                          }
                        }
                      }
                    },
                    "today_briefing": {
                      "anyOf": [
                        {
                          "additionalProperties": false,
                          "type": "object",
                          "required": [
                            "briefing_date",
                            "items",
                            "generated_at",
                            "stale",
                            "degraded"
                          ],
                          "properties": {
                            "briefing_date": {
                              "format": "date",
                              "type": "string"
                            },
                            "items": {
                              "type": "array",
                              "items": {
                                "additionalProperties": false,
                                "type": "object",
                                "required": [
                                  "title",
                                  "narrative",
                                  "cta_label",
                                  "evidence"
                                ],
                                "properties": {
                                  "title": {
                                    "type": "string"
                                  },
                                  "narrative": {
                                    "type": "string"
                                  },
                                  "cta_label": {
                                    "type": "string"
                                  },
                                  "evidence": {
                                    "type": "array",
                                    "items": {
                                      "additionalProperties": false,
                                      "type": "object",
                                      "required": [
                                        "source",
                                        "ref_id"
                                      ],
                                      "properties": {
                                        "source": {
                                          "type": "string"
                                        },
                                        "ref_id": {
                                          "type": "string"
                                        }
                                      }
                                    }
                                  }
                                }
                              }
                            },
                            "generated_at": {
                              "format": "date-time",
                              "type": "string"
                            },
                            "stale": {
                              "type": "boolean"
                            },
                            "degraded": {
                              "type": "boolean"
                            }
                          }
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/jobs/{id}": {
      "get": {
        "operationId": "getJobById",
        "summary": "Get job status by ID",
        "tags": [
          "jobs"
        ],
        "description": "Returns the current status, progress, result or error for a specific job. Used for polling async job completion.",
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true,
            "description": "Job ID"
          }
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "id",
                    "job_type",
                    "status",
                    "data",
                    "error",
                    "created_at",
                    "completed_at",
                    "expires_at"
                  ],
                  "properties": {
                    "id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "job_type": {
                      "type": "string"
                    },
                    "status": {
                      "anyOf": [
                        {
                          "type": "string",
                          "enum": [
                            "PENDING"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "RUNNING"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "COMPLETED"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "FAILED"
                          ]
                        }
                      ]
                    },
                    "data": {
                      "anyOf": [
                        {
                          "$comment": "json-value",
                          "description": "Arbitrary JSON value with nested arrays and objects."
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "error": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "created_at": {
                      "format": "date-time",
                      "type": "string"
                    },
                    "completed_at": {
                      "anyOf": [
                        {
                          "format": "date-time",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "expires_at": {
                      "format": "date-time",
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/jobs": {
      "get": {
        "operationId": "listJobs",
        "summary": "List jobs visible to the authenticated user",
        "tags": [
          "jobs"
        ],
        "description": "Returns a paginated list of async jobs owned by the current user or scoped to teams the user can access. Supports filtering by job_type and status.",
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "job_type",
            "required": false,
            "description": "Filter by job type (e.g. SYNC_AD_ACCOUNTS, CAMPAIGN_REPORT)"
          },
          {
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "enum": [
                    "PENDING"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "RUNNING"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "COMPLETED"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "FAILED"
                  ]
                }
              ]
            },
            "in": "query",
            "name": "status",
            "required": false,
            "description": "Filter by job status"
          },
          {
            "schema": {
              "minimum": 1,
              "maximum": 100,
              "default": 20,
              "type": "integer"
            },
            "in": "query",
            "name": "limit",
            "required": false
          },
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "query",
            "name": "cursor",
            "required": false,
            "description": "Cursor for pagination (last job id)"
          }
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "items",
                    "next_cursor"
                  ],
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "additionalProperties": false,
                        "type": "object",
                        "required": [
                          "id",
                          "job_type",
                          "status",
                          "data",
                          "error",
                          "created_at",
                          "completed_at",
                          "expires_at"
                        ],
                        "properties": {
                          "id": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "job_type": {
                            "type": "string"
                          },
                          "status": {
                            "anyOf": [
                              {
                                "type": "string",
                                "enum": [
                                  "PENDING"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "RUNNING"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "COMPLETED"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "FAILED"
                                ]
                              }
                            ]
                          },
                          "data": {
                            "anyOf": [
                              {
                                "$comment": "json-value",
                                "description": "Arbitrary JSON value with nested arrays and objects."
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "error": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "created_at": {
                            "format": "date-time",
                            "type": "string"
                          },
                          "completed_at": {
                            "anyOf": [
                              {
                                "format": "date-time",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "expires_at": {
                            "format": "date-time",
                            "type": "string"
                          }
                        }
                      }
                    },
                    "next_cursor": {
                      "anyOf": [
                        {
                          "format": "uuid",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/jobs/server": {
      "get": {
        "operationId": "listJobsServer",
        "summary": "List jobs (server-side paginated)",
        "tags": [
          "jobs"
        ],
        "description": "Returns a server-side paginated, filtered, sorted list of job results. Supports offset pagination, search, and multiple filter dimensions.",
        "parameters": [
          {
            "schema": {
              "minimum": 1,
              "maximum": 100,
              "default": 50,
              "type": "integer"
            },
            "in": "query",
            "name": "limit",
            "required": false
          },
          {
            "schema": {
              "minimum": 0,
              "default": 0,
              "type": "integer"
            },
            "in": "query",
            "name": "offset",
            "required": false
          },
          {
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "enum": [
                    "PENDING"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "RUNNING"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "COMPLETED"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "FAILED"
                  ]
                }
              ]
            },
            "in": "query",
            "name": "status",
            "required": false
          },
          {
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "enum": [
                    "created_at"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "completed_at"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "status"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "job_type"
                  ]
                }
              ]
            },
            "in": "query",
            "name": "sort_by",
            "required": false
          },
          {
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "enum": [
                    "asc"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "desc"
                  ]
                }
              ]
            },
            "in": "query",
            "name": "sort_order",
            "required": false
          },
          {
            "schema": {
              "maxLength": 120,
              "minLength": 2,
              "type": "string"
            },
            "in": "query",
            "name": "search",
            "required": false,
            "description": "Free-text search. Case-insensitive substring over the fields this list declares, AND-ed across whitespace-separated tokens; `%`, `_` and `\\` are matched literally. A uuid, a Stripe id (cus_/sub_/in_/pi_), an `act_…` ad account or an IP is matched by EQUALITY. The response echoes what was actually consulted in `search_meta`."
          },
          {
            "schema": {
              "maxLength": 100,
              "type": "string"
            },
            "in": "query",
            "name": "job_type",
            "required": false
          },
          {
            "schema": {
              "type": "boolean"
            },
            "in": "query",
            "name": "errors_only",
            "required": false
          },
          {
            "schema": {
              "format": "date-time",
              "type": "string"
            },
            "in": "query",
            "name": "created_from",
            "required": false
          },
          {
            "schema": {
              "format": "date-time",
              "type": "string"
            },
            "in": "query",
            "name": "created_to",
            "required": false
          }
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "items",
                    "total",
                    "counts"
                  ],
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "additionalProperties": false,
                        "type": "object",
                        "required": [
                          "id",
                          "job_type",
                          "status",
                          "data",
                          "error",
                          "team_id",
                          "user_id",
                          "created_at",
                          "completed_at",
                          "expires_at"
                        ],
                        "properties": {
                          "id": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "job_type": {
                            "type": "string"
                          },
                          "status": {
                            "anyOf": [
                              {
                                "type": "string",
                                "enum": [
                                  "PENDING"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "RUNNING"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "COMPLETED"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "FAILED"
                                ]
                              }
                            ]
                          },
                          "data": {
                            "anyOf": [
                              {
                                "$comment": "json-value",
                                "description": "Arbitrary JSON value with nested arrays and objects."
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "error": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "team_id": {
                            "description": "Workspace (team) the job belongs to. Reachable by name through `search`.",
                            "anyOf": [
                              {
                                "format": "uuid",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "user_id": {
                            "description": "Owner of the job. Reachable by e-mail or name through `search`.",
                            "anyOf": [
                              {
                                "format": "uuid",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "created_at": {
                            "format": "date-time",
                            "type": "string"
                          },
                          "completed_at": {
                            "anyOf": [
                              {
                                "format": "date-time",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "expires_at": {
                            "format": "date-time",
                            "type": "string"
                          }
                        }
                      }
                    },
                    "total": {
                      "type": "integer"
                    },
                    "counts": {
                      "additionalProperties": false,
                      "type": "object",
                      "required": [
                        "PENDING",
                        "RUNNING",
                        "COMPLETED",
                        "FAILED"
                      ],
                      "properties": {
                        "PENDING": {
                          "type": "integer"
                        },
                        "RUNNING": {
                          "type": "integer"
                        },
                        "COMPLETED": {
                          "type": "integer"
                        },
                        "FAILED": {
                          "type": "integer"
                        }
                      }
                    },
                    "search_meta": {
                      "additionalProperties": false,
                      "description": "What the search actually did, in machine tokens (D11). Absent on a response the caller never asked to search.",
                      "type": "object",
                      "required": [
                        "applied",
                        "degraded",
                        "escaped",
                        "fields_searched",
                        "mode",
                        "term",
                        "truncated"
                      ],
                      "properties": {
                        "applied": {
                          "description": "false = THE LIST IS NOT FILTERED (kill-switch off, or the term normalized below the two-character floor). The page must say so instead of presenting the rows as results.",
                          "type": "boolean"
                        },
                        "degraded": {
                          "description": "true = the owner/identity expansion is INCOMPLETE (a resolution query failed, or a set hit its 500-id cap): matching rows may be missing and it is not the operator’s typing.",
                          "type": "boolean"
                        },
                        "escaped": {
                          "description": "true = at least one `\\`, `%` or `_` in the term was matched literally (D7).",
                          "type": "boolean"
                        },
                        "fields_searched": {
                          "description": "Wire tokens of the fields ACTUALLY consulted, deduped and sorted. Rendered by the frontend as `t(\"search.field.\" + camel(token))`.",
                          "type": "array",
                          "items": {
                            "type": "string"
                          }
                        },
                        "id_fallback": {
                          "description": "Present only when the term classified as an identifier, matched no identifier field on this list, and was retried as text (D4).",
                          "type": "boolean",
                          "enum": [
                            true
                          ]
                        },
                        "mode": {
                          "description": "How the term was interpreted. After an `id_fallback` retry this reads `text`.",
                          "anyOf": [
                            {
                              "type": "string",
                              "enum": [
                                "id"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "email"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "text"
                              ]
                            }
                          ]
                        },
                        "not_applied": {
                          "description": "Why the list was not filtered. Present only when `applied` is false. `disabled` = the search kill-switch is off on a list that has no legacy predicate to fall back to, so these rows are the whole population and not an answer to the term. A list that DOES fall back emits no `search_meta` at all, because there the legacy predicate did filter it.",
                          "anyOf": [
                            {
                              "type": "string",
                              "enum": [
                                "below_min_length"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "disabled"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "no_applicable_field"
                              ]
                            }
                          ]
                        },
                        "term": {
                          "description": "The NORMALIZED term, echoed back for the UI. Never the raw input.",
                          "type": "string"
                        },
                        "truncated": {
                          "description": "Set when the LIST was cut (this page shows `shown` of `total`), else null.",
                          "anyOf": [
                            {
                              "type": "object",
                              "required": [
                                "shown",
                                "total"
                              ],
                              "properties": {
                                "shown": {
                                  "type": "integer"
                                },
                                "total": {
                                  "type": "integer"
                                }
                              }
                            },
                            {
                              "type": "null"
                            }
                          ]
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/jobs/types": {
      "get": {
        "operationId": "listJobTypes",
        "summary": "List distinct job types",
        "tags": [
          "jobs"
        ],
        "description": "Returns the distinct set of job_type values present in job_result for accessible sessions.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "items"
                  ],
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/kb/ingest": {
      "post": {
        "operationId": "ingestKbManifest",
        "summary": "Receive KB change manifest from CI",
        "tags": [
          "kb"
        ],
        "description": "Webhook-style endpoint called by the GitHub Actions CI pipeline after a PR is merged on `develop`. Accepts a structured \"change manifest\" describing the changed files, product areas, removal signals (product areas where every touched file was deleted, surfaced for human review rather than auto-archival), release signals and candidate audiences for the merge. The manifest is persisted (idempotent by `mergeCommitSha + pullRequestNumber`) and a SQS message is dispatched to the `PROCESS_KB_MANIFEST` worker. Auth is **NOT** via JWT - callers must present a shared secret in the `x-kb-ingest-key` header that must match the `KB_INGEST_API_KEY` env var (compared with `timingSafeEqual`). Returns 503 when the endpoint is not configured (missing env var), 401 on invalid/missing key. On success returns `202 Accepted` with `status` indicating whether the manifest was newly `accepted`, `already_ingested`, or `accepted_not_queued` (persisted but SQS dispatch failed - the processor retries on the next cron).",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "manifestVersion",
                  "generatedAt",
                  "repository",
                  "baseBranch",
                  "mergeCommitSha",
                  "pullRequestNumber",
                  "pullRequestTitle",
                  "labels",
                  "author",
                  "changedFiles",
                  "userFacingFiles",
                  "internalOnlyFiles",
                  "docsFiles",
                  "unknownFiles",
                  "productAreas",
                  "removalSignals",
                  "riskHints",
                  "releaseSignals",
                  "candidateAudiences",
                  "candidateSurfaces",
                  "existingKbReferences",
                  "notes"
                ],
                "properties": {
                  "manifestVersion": {
                    "type": "string"
                  },
                  "generatedAt": {
                    "type": "string"
                  },
                  "repository": {
                    "type": "string"
                  },
                  "baseBranch": {
                    "type": "string"
                  },
                  "mergeCommitSha": {
                    "type": "string"
                  },
                  "pullRequestNumber": {
                    "anyOf": [
                      {
                        "type": "integer"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "pullRequestTitle": {
                    "anyOf": [
                      {
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "labels": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  },
                  "author": {
                    "anyOf": [
                      {
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "changedFiles": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  },
                  "userFacingFiles": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  },
                  "internalOnlyFiles": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  },
                  "docsFiles": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  },
                  "unknownFiles": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  },
                  "productAreas": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  },
                  "removalSignals": {
                    "type": "array",
                    "items": {
                      "additionalProperties": false,
                      "type": "object",
                      "required": [
                        "productArea",
                        "deletedFiles"
                      ],
                      "properties": {
                        "productArea": {
                          "type": "string"
                        },
                        "deletedFiles": {
                          "type": "array",
                          "items": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  },
                  "riskHints": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  },
                  "releaseSignals": {
                    "additionalProperties": false,
                    "type": "object",
                    "required": [
                      "hasNewRoutes",
                      "hasNewPages",
                      "hasMigrations",
                      "hasI18nChanges",
                      "hasNewComponents"
                    ],
                    "properties": {
                      "hasNewRoutes": {
                        "type": "boolean"
                      },
                      "hasNewPages": {
                        "type": "boolean"
                      },
                      "hasMigrations": {
                        "type": "boolean"
                      },
                      "hasI18nChanges": {
                        "type": "boolean"
                      },
                      "hasNewComponents": {
                        "type": "boolean"
                      }
                    }
                  },
                  "candidateAudiences": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  },
                  "candidateSurfaces": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  },
                  "existingKbReferences": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "required": [
                        "docPath",
                        "relatedChangedFiles"
                      ],
                      "properties": {
                        "docPath": {
                          "type": "string"
                        },
                        "relatedChangedFiles": {
                          "type": "array",
                          "items": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  },
                  "notes": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "schema": {
              "minLength": 1,
              "type": "string"
            },
            "in": "header",
            "name": "x-kb-ingest-key",
            "required": true
          }
        ],
        "responses": {
          "202": {
            "description": "Accepted - processing asynchronously",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "status",
                    "manifestKey"
                  ],
                  "properties": {
                    "status": {
                      "anyOf": [
                        {
                          "type": "string",
                          "enum": [
                            "accepted"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "already_ingested"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "accepted_not_queued"
                          ]
                        }
                      ]
                    },
                    "manifestKey": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "Service unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ]
      }
    },
    "/api/v1/kb/search": {
      "get": {
        "operationId": "searchKnowledgeBase",
        "summary": "Search the public Help Center (Knowledge Base)",
        "tags": [
          "kb"
        ],
        "description": "Full-text search over the published Help Center articles (help.wevion.ai), proxied + cached from the Pylon Knowledge Base API. Returns matching articles with their public URL and a short snippet. Available to any authenticated user. Degrades gracefully to an empty list when the Knowledge Base provider is unavailable or not configured.",
        "parameters": [
          {
            "schema": {
              "minLength": 1,
              "maxLength": 200,
              "type": "string"
            },
            "in": "query",
            "name": "q",
            "required": true
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "locale",
            "required": false
          },
          {
            "schema": {
              "minimum": 1,
              "maximum": 20,
              "type": "integer"
            },
            "in": "query",
            "name": "limit",
            "required": false
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "items"
                  ],
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "id",
                          "title",
                          "url",
                          "snippet"
                        ],
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "title": {
                            "type": "string"
                          },
                          "url": {
                            "type": "string"
                          },
                          "snippet": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/kb/contextual": {
      "get": {
        "operationId": "listContextualKbArticles",
        "summary": "Get contextual KB article suggestions",
        "tags": [
          "kb"
        ],
        "description": "Returns a ranked list of published KB articles relevant to the current UI surface (pathname / featureKey / productArea). Results are filtered by the caller role (mapped to an audience of `mediabuyer`/`admin`/`both`) and the requested locale, with fallback to the canonical English version when a localized variant does not exist. When the `kb_contextual_help_enabled` feature flag is off the endpoint always returns an empty array (200 OK).",
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "pathname",
            "required": false
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "featureKey",
            "required": false
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "productArea",
            "required": false
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "locale",
            "required": false
          },
          {
            "schema": {
              "minimum": 1,
              "maximum": 10,
              "type": "integer"
            },
            "in": "query",
            "name": "limit",
            "required": false
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "items"
                  ],
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "articleKey",
                          "title",
                          "summary",
                          "productArea",
                          "locale"
                        ],
                        "properties": {
                          "articleKey": {
                            "type": "string"
                          },
                          "title": {
                            "type": "string"
                          },
                          "summary": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "productArea": {
                            "type": "string"
                          },
                          "locale": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/kb/articles/{articleKey}": {
      "get": {
        "operationId": "getKbArticle",
        "summary": "Get KB article details",
        "tags": [
          "kb"
        ],
        "description": "Resolves a published KB article by its stable `articleKey` in the requested locale (defaults to `en`). If no approved version exists for the requested locale, falls back to the article canonical locale. Returns 404 when the article is not published or no approved version is available in any locale.",
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "locale",
            "required": false
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "path",
            "name": "articleKey",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "articleKey",
                    "title",
                    "summary",
                    "productArea",
                    "audience",
                    "surface",
                    "locale"
                  ],
                  "properties": {
                    "articleKey": {
                      "type": "string"
                    },
                    "title": {
                      "type": "string"
                    },
                    "summary": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "productArea": {
                      "type": "string"
                    },
                    "audience": {
                      "type": "string"
                    },
                    "surface": {
                      "type": "string"
                    },
                    "locale": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/kb/health": {
      "get": {
        "operationId": "getKbHealth",
        "summary": "KB pipeline health check",
        "tags": [
          "kb-admin"
        ],
        "description": "Admin-only health probe for the KB ingestion / generation / translation / publish pipeline. Returns every KB feature flag (`kb_pipeline_enabled`, `kb_generation_enabled`, `kb_translation_enabled`, `kb_publish_enabled`, `kb_contextual_help_enabled`) from the centralized rollout config — all always-on since the 2026-07 flag cleanup. Restricted to roles `admin` and `super_admin`.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "status",
                    "flags"
                  ],
                  "properties": {
                    "status": {
                      "type": "string"
                    },
                    "flags": {
                      "type": "object",
                      "required": [
                        "kb_pipeline_enabled",
                        "kb_generation_enabled",
                        "kb_translation_enabled",
                        "kb_publish_enabled",
                        "kb_contextual_help_enabled"
                      ],
                      "properties": {
                        "kb_pipeline_enabled": {
                          "type": "boolean"
                        },
                        "kb_generation_enabled": {
                          "type": "boolean"
                        },
                        "kb_translation_enabled": {
                          "type": "boolean"
                        },
                        "kb_publish_enabled": {
                          "type": "boolean"
                        },
                        "kb_contextual_help_enabled": {
                          "type": "boolean"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/kb/articles/{articleKey}/status": {
      "get": {
        "operationId": "getKbArticleStatus",
        "summary": "Get full KB article status (admin)",
        "tags": [
          "kb-admin"
        ],
        "description": "Admin-only pipeline-state inspector for a single KB article, independent of the `GET /kb/articles/:articleKey` public endpoint. Unlike the public route, this returns the article regardless of its status (draft, review_required, blocked, promoted_pending_policy, published, ...) and reports the article-level `status`/`riskLevel` plus its latest version (any policy_state) for the canonical locale. Returns 404 only when no article with this key exists at all.",
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "in": "path",
            "name": "articleKey",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "articleKey",
                    "title",
                    "status",
                    "riskLevel",
                    "productArea",
                    "audience",
                    "surface",
                    "canonicalLocale",
                    "latestVersion"
                  ],
                  "properties": {
                    "articleKey": {
                      "type": "string"
                    },
                    "title": {
                      "type": "string"
                    },
                    "status": {
                      "type": "string"
                    },
                    "riskLevel": {
                      "type": "string"
                    },
                    "productArea": {
                      "type": "string"
                    },
                    "audience": {
                      "type": "string"
                    },
                    "surface": {
                      "type": "string"
                    },
                    "canonicalLocale": {
                      "type": "string"
                    },
                    "latestVersion": {
                      "anyOf": [
                        {
                          "type": "object",
                          "required": [
                            "versionNumber",
                            "locale",
                            "policyState",
                            "confidenceScore",
                            "createdAt"
                          ],
                          "properties": {
                            "versionNumber": {
                              "type": "number"
                            },
                            "locale": {
                              "type": "string"
                            },
                            "policyState": {
                              "type": "string"
                            },
                            "confidenceScore": {
                              "anyOf": [
                                {
                                  "type": "number"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "createdAt": {
                              "format": "date-time",
                              "type": "string"
                            }
                          }
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/kb/articles/{articleKey}/replay": {
      "post": {
        "operationId": "replayKbArticle",
        "summary": "Replay KB article pipeline (admin)",
        "tags": [
          "kb-admin"
        ],
        "description": "Admin-only endpoint to re-run the KB generation/policy/translation/publish pipeline for a single article. `level` selects the replay scope - `full` (default, reruns all phases), `phase` (reruns a single named `phase`), `locale` (reruns only a specific translated `locale`). `force=true` bypasses idempotency guards. Returns one of three possible actions in the response: `replayed` (work dispatched), `no_op` (nothing to replay), `rejected` (invalid arguments or unknown article).",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "properties": {
                  "level": {
                    "anyOf": [
                      {
                        "type": "string",
                        "enum": [
                          "full"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "phase"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "locale"
                        ]
                      }
                    ]
                  },
                  "phase": {
                    "type": "string"
                  },
                  "locale": {
                    "type": "string"
                  },
                  "force": {
                    "type": "boolean"
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "in": "path",
            "name": "articleKey",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "articleKey",
                    "action",
                    "details"
                  ],
                  "properties": {
                    "articleKey": {
                      "type": "string"
                    },
                    "action": {
                      "anyOf": [
                        {
                          "type": "string",
                          "enum": [
                            "replayed"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "no_op"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "rejected"
                          ]
                        }
                      ]
                    },
                    "details": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/launch/apps": {
      "get": {
        "operationId": "getApiV1LaunchApps",
        "summary": "Get apps available for promotion on an ad account",
        "tags": [
          "launch"
        ],
        "description": "Fetches applications associated with a Meta ad account via the Graph API. Used by Campaign Creator for APP_PROMOTION objective.",
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "query",
            "name": "meta_token_id",
            "required": true
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "ad_account_id",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "apps"
                  ],
                  "properties": {
                    "apps": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "id",
                          "name"
                        ],
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "name": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/launch/platform-resources": {
      "get": {
        "operationId": "getApiV1LaunchPlatformResources",
        "summary": "Get platform-aware launch resources",
        "tags": [
          "launch"
        ],
        "description": "Returns account-scoped launch resources for Google, TikTok and Taboola, scoped to the active workspace: rows whose `team_id` belongs to the accessible team set (narrowed by `x-team-id` / `x-active-scope`), plus legacy rows without `team_id` owned by an accessible session. Uses locally synced resources when available and returns an explicit unavailable flag when the upstream API/resource is not configured.",
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "account_id",
            "required": false
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "page_id",
            "required": false
          },
          {
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "enum": [
                    "meta"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "google"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "tiktok"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "taboola"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "snapchat"
                  ]
                }
              ]
            },
            "in": "query",
            "name": "platform",
            "required": true
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "resource_type",
            "required": false
          },
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "header",
            "name": "x-team-id",
            "required": false,
            "description": "Explicit team (workspace) scope: a team.id the caller belongs to."
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "header",
            "name": "x-active-scope",
            "required": false,
            "description": "Active scope selector in `<scopeType>:<uuid>` form, e.g. `organization:<organization_id>` or `team:<team_id>`. Omit the header for the all-workspaces view."
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "platform",
                    "resource_type",
                    "resources"
                  ],
                  "properties": {
                    "message": {
                      "type": "string"
                    },
                    "platform": {
                      "type": "string"
                    },
                    "resource_type": {
                      "type": "string"
                    },
                    "resources": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "id",
                          "name"
                        ],
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "meta": {
                            "description": "JSON object with nested arrays and objects.",
                            "type": "object",
                            "additionalProperties": {
                              "$comment": "json-value",
                              "description": "Arbitrary JSON value with nested arrays and objects."
                            }
                          },
                          "name": {
                            "type": "string"
                          }
                        }
                      }
                    },
                    "unavailable": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/launch/resources-by-token": {
      "get": {
        "operationId": "getApiV1LaunchResourcesByToken",
        "summary": "Get launch resources filtered by Meta token",
        "tags": [
          "launch"
        ],
        "description": "Returns ad accounts, fan pages or pixels filtered by the selected Meta token, scoped to the active workspace (accessible team set narrowed by `x-team-id` / `x-active-scope`, with legacy NULL-team rows visible to their owning session). Used by the Ad Launcher to populate cascading dropdowns.",
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "query",
            "name": "meta_token_id",
            "required": true
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "ad_account_id",
            "required": false
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "for_pixels",
            "required": false
          },
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "header",
            "name": "x-team-id",
            "required": false,
            "description": "Explicit team (workspace) scope: a team.id the caller belongs to."
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "header",
            "name": "x-active-scope",
            "required": false,
            "description": "Active scope selector in `<scopeType>:<uuid>` form, e.g. `organization:<organization_id>` or `team:<team_id>`. Omit the header for the all-workspaces view."
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "properties": {
                    "ad_accounts": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "account_id",
                          "account_name",
                          "business_id",
                          "business_name",
                          "account_currency",
                          "account_timezone",
                          "account_timezone_offset_hours_utc",
                          "account_status",
                          "validated_tokens_missing"
                        ],
                        "properties": {
                          "account_id": {
                            "type": "string"
                          },
                          "account_name": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "business_id": {
                            "type": "string"
                          },
                          "business_name": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "account_currency": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "account_timezone": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "account_timezone_offset_hours_utc": {
                            "anyOf": [
                              {
                                "type": "integer"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "account_status": {
                            "anyOf": [
                              {
                                "type": "integer"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "validated_tokens_missing": {
                            "description": "True when the ad account was synced but never connected (validated_tokens is SQL NULL). This is the only state the publish worker rejects outright; a connected=false flag or an empty token array do NOT prevent publishing, because the token is also resolved from token_resource_permission.",
                            "type": "boolean"
                          }
                        }
                      }
                    },
                    "meta_user": {
                      "type": "object",
                      "required": [
                        "id",
                        "name",
                        "email",
                        "business_user_ids"
                      ],
                      "properties": {
                        "id": {
                          "type": "string"
                        },
                        "name": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "email": {
                          "type": "string"
                        },
                        "business_user_ids": {
                          "anyOf": [
                            {
                              "description": "JSON object with nested arrays and objects.",
                              "type": "object",
                              "additionalProperties": {
                                "$comment": "json-value",
                                "description": "Arbitrary JSON value with nested arrays and objects."
                              }
                            },
                            {
                              "type": "null"
                            }
                          ]
                        }
                      }
                    },
                    "fan_pages": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "fan_page_id",
                          "fan_page_name",
                          "business_id",
                          "business_name",
                          "same_business"
                        ],
                        "properties": {
                          "fan_page_id": {
                            "type": "string"
                          },
                          "fan_page_name": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "business_id": {
                            "type": "string"
                          },
                          "business_name": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "same_business": {
                            "type": "boolean"
                          }
                        }
                      }
                    },
                    "pixels": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "pixel_id",
                          "pixel_name",
                          "business_id",
                          "business_name"
                        ],
                        "properties": {
                          "pixel_id": {
                            "type": "string"
                          },
                          "pixel_name": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "business_id": {
                            "type": "string"
                          },
                          "business_name": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/launch-templates/curated": {
      "get": {
        "operationId": "getApiV1LaunchTemplatesCurated",
        "summary": "List Wevion-curated (\"Playbook\") launch templates",
        "tags": [
          "launch"
        ],
        "description": "Returns the globally-visible, Wevion-curated launch templates. Read-only for every authenticated user — no ownership or sharing filter applies.",
        "parameters": [
          {
            "schema": {
              "maxLength": 5,
              "type": "string"
            },
            "in": "query",
            "name": "lang",
            "required": false
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "items"
                  ],
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "id",
                          "name",
                          "display_name",
                          "description",
                          "category",
                          "created_at",
                          "preview"
                        ],
                        "properties": {
                          "id": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "name": {
                            "type": "string"
                          },
                          "display_name": {
                            "type": "string"
                          },
                          "description": {
                            "type": "string"
                          },
                          "category": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "created_at": {
                            "format": "date-time",
                            "type": "string"
                          },
                          "preview": {
                            "type": "object",
                            "required": [
                              "objective",
                              "budget",
                              "budget_level",
                              "ad_set_budgets",
                              "ad_sets_count",
                              "ads_count",
                              "countries"
                            ],
                            "properties": {
                              "objective": {
                                "type": "string"
                              },
                              "budget": {
                                "type": "string"
                              },
                              "budget_level": {
                                "type": "string"
                              },
                              "ad_set_budgets": {
                                "type": "array",
                                "items": {
                                  "type": "string"
                                }
                              },
                              "ad_sets_count": {
                                "type": "integer"
                              },
                              "ads_count": {
                                "type": "integer"
                              },
                              "countries": {
                                "type": "array",
                                "items": {
                                  "type": "string"
                                }
                              }
                            }
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/launch-templates": {
      "get": {
        "operationId": "getApiV1LaunchTemplates",
        "summary": "List launch templates",
        "tags": [
          "launch"
        ],
        "description": "Returns all saved launch templates for the authenticated user, including a preview of each template configuration.",
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "items"
                  ],
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "id",
                          "name",
                          "created_at",
                          "is_owner",
                          "is_shared",
                          "shared_count",
                          "can_manage",
                          "owner",
                          "preview"
                        ],
                        "properties": {
                          "id": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "name": {
                            "type": "string"
                          },
                          "created_at": {
                            "format": "date-time",
                            "type": "string"
                          },
                          "is_owner": {
                            "type": "boolean"
                          },
                          "is_shared": {
                            "type": "boolean"
                          },
                          "shared_count": {
                            "type": "integer"
                          },
                          "can_manage": {
                            "type": "boolean"
                          },
                          "owner": {
                            "type": "object",
                            "required": [
                              "id",
                              "name",
                              "email"
                            ],
                            "properties": {
                              "id": {
                                "format": "uuid",
                                "type": "string"
                              },
                              "name": {
                                "anyOf": [
                                  {
                                    "type": "string"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "email": {
                                "type": "string"
                              }
                            }
                          },
                          "preview": {
                            "type": "object",
                            "required": [
                              "objective",
                              "budget",
                              "budget_level",
                              "ad_set_budgets",
                              "ad_sets_count",
                              "ads_count",
                              "countries"
                            ],
                            "properties": {
                              "objective": {
                                "type": "string"
                              },
                              "budget": {
                                "type": "string"
                              },
                              "budget_level": {
                                "type": "string"
                              },
                              "ad_set_budgets": {
                                "type": "array",
                                "items": {
                                  "type": "string"
                                }
                              },
                              "ad_sets_count": {
                                "type": "integer"
                              },
                              "ads_count": {
                                "type": "integer"
                              },
                              "countries": {
                                "type": "array",
                                "items": {
                                  "type": "string"
                                }
                              }
                            }
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "postApiV1LaunchTemplates",
        "summary": "Save a launch template",
        "tags": [
          "launch"
        ],
        "description": "Creates a new launch template with the given name and campaign configuration data. Template names must be unique per user.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "name",
                  "template_data"
                ],
                "properties": {
                  "name": {
                    "minLength": 1,
                    "maxLength": 255,
                    "type": "string"
                  },
                  "template_data": {
                    "description": "JSON object with nested arrays and objects.",
                    "type": "object",
                    "additionalProperties": {
                      "$comment": "json-value",
                      "description": "Arbitrary JSON value with nested arrays and objects."
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "201": {
            "description": "Resource created",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "id",
                    "name",
                    "created_at"
                  ],
                  "properties": {
                    "id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "name": {
                      "type": "string"
                    },
                    "created_at": {
                      "format": "date-time",
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "409": {
            "description": "Conflict - resource state prevents the operation",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "413": {
            "description": "Payload too large",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/launch-templates/{id}": {
      "get": {
        "operationId": "getApiV1LaunchTemplatesById",
        "summary": "Get launch template by ID",
        "tags": [
          "launch"
        ],
        "description": "Returns the full template data for a specific launch template, including the complete campaign configuration.",
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "id",
                    "name",
                    "template_data",
                    "cleared_fields",
                    "created_at"
                  ],
                  "properties": {
                    "id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "name": {
                      "type": "string"
                    },
                    "template_data": {
                      "description": "JSON object with nested arrays and objects.",
                      "type": "object",
                      "additionalProperties": {
                        "$comment": "json-value",
                        "description": "Arbitrary JSON value with nested arrays and objects."
                      }
                    },
                    "cleared_fields": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "created_at": {
                      "format": "date-time",
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      },
      "patch": {
        "operationId": "patchApiV1LaunchTemplatesById",
        "summary": "Rename a launch template",
        "tags": [
          "launch"
        ],
        "description": "Updates the name of an existing launch template. The new name must be unique per user.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "name"
                ],
                "properties": {
                  "name": {
                    "minLength": 1,
                    "maxLength": 255,
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "id",
                    "name"
                  ],
                  "properties": {
                    "id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "name": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "Conflict - resource state prevents the operation",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      },
      "delete": {
        "operationId": "deleteApiV1LaunchTemplatesById",
        "summary": "Delete a launch template",
        "tags": [
          "launch"
        ],
        "description": "Permanently deletes a launch template by ID.",
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "message"
                  ],
                  "properties": {
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/launch-templates/{id}/shares": {
      "get": {
        "operationId": "getApiV1LaunchTemplatesByIdShares",
        "summary": "List the recipients a template is shared with (owner only)",
        "tags": [
          "launch"
        ],
        "description": "Returns the user IDs that currently have access to a launch template. Only the template owner can list shares.",
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "user_ids"
                  ],
                  "properties": {
                    "user_ids": {
                      "type": "array",
                      "items": {
                        "format": "uuid",
                        "type": "string"
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      },
      "put": {
        "operationId": "putApiV1LaunchTemplatesByIdShares",
        "summary": "Set the recipients a template is shared with (owner only)",
        "tags": [
          "launch"
        ],
        "description": "Replaces the share list for a launch template with team members accessible to the owner. Passing an empty list revokes all shares.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "user_ids"
                ],
                "properties": {
                  "user_ids": {
                    "maxItems": 500,
                    "type": "array",
                    "items": {
                      "format": "uuid",
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "shared_with"
                  ],
                  "properties": {
                    "shared_with": {
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/launch-templates/{id}/duplicate": {
      "post": {
        "operationId": "postApiV1LaunchTemplatesByIdDuplicate",
        "summary": "Duplicate a (possibly shared) template into your own templates",
        "tags": [
          "launch"
        ],
        "description": "Copies a readable launch template into the authenticated user’s own template library. Shared templates are sanitized before duplication.",
        "parameters": [
          {
            "schema": {
              "maxLength": 5,
              "type": "string"
            },
            "in": "query",
            "name": "lang",
            "required": false
          },
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "id",
                    "name",
                    "reused"
                  ],
                  "properties": {
                    "id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "name": {
                      "type": "string"
                    },
                    "reused": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "201": {
            "description": "Resource created",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "id",
                    "name",
                    "reused"
                  ],
                  "properties": {
                    "id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "name": {
                      "type": "string"
                    },
                    "reused": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "Conflict - resource state prevents the operation",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/launch-templates/export": {
      "post": {
        "operationId": "postApiV1LaunchTemplatesExport",
        "summary": "Export own launch templates to a portable JSON envelope",
        "tags": [
          "launch"
        ],
        "description": "Exports one or more templates owned by the authenticated user into the Wevion launch-template envelope, stripping account-bound fields and adding readable resource names when available.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "ids"
                ],
                "properties": {
                  "ids": {
                    "minItems": 1,
                    "maxItems": 250,
                    "type": "array",
                    "items": {
                      "format": "uuid",
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "format",
                    "version",
                    "templates"
                  ],
                  "properties": {
                    "format": {
                      "type": "string"
                    },
                    "version": {
                      "type": "integer"
                    },
                    "templates": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "name",
                          "template_data"
                        ],
                        "properties": {
                          "name": {
                            "type": "string"
                          },
                          "template_data": {
                            "description": "JSON object with nested arrays and objects.",
                            "type": "object",
                            "additionalProperties": {
                              "$comment": "json-value",
                              "description": "Arbitrary JSON value with nested arrays and objects."
                            }
                          },
                          "resource_names": {
                            "additionalProperties": false,
                            "type": "object",
                            "properties": {
                              "account": {
                                "type": "string"
                              },
                              "pixel": {
                                "type": "string"
                              },
                              "page": {
                                "type": "string"
                              }
                            }
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/launch-templates/import": {
      "post": {
        "operationId": "postApiV1LaunchTemplatesImport",
        "summary": "Import launch templates from a JSON envelope into your own templates",
        "tags": [
          "launch"
        ],
        "description": "Imports templates from a Wevion launch-template export envelope into the authenticated user’s template library, resolving resource names against accessible assets when supplied.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "format",
                  "version",
                  "templates"
                ],
                "properties": {
                  "format": {
                    "type": "string",
                    "enum": [
                      "wevion.launch-templates"
                    ]
                  },
                  "version": {
                    "type": "integer"
                  },
                  "templates": {
                    "minItems": 1,
                    "maxItems": 250,
                    "type": "array",
                    "items": {
                      "additionalProperties": false,
                      "type": "object",
                      "required": [
                        "name",
                        "template_data"
                      ],
                      "properties": {
                        "name": {
                          "minLength": 1,
                          "maxLength": 255,
                          "type": "string"
                        },
                        "template_data": {
                          "description": "JSON object with nested arrays and objects.",
                          "type": "object",
                          "additionalProperties": {
                            "$comment": "json-value",
                            "description": "Arbitrary JSON value with nested arrays and objects."
                          }
                        },
                        "resource_names": {
                          "additionalProperties": false,
                          "type": "object",
                          "properties": {
                            "account": {
                              "type": "string"
                            },
                            "pixel": {
                              "type": "string"
                            },
                            "page": {
                              "type": "string"
                            }
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "imported",
                    "renamed",
                    "skipped"
                  ],
                  "properties": {
                    "imported": {
                      "type": "integer"
                    },
                    "renamed": {
                      "type": "integer"
                    },
                    "skipped": {
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/launch-templates/bulk": {
      "delete": {
        "operationId": "deleteApiV1LaunchTemplatesBulk",
        "summary": "Bulk delete launch templates",
        "tags": [
          "launch"
        ],
        "description": "Permanently deletes multiple launch templates by their IDs. Only deletes templates owned by the authenticated user.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "ids"
                ],
                "properties": {
                  "ids": {
                    "minItems": 1,
                    "maxItems": 250,
                    "type": "array",
                    "items": {
                      "format": "uuid",
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "deleted"
                  ],
                  "properties": {
                    "deleted": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/locale-search": {
      "get": {
        "operationId": "getApiV1LocaleSearch",
        "summary": "List or search Meta locales for ad-set language targeting",
        "tags": [
          "targeting"
        ],
        "description": "Proxies Meta Marketing API `search?type=adlocale`, returning the numeric locale IDs accepted by `targeting.locales` on an ad set. Meta owns the list, so it is queried live rather than mirrored in code — a copy in the repo goes stale and only ever covers part of it. With `q` omitted Meta returns its COMPLETE list (92 locales as of 2026-08-20), which is small enough for the client to hold and filter locally; `q` is still accepted for narrower lookups. Returns `degraded: true` with an empty list when the ad account has no usable token or Meta is unreachable, so the caller can distinguish an outage from a query that matched nothing.",
        "parameters": [
          {
            "schema": {
              "maxLength": 100,
              "type": "string"
            },
            "in": "query",
            "name": "q",
            "required": false,
            "description": "Search query (e.g. \"eng\"). Omit or leave empty to get Meta's complete locale list."
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "account_id",
            "required": true,
            "description": "Ad account ID to resolve token"
          }
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "degraded",
                    "locales"
                  ],
                  "properties": {
                    "degraded": {
                      "type": "boolean"
                    },
                    "locales": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "key",
                          "name"
                        ],
                        "properties": {
                          "key": {
                            "description": "Meta locale ID, sent verbatim in targeting.locales",
                            "type": "integer"
                          },
                          "name": {
                            "description": "Display name, e.g. \"English (All)\"",
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "integer"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "integer"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "integer"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/market-intelligence/benchmarks": {
      "get": {
        "operationId": "getApiV1MarketIntelligenceBenchmarks",
        "summary": "List market benchmarks",
        "tags": [
          "market-intelligence"
        ],
        "description": "Returns industry benchmark rows for the requested industry, geography, and optional metric.",
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "geo",
            "required": false
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "industry",
            "required": false
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "metric",
            "required": false
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "items"
                  ],
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "additionalProperties": false,
                        "type": "object",
                        "required": [
                          "id",
                          "industry",
                          "geo",
                          "metric",
                          "value_p25",
                          "value_median",
                          "value_p75",
                          "source",
                          "data_period",
                          "account_count",
                          "updated_at"
                        ],
                        "properties": {
                          "id": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "industry": {
                            "type": "string"
                          },
                          "geo": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "metric": {
                            "type": "string"
                          },
                          "value_p25": {
                            "anyOf": [
                              {
                                "anyOf": [
                                  {
                                    "type": "number"
                                  },
                                  {
                                    "type": "string"
                                  }
                                ]
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "value_median": {
                            "anyOf": [
                              {
                                "anyOf": [
                                  {
                                    "type": "number"
                                  },
                                  {
                                    "type": "string"
                                  }
                                ]
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "value_p75": {
                            "anyOf": [
                              {
                                "anyOf": [
                                  {
                                    "type": "number"
                                  },
                                  {
                                    "type": "string"
                                  }
                                ]
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "source": {
                            "type": "string"
                          },
                          "data_period": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "account_count": {
                            "anyOf": [
                              {
                                "type": "integer"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "updated_at": {
                            "format": "date-time",
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "error_code": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/market-intelligence/benchmark-comparison": {
      "get": {
        "operationId": "getApiV1MarketIntelligenceBenchmarkComparison",
        "summary": "Compare account metrics to benchmarks",
        "tags": [
          "market-intelligence"
        ],
        "description": "Compares recent account performance against market benchmark percentiles.",
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "account_id",
            "required": false
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "geo",
            "required": false
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "industry",
            "required": false
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "benchmarks",
                    "comparisons",
                    "sourceDate"
                  ],
                  "properties": {
                    "benchmarks": {
                      "type": "array",
                      "items": {
                        "additionalProperties": false,
                        "type": "object",
                        "required": [
                          "id",
                          "industry",
                          "geo",
                          "metric",
                          "value_p25",
                          "value_median",
                          "value_p75",
                          "source",
                          "data_period",
                          "account_count",
                          "updated_at"
                        ],
                        "properties": {
                          "id": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "industry": {
                            "type": "string"
                          },
                          "geo": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "metric": {
                            "type": "string"
                          },
                          "value_p25": {
                            "anyOf": [
                              {
                                "anyOf": [
                                  {
                                    "type": "number"
                                  },
                                  {
                                    "type": "string"
                                  }
                                ]
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "value_median": {
                            "anyOf": [
                              {
                                "anyOf": [
                                  {
                                    "type": "number"
                                  },
                                  {
                                    "type": "string"
                                  }
                                ]
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "value_p75": {
                            "anyOf": [
                              {
                                "anyOf": [
                                  {
                                    "type": "number"
                                  },
                                  {
                                    "type": "string"
                                  }
                                ]
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "source": {
                            "type": "string"
                          },
                          "data_period": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "account_count": {
                            "anyOf": [
                              {
                                "type": "integer"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "updated_at": {
                            "format": "date-time",
                            "type": "string"
                          }
                        }
                      }
                    },
                    "comparisons": {
                      "type": "array",
                      "items": {
                        "additionalProperties": false,
                        "type": "object",
                        "required": [
                          "benchmark",
                          "metric",
                          "position",
                          "value"
                        ],
                        "properties": {
                          "benchmark": {
                            "additionalProperties": false,
                            "type": "object",
                            "required": [
                              "id",
                              "industry",
                              "geo",
                              "metric",
                              "value_p25",
                              "value_median",
                              "value_p75",
                              "source",
                              "data_period",
                              "account_count",
                              "updated_at"
                            ],
                            "properties": {
                              "id": {
                                "format": "uuid",
                                "type": "string"
                              },
                              "industry": {
                                "type": "string"
                              },
                              "geo": {
                                "anyOf": [
                                  {
                                    "type": "string"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "metric": {
                                "type": "string"
                              },
                              "value_p25": {
                                "anyOf": [
                                  {
                                    "anyOf": [
                                      {
                                        "type": "number"
                                      },
                                      {
                                        "type": "string"
                                      }
                                    ]
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "value_median": {
                                "anyOf": [
                                  {
                                    "anyOf": [
                                      {
                                        "type": "number"
                                      },
                                      {
                                        "type": "string"
                                      }
                                    ]
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "value_p75": {
                                "anyOf": [
                                  {
                                    "anyOf": [
                                      {
                                        "type": "number"
                                      },
                                      {
                                        "type": "string"
                                      }
                                    ]
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "source": {
                                "type": "string"
                              },
                              "data_period": {
                                "anyOf": [
                                  {
                                    "type": "string"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "account_count": {
                                "anyOf": [
                                  {
                                    "type": "integer"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "updated_at": {
                                "format": "date-time",
                                "type": "string"
                              }
                            }
                          },
                          "metric": {
                            "type": "string"
                          },
                          "position": {
                            "type": "string"
                          },
                          "value": {
                            "anyOf": [
                              {
                                "type": "number"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          }
                        }
                      }
                    },
                    "sourceDate": {
                      "anyOf": [
                        {
                          "format": "date-time",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "error_code": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/market-intelligence/trends": {
      "get": {
        "operationId": "getApiV1MarketIntelligenceTrends",
        "summary": "List market trend feed",
        "tags": [
          "market-intelligence"
        ],
        "description": "Returns market trend feed items personalized for the current team profile.",
        "parameters": [
          {
            "schema": {
              "type": "number"
            },
            "in": "query",
            "name": "limit",
            "required": false
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "items"
                  ],
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "additionalProperties": false,
                        "type": "object",
                        "required": [
                          "id",
                          "title",
                          "is_read",
                          "relevance_score"
                        ],
                        "properties": {
                          "id": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "team_id": {
                            "anyOf": [
                              {
                                "format": "uuid",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "session_id": {
                            "anyOf": [
                              {
                                "format": "uuid",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "industry": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "geo": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "source_domain": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "title": {
                            "type": "string"
                          },
                          "summary": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "source_url": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "trend_type": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "actionable_insight": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "personalised": {
                            "type": "boolean"
                          },
                          "personalised_evidence": {
                            "anyOf": [
                              {
                                "$comment": "json-value"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "published_at": {
                            "anyOf": [
                              {
                                "format": "date-time",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "generated_at": {
                            "format": "date-time",
                            "type": "string"
                          },
                          "expires_at": {
                            "format": "date-time",
                            "type": "string"
                          },
                          "data_confidence": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "data_evidence": {
                            "anyOf": [
                              {
                                "$comment": "json-value"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "is_read": {
                            "type": "boolean"
                          },
                          "is_dismissed": {
                            "type": "boolean"
                          },
                          "relevance_score": {
                            "anyOf": [
                              {
                                "type": "number"
                              },
                              {
                                "type": "string"
                              }
                            ]
                          }
                        }
                      }
                    },
                    "unreadCount": {
                      "type": "integer"
                    },
                    "unread_count": {
                      "type": "integer"
                    },
                    "unavailable_reason": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "error_code": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/market-intelligence/trends/generate": {
      "post": {
        "operationId": "postApiV1MarketIntelligenceTrendsGenerate",
        "summary": "Generate market trend feed",
        "tags": [
          "market-intelligence"
        ],
        "description": "Runs on-demand market trend discovery and stores deduplicated trend feed items.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "properties": {
                  "industry": {
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "items",
                    "industry",
                    "geo"
                  ],
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "additionalProperties": false,
                        "type": "object",
                        "required": [
                          "id",
                          "title",
                          "is_read",
                          "relevance_score"
                        ],
                        "properties": {
                          "id": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "team_id": {
                            "anyOf": [
                              {
                                "format": "uuid",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "session_id": {
                            "anyOf": [
                              {
                                "format": "uuid",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "industry": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "geo": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "source_domain": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "title": {
                            "type": "string"
                          },
                          "summary": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "source_url": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "trend_type": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "actionable_insight": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "personalised": {
                            "type": "boolean"
                          },
                          "personalised_evidence": {
                            "anyOf": [
                              {
                                "$comment": "json-value"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "published_at": {
                            "anyOf": [
                              {
                                "format": "date-time",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "generated_at": {
                            "format": "date-time",
                            "type": "string"
                          },
                          "expires_at": {
                            "format": "date-time",
                            "type": "string"
                          },
                          "data_confidence": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "data_evidence": {
                            "anyOf": [
                              {
                                "$comment": "json-value"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "is_read": {
                            "type": "boolean"
                          },
                          "is_dismissed": {
                            "type": "boolean"
                          },
                          "relevance_score": {
                            "anyOf": [
                              {
                                "type": "number"
                              },
                              {
                                "type": "string"
                              }
                            ]
                          }
                        }
                      }
                    },
                    "industry": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "geo": {
                      "type": "string"
                    },
                    "unavailableReason": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "error_code": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/market-intelligence/trends/{id}/read": {
      "patch": {
        "operationId": "patchApiV1MarketIntelligenceTrendsByIdRead",
        "summary": "Mark market trend as read",
        "tags": [
          "market-intelligence"
        ],
        "description": "Marks a market trend feed item as read for the current team scope.",
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "id",
                    "title",
                    "is_read",
                    "relevance_score"
                  ],
                  "properties": {
                    "id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "team_id": {
                      "anyOf": [
                        {
                          "format": "uuid",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "session_id": {
                      "anyOf": [
                        {
                          "format": "uuid",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "industry": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "geo": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "source_domain": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "title": {
                      "type": "string"
                    },
                    "summary": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "source_url": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "trend_type": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "actionable_insight": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "personalised": {
                      "type": "boolean"
                    },
                    "personalised_evidence": {
                      "anyOf": [
                        {
                          "$comment": "json-value"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "published_at": {
                      "anyOf": [
                        {
                          "format": "date-time",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "generated_at": {
                      "format": "date-time",
                      "type": "string"
                    },
                    "expires_at": {
                      "format": "date-time",
                      "type": "string"
                    },
                    "data_confidence": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "data_evidence": {
                      "anyOf": [
                        {
                          "$comment": "json-value"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "is_read": {
                      "type": "boolean"
                    },
                    "is_dismissed": {
                      "type": "boolean"
                    },
                    "relevance_score": {
                      "anyOf": [
                        {
                          "type": "number"
                        },
                        {
                          "type": "string"
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "error_code": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/market-intelligence/cost-trends": {
      "get": {
        "operationId": "getApiV1MarketIntelligenceCostTrends",
        "summary": "Get paid media cost trends",
        "tags": [
          "market-intelligence"
        ],
        "description": "Returns CPM/CPC trend series and seasonal annotations for the accessible team scope.",
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "account_id",
            "required": false
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "annotations",
                    "cpmChangePct",
                    "series",
                    "status"
                  ],
                  "properties": {
                    "annotations": {
                      "type": "array",
                      "items": {
                        "additionalProperties": false,
                        "type": "object",
                        "required": [
                          "period_label",
                          "period_start_mmdd",
                          "period_end_mmdd",
                          "metric",
                          "avg_change_pct"
                        ],
                        "properties": {
                          "period_label": {
                            "type": "string"
                          },
                          "period_start_mmdd": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "period_end_mmdd": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "metric": {
                            "type": "string"
                          },
                          "avg_change_pct": {
                            "anyOf": [
                              {
                                "anyOf": [
                                  {
                                    "type": "number"
                                  },
                                  {
                                    "type": "string"
                                  }
                                ]
                              },
                              {
                                "type": "null"
                              }
                            ]
                          }
                        }
                      }
                    },
                    "cpmChangePct": {
                      "anyOf": [
                        {
                          "type": "integer"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "series": {
                      "type": "array",
                      "items": {
                        "additionalProperties": false,
                        "type": "object",
                        "required": [
                          "date",
                          "cpm",
                          "cpc"
                        ],
                        "properties": {
                          "date": {
                            "format": "date",
                            "type": "string"
                          },
                          "cpm": {
                            "anyOf": [
                              {
                                "anyOf": [
                                  {
                                    "type": "number"
                                  },
                                  {
                                    "type": "string"
                                  }
                                ]
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "cpc": {
                            "anyOf": [
                              {
                                "anyOf": [
                                  {
                                    "type": "number"
                                  },
                                  {
                                    "type": "string"
                                  }
                                ]
                              },
                              {
                                "type": "null"
                              }
                            ]
                          }
                        }
                      }
                    },
                    "status": {
                      "anyOf": [
                        {
                          "type": "string",
                          "enum": [
                            "insufficient_data"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "rising"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "falling"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "stable"
                          ]
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "error_code": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/market-intelligence/google-trends-search": {
      "post": {
        "operationId": "postApiV1MarketIntelligenceGoogleTrendsSearch",
        "summary": "Search Google Trends signal",
        "tags": [
          "market-intelligence"
        ],
        "description": "Returns Google Trends or Keyword Planner demand signals for one keyword.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "keyword"
                ],
                "properties": {
                  "keyword": {
                    "minLength": 1,
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "geo",
                    "points",
                    "provider",
                    "query",
                    "relatedQueries",
                    "relatedTopics",
                    "status",
                    "timeframe"
                  ],
                  "properties": {
                    "elapsedMs": {
                      "type": "number"
                    },
                    "geo": {
                      "type": "string"
                    },
                    "points": {
                      "type": "array",
                      "items": {
                        "additionalProperties": false,
                        "type": "object",
                        "required": [
                          "date",
                          "value"
                        ],
                        "properties": {
                          "date": {
                            "type": "string"
                          },
                          "rawSearches": {
                            "anyOf": [
                              {
                                "type": "number"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "timestamp": {
                            "anyOf": [
                              {
                                "type": "number"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "value": {
                            "anyOf": [
                              {
                                "type": "number"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          }
                        }
                      }
                    },
                    "provider": {
                      "anyOf": [
                        {
                          "type": "string",
                          "enum": [
                            "serpapi"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "google_ads_keyword_planner"
                          ]
                        }
                      ]
                    },
                    "query": {
                      "type": "string"
                    },
                    "relatedQueries": {
                      "type": "array",
                      "items": {
                        "additionalProperties": false,
                        "type": "object",
                        "required": [
                          "query"
                        ],
                        "properties": {
                          "avgMonthlySearches": {
                            "anyOf": [
                              {
                                "type": "number"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "competition": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "query": {
                            "type": "string"
                          }
                        }
                      }
                    },
                    "relatedTopics": {
                      "type": "array",
                      "items": {
                        "additionalProperties": false,
                        "type": "object",
                        "required": [
                          "query"
                        ],
                        "properties": {
                          "avgMonthlySearches": {
                            "anyOf": [
                              {
                                "type": "number"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "competition": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "query": {
                            "type": "string"
                          }
                        }
                      }
                    },
                    "seedAvgMonthlySearches": {
                      "anyOf": [
                        {
                          "type": "number"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "seedCompetition": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "seedCpcRange": {
                      "anyOf": [
                        {
                          "type": "object",
                          "required": [
                            "high",
                            "low"
                          ],
                          "properties": {
                            "high": {
                              "anyOf": [
                                {
                                  "type": "number"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "low": {
                              "anyOf": [
                                {
                                  "type": "number"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            }
                          }
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "sourceUrl": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "status": {
                      "type": "string"
                    },
                    "timeframe": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "error_code": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/market-intelligence/google-trends-scope": {
      "get": {
        "operationId": "getApiV1MarketIntelligenceGoogleTrendsScope",
        "summary": "Scan Google Trends scope",
        "tags": [
          "market-intelligence"
        ],
        "description": "Derives adjacent search keywords from account context and returns trend signals for each seed.",
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "baseProducts",
                    "geo",
                    "industry",
                    "keywords",
                    "results"
                  ],
                  "properties": {
                    "baseProducts": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "geo": {
                      "type": "string"
                    },
                    "industry": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "keywords": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "results": {
                      "type": "array",
                      "items": {
                        "additionalProperties": false,
                        "type": "object",
                        "required": [
                          "geo",
                          "points",
                          "provider",
                          "query",
                          "relatedQueries",
                          "relatedTopics",
                          "status",
                          "timeframe"
                        ],
                        "properties": {
                          "elapsedMs": {
                            "type": "number"
                          },
                          "geo": {
                            "type": "string"
                          },
                          "points": {
                            "type": "array",
                            "items": {
                              "additionalProperties": false,
                              "type": "object",
                              "required": [
                                "date",
                                "value"
                              ],
                              "properties": {
                                "date": {
                                  "type": "string"
                                },
                                "rawSearches": {
                                  "anyOf": [
                                    {
                                      "type": "number"
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "timestamp": {
                                  "anyOf": [
                                    {
                                      "type": "number"
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "value": {
                                  "anyOf": [
                                    {
                                      "type": "number"
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                }
                              }
                            }
                          },
                          "provider": {
                            "anyOf": [
                              {
                                "type": "string",
                                "enum": [
                                  "serpapi"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "google_ads_keyword_planner"
                                ]
                              }
                            ]
                          },
                          "query": {
                            "type": "string"
                          },
                          "relatedQueries": {
                            "type": "array",
                            "items": {
                              "additionalProperties": false,
                              "type": "object",
                              "required": [
                                "query"
                              ],
                              "properties": {
                                "avgMonthlySearches": {
                                  "anyOf": [
                                    {
                                      "type": "number"
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "competition": {
                                  "anyOf": [
                                    {
                                      "type": "string"
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "query": {
                                  "type": "string"
                                }
                              }
                            }
                          },
                          "relatedTopics": {
                            "type": "array",
                            "items": {
                              "additionalProperties": false,
                              "type": "object",
                              "required": [
                                "query"
                              ],
                              "properties": {
                                "avgMonthlySearches": {
                                  "anyOf": [
                                    {
                                      "type": "number"
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "competition": {
                                  "anyOf": [
                                    {
                                      "type": "string"
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "query": {
                                  "type": "string"
                                }
                              }
                            }
                          },
                          "seedAvgMonthlySearches": {
                            "anyOf": [
                              {
                                "type": "number"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "seedCompetition": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "seedCpcRange": {
                            "anyOf": [
                              {
                                "type": "object",
                                "required": [
                                  "high",
                                  "low"
                                ],
                                "properties": {
                                  "high": {
                                    "anyOf": [
                                      {
                                        "type": "number"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "low": {
                                    "anyOf": [
                                      {
                                        "type": "number"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  }
                                }
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "sourceUrl": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "status": {
                            "type": "string"
                          },
                          "timeframe": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "error_code": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/public/marketing-coupons/{code}": {
      "get": {
        "operationId": "getApiV1PublicMarketingCouponsByCode",
        "summary": "Look up an ambassador coupon",
        "tags": [
          "public"
        ],
        "description": "Public lookup of an active ambassador marketing coupon by code. Returns display-safe fields (person name and photo) rendered pre-applied on the login/register pages.",
        "parameters": [
          {
            "schema": {
              "minLength": 3,
              "maxLength": 80,
              "type": "string"
            },
            "in": "path",
            "name": "code",
            "required": true
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "code",
                    "person_name",
                    "photo_url"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "person_name": {
                      "type": "string"
                    },
                    "photo_url": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/marketing-coupons/redeem": {
      "post": {
        "operationId": "postApiV1MarketingCouponsRedeem",
        "summary": "Redeem an ambassador coupon",
        "tags": [
          "billing"
        ],
        "description": "Redeems an ambassador coupon for a new authenticated signup: comps the plan and window configured on the coupon (default 3 months of Pro; e.g. the Budapest voucher grants 1 month of Plus), with no Stripe involvement. Existing accounts and accounts that already have a subscription are refused.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "code"
                ],
                "properties": {
                  "code": {
                    "minLength": 3,
                    "maxLength": 80,
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "plan_name",
                    "months",
                    "person_name"
                  ],
                  "properties": {
                    "plan_name": {
                      "type": "string"
                    },
                    "months": {
                      "type": "number"
                    },
                    "person_name": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "Conflict - resource state prevents the operation",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/marketing/request-demo": {
      "post": {
        "operationId": "postApiV1MarketingRequestDemo",
        "summary": "Record that the authenticated user requested a demo (F3, idempotent)",
        "tags": [
          "marketing"
        ],
        "description": "Idempotently records the first demo request timestamp for the authenticated user and emits the marketing.demo_requested lifecycle event.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "properties": {}
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "demo_requested_at"
                  ],
                  "properties": {
                    "demo_requested_at": {
                      "format": "date-time",
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/meta/campaigns/{campaignId}/change-history": {
      "get": {
        "operationId": "getApiV1MetaCampaignsByCampaignIdChangeHistory",
        "summary": "Get the change history for a Meta campaign",
        "tags": [
          "meta"
        ],
        "description": "Reads the campaign's change log live from Meta's /activities edge (Meta Ads Manager \"Cronologia\").",
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "since",
            "required": false
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "until",
            "required": false
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "actor_id",
            "required": false
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "field",
            "required": false
          },
          {
            "schema": {
              "minimum": 1,
              "maximum": 500,
              "type": "integer"
            },
            "in": "query",
            "name": "limit",
            "required": false
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "after",
            "required": false
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "locale",
            "required": false
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "path",
            "name": "campaignId",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "items",
                    "next_cursor"
                  ],
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "additionalProperties": false,
                        "type": "object",
                        "required": [
                          "id",
                          "event_time",
                          "actor_id",
                          "actor_name",
                          "event_type",
                          "translated_event_type",
                          "entity_level",
                          "field",
                          "old_value",
                          "new_value",
                          "object_id",
                          "object_name",
                          "application_name"
                        ],
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "event_time": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "actor_id": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "actor_name": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "event_type": {
                            "type": "string"
                          },
                          "translated_event_type": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "entity_level": {
                            "type": "string"
                          },
                          "field": {
                            "type": "string"
                          },
                          "old_value": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "new_value": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "object_id": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "object_name": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "application_name": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          }
                        }
                      }
                    },
                    "next_cursor": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/meta/ad-accounts/{adAccountId}/recent-activity": {
      "get": {
        "operationId": "getApiV1MetaAdAccountsByAdAccountIdRecentActivity",
        "summary": "Get the most recent change per object in an ad account",
        "tags": [
          "meta"
        ],
        "description": "Powers the \"Last modified\" column. One /act_{id}/activities call, reduced to last-change per object.",
        "parameters": [
          {
            "schema": {
              "minimum": 1,
              "maximum": 500,
              "type": "integer"
            },
            "in": "query",
            "name": "limit",
            "required": false
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "path",
            "name": "adAccountId",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "items"
                  ],
                  "properties": {
                    "items": {
                      "type": "object",
                      "additionalProperties": {
                        "additionalProperties": false,
                        "type": "object",
                        "required": [
                          "event_time",
                          "actor_name",
                          "translated_event_type",
                          "field",
                          "entity_level"
                        ],
                        "properties": {
                          "event_time": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "actor_name": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "translated_event_type": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "field": {
                            "type": "string"
                          },
                          "entity_level": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/meta/lead-forms": {
      "post": {
        "operationId": "postApiV1MetaLeadForms",
        "summary": "Create a Meta Instant Form",
        "tags": [
          "meta"
        ],
        "description": "Creates a lead-generation Instant Form on a connected Facebook Page (`POST /{page_id}/leadgen_forms`) and returns its id, ready to attach to an ad. Meta publishes forms immutable: questions, privacy policy and the quality filters (SMS verification, higher-intent review step) can only be chosen at creation, so an existing form can never be upgraded — a new one is created instead. The Page access token is resolved server-side from the connected Page; the caller never handles Meta tokens.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "page_id",
                  "name",
                  "questions"
                ],
                "properties": {
                  "page_id": {
                    "minLength": 1,
                    "description": "Facebook Page that will own the form.",
                    "type": "string"
                  },
                  "name": {
                    "minLength": 1,
                    "maxLength": 200,
                    "description": "Internal form name, shown in the picker.",
                    "type": "string"
                  },
                  "questions": {
                    "minItems": 1,
                    "maxItems": 30,
                    "description": "Questions in display order. At least one is required by Meta.",
                    "type": "array",
                    "items": {
                      "additionalProperties": false,
                      "type": "object",
                      "required": [
                        "type"
                      ],
                      "properties": {
                        "type": {
                          "anyOf": [
                            {
                              "type": "string",
                              "enum": [
                                "FULL_NAME"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "FIRST_NAME"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "LAST_NAME"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "EMAIL"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "PHONE"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "PHONE_OTP"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "WHATSAPP_NUMBER"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "STREET_ADDRESS"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "CITY"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "STATE"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "PROVINCE"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "COUNTRY"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "POST_CODE"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "ZIP"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "COMPANY_NAME"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "JOB_TITLE"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "WORK_EMAIL"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "WORK_PHONE_NUMBER"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "DOB"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "GENDER"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "MARITAL_STATUS"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "RELATIONSHIP_STATUS"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "MILITARY_STATUS"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "CUSTOM"
                              ]
                            }
                          ]
                        },
                        "key": {
                          "maxLength": 100,
                          "type": "string"
                        },
                        "label": {
                          "maxLength": 300,
                          "type": "string"
                        },
                        "options": {
                          "maxItems": 30,
                          "type": "array",
                          "items": {
                            "additionalProperties": false,
                            "type": "object",
                            "required": [
                              "value"
                            ],
                            "properties": {
                              "value": {
                                "maxLength": 200,
                                "type": "string"
                              },
                              "key": {
                                "maxLength": 100,
                                "type": "string"
                              }
                            }
                          }
                        }
                      }
                    }
                  },
                  "locale": {
                    "maxLength": 10,
                    "description": "Form locale, e.g. \"it_IT\". Defaults to the Page locale.",
                    "type": "string"
                  },
                  "privacy_policy_url": {
                    "format": "uri",
                    "maxLength": 1000,
                    "description": "Required by Meta before a form can serve.",
                    "type": "string"
                  },
                  "privacy_policy_link_text": {
                    "maxLength": 100,
                    "type": "string"
                  },
                  "context_card_title": {
                    "maxLength": 200,
                    "type": "string"
                  },
                  "context_card_content": {
                    "maxItems": 10,
                    "type": "array",
                    "items": {
                      "maxLength": 300,
                      "type": "string"
                    }
                  },
                  "context_card_button_text": {
                    "maxLength": 100,
                    "type": "string"
                  },
                  "thank_you_title": {
                    "maxLength": 200,
                    "type": "string"
                  },
                  "thank_you_body": {
                    "maxLength": 500,
                    "type": "string"
                  },
                  "thank_you_button_text": {
                    "maxLength": 100,
                    "type": "string"
                  },
                  "thank_you_website_url": {
                    "format": "uri",
                    "maxLength": 1000,
                    "type": "string"
                  },
                  "follow_up_action_url": {
                    "format": "uri",
                    "maxLength": 1000,
                    "type": "string"
                  },
                  "phone_sms_verify": {
                    "type": "boolean"
                  },
                  "optimized_for_quality": {
                    "type": "boolean"
                  },
                  "block_display_for_non_targeted_viewer": {
                    "type": "boolean"
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "header",
            "name": "x-team-id",
            "required": false,
            "description": "Explicit team (workspace) scope: a team.id the caller belongs to."
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "header",
            "name": "x-active-scope",
            "required": false,
            "description": "Active scope selector in `<scopeType>:<uuid>` form, e.g. `organization:<organization_id>` or `team:<team_id>`. Omit the header for the all-workspaces view."
          }
        ],
        "responses": {
          "201": {
            "description": "Form created on the Page.",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "description": "Form created on the Page.",
                  "type": "object",
                  "required": [
                    "id",
                    "name",
                    "page_id"
                  ],
                  "properties": {
                    "id": {
                      "description": "Meta leadgen form id, ready to attach to an ad.",
                      "type": "string"
                    },
                    "name": {
                      "type": "string"
                    },
                    "page_id": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid form definition, e.g. SMS verification without a phone question.",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "description": "Invalid form definition, e.g. SMS verification without a phone question.",
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "The Page is not connected to the caller team.",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "description": "The Page is not connected to the caller team.",
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "422": {
            "description": "Meta refused the form: missing permission, invalid privacy policy, and similar.",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "description": "Meta refused the form: missing permission, invalid privacy policy, and similar.",
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Unexpected server error.",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "description": "Unexpected server error.",
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ]
      }
    },
    "/api/v1/meta/users/deactivate": {
      "post": {
        "operationId": "postApiV1MetaUsersDeactivate",
        "summary": "Deactivate Meta user tokens (soft-delete)",
        "tags": [
          "meta"
        ],
        "description": "Marks selected tokens as INACTIVE and disconnects orphaned resources (ad accounts, pages, catalogs, pixels) whose only valid link was through the deactivated tokens. Resources still reachable via another active token in the same session remain connected.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "token_ids"
                ],
                "properties": {
                  "token_ids": {
                    "type": "array",
                    "items": {
                      "format": "uuid",
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "deactivated",
                    "disconnected_ad_accounts",
                    "disconnected_fan_pages",
                    "disconnected_catalogs",
                    "disconnected_pixels",
                    "message"
                  ],
                  "properties": {
                    "deactivated": {
                      "type": "number"
                    },
                    "disconnected_ad_accounts": {
                      "type": "number"
                    },
                    "disconnected_fan_pages": {
                      "type": "number"
                    },
                    "disconnected_catalogs": {
                      "type": "number"
                    },
                    "disconnected_pixels": {
                      "type": "number"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/platforms/users/deactivate": {
      "post": {
        "operationId": "deactivatePlatformUsers",
        "summary": "Deactivate platform tokens (Google/TikTok/Taboola)",
        "tags": [
          "platforms"
        ],
        "description": "Marks the supplied non-Meta platform tokens as INACTIVE and disconnects the matching `platform_connection` rows. IDs are prefixed. `google-<session_id>` / `tiktok-<session_id>` deactivate the whole platform user connection; legacy `google-<account_id>` / `tiktok-<advertiser_id>` resolves the owning token sessions first.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "platform_ids"
                ],
                "properties": {
                  "platform_ids": {
                    "description": "Platform-prefixed ids (e.g. [\"google-<session_id>\", \"tiktok-<session_id>\"] from the Users page, or legacy account ids like [\"google-123\"]).",
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "deactivated",
                    "message"
                  ],
                  "properties": {
                    "deactivated": {
                      "type": "number"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/platforms/users/delete": {
      "post": {
        "operationId": "deletePlatformUsers",
        "summary": "Hard-delete platform accounts (Google/TikTok/Taboola) + their insights",
        "tags": [
          "platforms"
        ],
        "description": "Hard-deletes the supplied non-Meta platform user/account. Users-page ids (`google-<session_id>`, `tiktok-<session_id>`) delete the platform token, all accounts, platform_connection rows and insights for that platform session. Legacy account ids delete only the selected account and preserve the token.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "platform_ids"
                ],
                "properties": {
                  "platform_ids": {
                    "description": "Platform-prefixed ids (e.g. [\"google-<session_id>\"] from Users, or legacy account ids like [\"google-123\", \"tiktok-67890\"]).",
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "deleted_tokens",
                    "deleted_ad_accounts",
                    "deleted_fan_pages",
                    "deleted_catalogs",
                    "deleted_pixels",
                    "deleted_insights",
                    "deleted_campaign_drafts",
                    "updated_automation_rules",
                    "message"
                  ],
                  "properties": {
                    "deleted_tokens": {
                      "type": "number"
                    },
                    "deleted_ad_accounts": {
                      "type": "number"
                    },
                    "deleted_fan_pages": {
                      "type": "number"
                    },
                    "deleted_catalogs": {
                      "type": "number"
                    },
                    "deleted_pixels": {
                      "type": "number"
                    },
                    "deleted_insights": {
                      "type": "number"
                    },
                    "deleted_campaign_drafts": {
                      "type": "number"
                    },
                    "updated_automation_rules": {
                      "type": "number"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/meta/users/system-token": {
      "post": {
        "operationId": "postApiV1MetaUsersSystemToken",
        "summary": "Add system user token",
        "tags": [
          "meta"
        ],
        "description": "Validates a manually provided Meta access token against the Meta API, stores it in the destination workspace team (x-team-id header or active team scope — 400 SCOPE_TEAM_REQUIRED without it), and auto-discovers ad accounts and fan pages from the associated Business Manager. Discovered accounts already assigned to another workspace of the organization answer 409 ACCOUNT_ALREADY_ASSIGNED unless confirm_move=true.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "access_token",
                  "business_id"
                ],
                "properties": {
                  "access_token": {
                    "minLength": 10,
                    "type": "string"
                  },
                  "business_id": {
                    "minLength": 5,
                    "type": "string"
                  },
                  "confirm_move": {
                    "description": "Confirm moving discovered ad accounts already assigned to another workspace of the organization (409 ACCOUNT_ALREADY_ASSIGNED otherwise). The move reassigns every row of each account and re-stamps its historical analytics.",
                    "type": "boolean"
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "header",
            "name": "x-team-id",
            "required": false,
            "description": "Destination workspace team id."
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "message",
                    "user_name"
                  ],
                  "properties": {
                    "message": {
                      "type": "string"
                    },
                    "user_name": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Explicit destination workspace required: send the x-team-id header or activate a team scope for this operation.",
            "content": {
              "application/json": {
                "schema": {
                  "description": "Explicit destination workspace required: send the x-team-id header or activate a team scope for this operation.",
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "SCOPE_TEAM_REQUIRED"
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "409": {
            "description": "The external ad account is already assigned to another workspace of your organization. Retry with confirm_move=true to move it (and its historical analytics) into the active workspace.",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "description": "The external ad account is already assigned to another workspace of your organization. Retry with confirm_move=true to move it (and its historical analytics) into the active workspace.",
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message",
                    "code",
                    "current_team_id",
                    "current_workspace_name",
                    "external_account_id",
                    "platform"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "ACCOUNT_ALREADY_ASSIGNED"
                      ]
                    },
                    "current_team_id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "current_workspace_name": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "external_account_id": {
                      "type": "string"
                    },
                    "platform": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/meta/users/delete": {
      "post": {
        "operationId": "postApiV1MetaUsersDelete",
        "summary": "Delete Meta user tokens permanently (hard-delete)",
        "tags": [
          "meta"
        ],
        "description": "Permanently deletes selected tokens AND every orphan resource exclusively tied to them (ad accounts, pages, catalogs, pixels) plus every downstream row (insights, campaigns, publish jobs, pixel links, automation rules). Resources shared with another ACTIVE token are kept.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "token_ids"
                ],
                "properties": {
                  "token_ids": {
                    "type": "array",
                    "items": {
                      "format": "uuid",
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "deleted_tokens",
                    "deleted_ad_accounts",
                    "deleted_fan_pages",
                    "deleted_catalogs",
                    "deleted_pixels",
                    "deleted_insights",
                    "deleted_campaign_drafts",
                    "updated_automation_rules",
                    "message"
                  ],
                  "properties": {
                    "deleted_tokens": {
                      "type": "number"
                    },
                    "deleted_ad_accounts": {
                      "type": "number"
                    },
                    "deleted_fan_pages": {
                      "type": "number"
                    },
                    "deleted_catalogs": {
                      "type": "number"
                    },
                    "deleted_pixels": {
                      "type": "number"
                    },
                    "deleted_insights": {
                      "type": "number"
                    },
                    "deleted_campaign_drafts": {
                      "type": "number"
                    },
                    "updated_automation_rules": {
                      "type": "number"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/meta/users": {
      "get": {
        "operationId": "getApiV1MetaUsers",
        "summary": "Get connected Meta users (server-side paginated)",
        "tags": [
          "meta"
        ],
        "description": "Returns a server-side paginated, filtered, sorted list of Meta tokens/users. Supports offset pagination, search, and 6 filter dimensions.",
        "parameters": [
          {
            "schema": {
              "minimum": 1,
              "maximum": 100,
              "default": 50,
              "type": "integer"
            },
            "in": "query",
            "name": "limit",
            "required": false
          },
          {
            "schema": {
              "minimum": 0,
              "default": 0,
              "type": "integer"
            },
            "in": "query",
            "name": "offset",
            "required": false
          },
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "query",
            "name": "member_id",
            "required": false
          },
          {
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "enum": [
                    "ACTIVE"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "INACTIVE"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "EXPIRED"
                  ]
                }
              ]
            },
            "in": "query",
            "name": "status",
            "required": false
          },
          {
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "enum": [
                    "name"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "email"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "token_status"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "created_at"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "updated_at"
                  ]
                }
              ]
            },
            "in": "query",
            "name": "sort_by",
            "required": false
          },
          {
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "enum": [
                    "asc"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "desc"
                  ]
                }
              ]
            },
            "in": "query",
            "name": "sort_order",
            "required": false
          },
          {
            "schema": {
              "minLength": 2,
              "maxLength": 200,
              "type": "string"
            },
            "in": "query",
            "name": "search",
            "required": false
          },
          {
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "enum": [
                    "personal"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "system"
                  ]
                }
              ]
            },
            "in": "query",
            "name": "member_type",
            "required": false
          },
          {
            "schema": {
              "maxLength": 50,
              "type": "string"
            },
            "in": "query",
            "name": "role",
            "required": false
          },
          {
            "schema": {
              "maxLength": 100,
              "type": "string"
            },
            "in": "query",
            "name": "business_id",
            "required": false
          },
          {
            "schema": {
              "format": "date-time",
              "type": "string"
            },
            "in": "query",
            "name": "created_from",
            "required": false
          },
          {
            "schema": {
              "format": "date-time",
              "type": "string"
            },
            "in": "query",
            "name": "created_to",
            "required": false
          },
          {
            "schema": {
              "format": "date-time",
              "type": "string"
            },
            "in": "query",
            "name": "updated_from",
            "required": false
          },
          {
            "schema": {
              "format": "date-time",
              "type": "string"
            },
            "in": "query",
            "name": "updated_to",
            "required": false
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "items",
                    "total",
                    "counts"
                  ],
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "id",
                          "user_id",
                          "owner_session_id",
                          "email",
                          "name",
                          "token_status",
                          "business_user_ids",
                          "created_at",
                          "updated_at"
                        ],
                        "properties": {
                          "id": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "user_id": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "owner_session_id": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "email": {
                            "type": "string"
                          },
                          "name": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "token_status": {
                            "type": "string"
                          },
                          "business_user_ids": {
                            "anyOf": [
                              {
                                "description": "JSON object with nested arrays and objects.",
                                "type": "object",
                                "additionalProperties": {
                                  "$comment": "json-value",
                                  "description": "Arbitrary JSON value with nested arrays and objects."
                                }
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "created_at": {
                            "format": "date-time",
                            "type": "string"
                          },
                          "updated_at": {
                            "anyOf": [
                              {
                                "format": "date-time",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "member_name": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "member_email": {
                            "type": "string"
                          },
                          "team_name": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          }
                        }
                      }
                    },
                    "total": {
                      "type": "integer"
                    },
                    "counts": {
                      "type": "object",
                      "required": [
                        "ACTIVE",
                        "INACTIVE",
                        "EXPIRED"
                      ],
                      "properties": {
                        "ACTIVE": {
                          "type": "integer"
                        },
                        "INACTIVE": {
                          "type": "integer"
                        },
                        "EXPIRED": {
                          "type": "integer"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/meta/users/businesses": {
      "get": {
        "operationId": "getApiV1MetaUsersBusinesses",
        "summary": "List businesses available for the current user",
        "tags": [
          "meta"
        ],
        "description": "Returns distinct Meta Business Manager ids and names associated with Meta tokens visible to the caller, respecting admin/team scoping.",
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "items"
                  ],
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "id",
                          "name"
                        ],
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "name": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/metrics/meta": {
      "get": {
        "operationId": "getMetricsMeta",
        "summary": "Get Meta API metrics",
        "tags": [
          "metrics"
        ],
        "description": "Returns Meta API call metrics (sliding window). Requires admin role.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Meta API call metrics snapshot (sliding window counters)",
            "content": {
              "application/json": {
                "schema": {
                  "description": "Meta API call metrics snapshot (sliding window counters)",
                  "type": "object",
                  "required": [
                    "totalCalls",
                    "windowCalls",
                    "errorCounts",
                    "avgResponseTimeMs",
                    "rateLimitHits",
                    "lastRateLimitUsagePct",
                    "windowStartTime",
                    "collectedAt"
                  ],
                  "properties": {
                    "totalCalls": {
                      "description": "Cumulative Meta API calls since process start",
                      "type": "number"
                    },
                    "windowCalls": {
                      "description": "Calls currently held in the sliding window",
                      "type": "number"
                    },
                    "errorCounts": {
                      "description": "Error count grouped by MetaErrorCategory (e.g. rate_limit, auth, transient).",
                      "type": "object",
                      "additionalProperties": {
                        "type": "number"
                      }
                    },
                    "avgResponseTimeMs": {
                      "type": "number"
                    },
                    "rateLimitHits": {
                      "type": "number"
                    },
                    "lastRateLimitUsagePct": {
                      "type": "number"
                    },
                    "windowStartTime": {
                      "format": "date-time",
                      "type": "string"
                    },
                    "collectedAt": {
                      "format": "date-time",
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/metrics/sqs": {
      "get": {
        "operationId": "getMetricsSqs",
        "summary": "Get SQS queue metrics",
        "tags": [
          "metrics"
        ],
        "description": "Returns SQS queue depth metrics for all configured queues (visible, in-flight, delayed). Requires super_admin role.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "queues",
                    "mainQueue",
                    "slowQueue",
                    "timestamp"
                  ],
                  "properties": {
                    "queues": {
                      "type": "object",
                      "additionalProperties": {
                        "type": "object",
                        "required": [
                          "visible",
                          "inFlight",
                          "delayed"
                        ],
                        "properties": {
                          "visible": {
                            "type": "number"
                          },
                          "inFlight": {
                            "type": "number"
                          },
                          "delayed": {
                            "type": "number"
                          }
                        }
                      }
                    },
                    "mainQueue": {
                      "type": "object",
                      "required": [
                        "visible",
                        "inFlight",
                        "delayed"
                      ],
                      "properties": {
                        "visible": {
                          "type": "number"
                        },
                        "inFlight": {
                          "type": "number"
                        },
                        "delayed": {
                          "type": "number"
                        }
                      }
                    },
                    "slowQueue": {
                      "type": "null"
                    },
                    "timestamp": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/metrics/tracker-sync": {
      "get": {
        "operationId": "getMetricsTrackerSync",
        "summary": "Get Tracker sync metrics",
        "tags": [
          "metrics"
        ],
        "description": "Returns tracker-sync health, checkpoint throughput, root-dispatch backlog, queue admission state and upstream guard snapshots. Requires super_admin role.",
        "parameters": [
          {
            "schema": {
              "minimum": 1,
              "maximum": 168,
              "type": "integer"
            },
            "in": "query",
            "name": "windowHours",
            "required": false
          }
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "timestamp",
                    "windowHours",
                    "syncLogs",
                    "progress",
                    "configs",
                    "retention",
                    "rootDispatch",
                    "queue",
                    "upstreamGuards"
                  ],
                  "properties": {
                    "timestamp": {
                      "format": "date-time",
                      "type": "string"
                    },
                    "windowHours": {
                      "minimum": 1,
                      "type": "integer"
                    },
                    "syncLogs": {
                      "type": "object",
                      "required": [
                        "running",
                        "completedLastWindow",
                        "partialLastWindow",
                        "failedLastWindow",
                        "stalledLastWindow"
                      ],
                      "properties": {
                        "running": {
                          "minimum": 0,
                          "type": "integer"
                        },
                        "completedLastWindow": {
                          "minimum": 0,
                          "type": "integer"
                        },
                        "partialLastWindow": {
                          "minimum": 0,
                          "type": "integer"
                        },
                        "failedLastWindow": {
                          "minimum": 0,
                          "type": "integer"
                        },
                        "stalledLastWindow": {
                          "minimum": 0,
                          "type": "integer"
                        }
                      }
                    },
                    "progress": {
                      "type": "object",
                      "required": [
                        "pending",
                        "inProgress",
                        "retrying",
                        "completed",
                        "failed",
                        "leased",
                        "maxAttemptCount",
                        "nextRetryAt"
                      ],
                      "properties": {
                        "pending": {
                          "minimum": 0,
                          "type": "integer"
                        },
                        "inProgress": {
                          "minimum": 0,
                          "type": "integer"
                        },
                        "retrying": {
                          "minimum": 0,
                          "type": "integer"
                        },
                        "completed": {
                          "minimum": 0,
                          "type": "integer"
                        },
                        "failed": {
                          "minimum": 0,
                          "type": "integer"
                        },
                        "leased": {
                          "minimum": 0,
                          "type": "integer"
                        },
                        "maxAttemptCount": {
                          "minimum": 0,
                          "type": "integer"
                        },
                        "nextRetryAt": {
                          "anyOf": [
                            {
                              "format": "date-time",
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        }
                      }
                    },
                    "configs": {
                      "type": "object",
                      "required": [
                        "active",
                        "syncing",
                        "error"
                      ],
                      "properties": {
                        "active": {
                          "minimum": 0,
                          "type": "integer"
                        },
                        "syncing": {
                          "minimum": 0,
                          "type": "integer"
                        },
                        "error": {
                          "minimum": 0,
                          "type": "integer"
                        }
                      }
                    },
                    "retention": {
                      "type": "object",
                      "required": [
                        "enabled",
                        "syncLogRetentionDays",
                        "rollupRetentionDays"
                      ],
                      "properties": {
                        "enabled": {
                          "type": "boolean"
                        },
                        "syncLogRetentionDays": {
                          "anyOf": [
                            {
                              "minimum": 1,
                              "type": "integer"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "rollupRetentionDays": {
                          "anyOf": [
                            {
                              "minimum": 1,
                              "type": "integer"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        }
                      }
                    },
                    "rootDispatch": {
                      "type": "object",
                      "required": [
                        "queued",
                        "deferred",
                        "processing",
                        "enqueueFailed",
                        "overdue",
                        "nextDispatchAt"
                      ],
                      "properties": {
                        "queued": {
                          "minimum": 0,
                          "type": "integer"
                        },
                        "deferred": {
                          "minimum": 0,
                          "type": "integer"
                        },
                        "processing": {
                          "minimum": 0,
                          "type": "integer"
                        },
                        "enqueueFailed": {
                          "minimum": 0,
                          "type": "integer"
                        },
                        "overdue": {
                          "minimum": 0,
                          "type": "integer"
                        },
                        "nextDispatchAt": {
                          "anyOf": [
                            {
                              "format": "date-time",
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        }
                      }
                    },
                    "queue": {
                      "type": "object",
                      "required": [
                        "visible",
                        "inFlight",
                        "delayed",
                        "blocked",
                        "reasons",
                        "limits",
                        "retryDelayMs"
                      ],
                      "properties": {
                        "visible": {
                          "minimum": 0,
                          "type": "number"
                        },
                        "inFlight": {
                          "minimum": 0,
                          "type": "number"
                        },
                        "delayed": {
                          "minimum": 0,
                          "type": "number"
                        },
                        "blocked": {
                          "type": "boolean"
                        },
                        "reasons": {
                          "type": "array",
                          "items": {
                            "type": "string"
                          }
                        },
                        "limits": {
                          "type": "object",
                          "required": [
                            "visible",
                            "inFlight",
                            "delayed"
                          ],
                          "properties": {
                            "visible": {
                              "minimum": 1,
                              "type": "integer"
                            },
                            "inFlight": {
                              "minimum": 1,
                              "type": "integer"
                            },
                            "delayed": {
                              "minimum": 1,
                              "type": "integer"
                            }
                          }
                        },
                        "retryDelayMs": {
                          "minimum": 1,
                          "type": "integer"
                        }
                      }
                    },
                    "upstreamGuards": {
                      "type": "object",
                      "required": [
                        "total",
                        "open",
                        "halfOpen",
                        "coolingDown",
                        "entries"
                      ],
                      "properties": {
                        "total": {
                          "minimum": 0,
                          "type": "integer"
                        },
                        "open": {
                          "minimum": 0,
                          "type": "integer"
                        },
                        "halfOpen": {
                          "minimum": 0,
                          "type": "integer"
                        },
                        "coolingDown": {
                          "minimum": 0,
                          "type": "integer"
                        },
                        "entries": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "required": [
                              "baseUrl",
                              "scopeKey",
                              "trackerType",
                              "state",
                              "consecutiveTransientFailures",
                              "cooldownRemainingMs",
                              "openRemainingMs"
                            ],
                            "properties": {
                              "baseUrl": {
                                "type": "string"
                              },
                              "scopeKey": {
                                "type": "string"
                              },
                              "trackerType": {
                                "type": "string"
                              },
                              "state": {
                                "type": "string"
                              },
                              "consecutiveTransientFailures": {
                                "minimum": 0,
                                "type": "integer"
                              },
                              "cooldownRemainingMs": {
                                "minimum": 0,
                                "type": "integer"
                              },
                              "openRemainingMs": {
                                "minimum": 0,
                                "type": "integer"
                              }
                            }
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/my-workspace": {
      "get": {
        "operationId": "getApiV1MyWorkspace",
        "summary": "Get my workspace override",
        "tags": [
          "workspace"
        ],
        "description": "Get the workspace override for the authenticated user in the current team",
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "anyOf": [
                    {
                      "type": "object",
                      "required": [
                        "base_preset_id",
                        "config",
                        "id",
                        "user_id",
                        "team_id"
                      ],
                      "properties": {
                        "base_preset_id": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "config": {
                          "type": "object",
                          "required": [
                            "hidden_module_ids",
                            "pinned_module_ids",
                            "reordered_module_ids"
                          ],
                          "properties": {
                            "hidden_module_ids": {
                              "type": "array",
                              "items": {
                                "type": "string"
                              }
                            },
                            "pinned_module_ids": {
                              "type": "array",
                              "items": {
                                "type": "string"
                              }
                            },
                            "reordered_hub_ids": {
                              "type": "array",
                              "items": {
                                "type": "string"
                              }
                            },
                            "reordered_module_ids": {
                              "type": "array",
                              "items": {
                                "type": "string"
                              }
                            },
                            "selected_template_id": {
                              "anyOf": [
                                {
                                  "type": "string"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            }
                          }
                        },
                        "id": {
                          "type": "string"
                        },
                        "user_id": {
                          "type": "string"
                        },
                        "team_id": {
                          "type": "string"
                        }
                      }
                    },
                    {
                      "type": "null"
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          }
        }
      },
      "put": {
        "operationId": "putApiV1MyWorkspace",
        "summary": "Save my workspace override",
        "tags": [
          "workspace"
        ],
        "description": "Save workspace override for the authenticated user",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "hidden_module_ids",
                  "pinned_module_ids",
                  "reordered_module_ids"
                ],
                "properties": {
                  "hidden_module_ids": {
                    "maxItems": 100,
                    "type": "array",
                    "items": {
                      "maxLength": 100,
                      "type": "string"
                    }
                  },
                  "pinned_module_ids": {
                    "maxItems": 100,
                    "type": "array",
                    "items": {
                      "maxLength": 100,
                      "type": "string"
                    }
                  },
                  "reordered_hub_ids": {
                    "maxItems": 20,
                    "type": "array",
                    "items": {
                      "maxLength": 100,
                      "type": "string"
                    }
                  },
                  "reordered_module_ids": {
                    "maxItems": 100,
                    "type": "array",
                    "items": {
                      "maxLength": 100,
                      "type": "string"
                    }
                  },
                  "selected_template_id": {
                    "anyOf": [
                      {
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "base_preset_id",
                    "config",
                    "id",
                    "user_id",
                    "team_id"
                  ],
                  "properties": {
                    "base_preset_id": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "config": {
                      "type": "object",
                      "required": [
                        "hidden_module_ids",
                        "pinned_module_ids",
                        "reordered_module_ids"
                      ],
                      "properties": {
                        "hidden_module_ids": {
                          "type": "array",
                          "items": {
                            "type": "string"
                          }
                        },
                        "pinned_module_ids": {
                          "type": "array",
                          "items": {
                            "type": "string"
                          }
                        },
                        "reordered_hub_ids": {
                          "type": "array",
                          "items": {
                            "type": "string"
                          }
                        },
                        "reordered_module_ids": {
                          "type": "array",
                          "items": {
                            "type": "string"
                          }
                        },
                        "selected_template_id": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        }
                      }
                    },
                    "id": {
                      "type": "string"
                    },
                    "user_id": {
                      "type": "string"
                    },
                    "team_id": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/my-workspace/reset": {
      "post": {
        "operationId": "postApiV1MyWorkspaceReset",
        "summary": "Reset my workspace override",
        "tags": [
          "workspace"
        ],
        "description": "Reset workspace override to team default",
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "message",
                    "success"
                  ],
                  "properties": {
                    "message": {
                      "type": "string"
                    },
                    "success": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/naming-convention": {
      "get": {
        "operationId": "listNamingConventions",
        "summary": "List naming conventions configured for the calling team session",
        "tags": [
          "settings"
        ],
        "description": "Returns active and inactive naming convention policies for campaign and ad set names.",
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "conventions"
                  ],
                  "properties": {
                    "conventions": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "level",
                          "pattern",
                          "policy",
                          "is_active"
                        ],
                        "properties": {
                          "level": {
                            "anyOf": [
                              {
                                "type": "string",
                                "enum": [
                                  "campaign"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "adset"
                                ]
                              }
                            ]
                          },
                          "pattern": {
                            "minLength": 1,
                            "maxLength": 200,
                            "type": "string"
                          },
                          "policy": {
                            "anyOf": [
                              {
                                "type": "string",
                                "enum": [
                                  "warn"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "block"
                                ]
                              }
                            ]
                          },
                          "is_active": {
                            "type": "boolean"
                          },
                          "example": {
                            "anyOf": [
                              {
                                "maxLength": 200,
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/naming-convention/{level}": {
      "put": {
        "operationId": "upsertNamingConvention",
        "summary": "Create or update the naming convention for a level",
        "tags": [
          "settings"
        ],
        "description": "Creates or replaces the naming pattern, enforcement policy, active flag, and example for campaign or ad set names.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "pattern",
                  "policy",
                  "is_active"
                ],
                "properties": {
                  "pattern": {
                    "minLength": 1,
                    "maxLength": 200,
                    "type": "string"
                  },
                  "policy": {
                    "anyOf": [
                      {
                        "type": "string",
                        "enum": [
                          "warn"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "block"
                        ]
                      }
                    ]
                  },
                  "is_active": {
                    "type": "boolean"
                  },
                  "example": {
                    "maxLength": 200,
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "enum": [
                    "campaign"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "adset"
                  ]
                }
              ]
            },
            "in": "path",
            "name": "level",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "ok"
                  ],
                  "properties": {
                    "ok": {
                      "type": "boolean",
                      "enum": [
                        true
                      ]
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      },
      "delete": {
        "operationId": "deleteNamingConvention",
        "summary": "Remove the naming convention for a level",
        "tags": [
          "settings"
        ],
        "description": "Deletes the naming convention policy for the requested campaign or ad set level.",
        "parameters": [
          {
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "enum": [
                    "campaign"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "adset"
                  ]
                }
              ]
            },
            "in": "path",
            "name": "level",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "204": {
            "description": "No content"
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/naming-convention/validate": {
      "post": {
        "operationId": "validateNamingConvention",
        "summary": "Validate a campaign/adset name against the team naming convention",
        "tags": [
          "settings"
        ],
        "description": "Checks a proposed campaign or ad set name against the team naming convention and returns warnings or blocking errors.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "name",
                  "level"
                ],
                "properties": {
                  "name": {
                    "minLength": 1,
                    "maxLength": 400,
                    "type": "string"
                  },
                  "level": {
                    "anyOf": [
                      {
                        "type": "string",
                        "enum": [
                          "campaign"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "adset"
                        ]
                      }
                    ]
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "valid"
                  ],
                  "properties": {
                    "valid": {
                      "type": "boolean"
                    },
                    "suggestion": {
                      "type": "string"
                    },
                    "warning": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "anyOf": [
                        {
                          "type": "string",
                          "enum": [
                            "NAMING_PATTERN_MISMATCH"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "NAMING_PATTERN_WARNING"
                          ]
                        }
                      ]
                    },
                    "pattern": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/notifications": {
      "get": {
        "operationId": "getApiV1Notifications",
        "summary": "List notifications",
        "tags": [
          "notifications"
        ],
        "description": "Returns a paginated list of notifications for the authenticated user. Supports filtering by type, severity, and read status.",
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "type",
            "required": false
          },
          {
            "schema": {
              "type": "string"
            },
            "examples": {
              "CRITICAL": {
                "value": "CRITICAL"
              },
              "CRITICAL,ERROR": {
                "value": "CRITICAL,ERROR"
              }
            },
            "in": "query",
            "name": "severity",
            "required": false,
            "description": "One canonical severity (CRITICAL | ERROR | WARNING | INFO | SUCCESS) or a comma-separated list, e.g. \"CRITICAL,ERROR\". Values are normalised to the canonical UPPERCASE form server-side."
          },
          {
            "schema": {
              "type": "boolean"
            },
            "in": "query",
            "name": "is_read",
            "required": false
          },
          {
            "schema": {
              "type": "boolean"
            },
            "in": "query",
            "name": "archived",
            "required": false,
            "description": "true = only archived, false/omitted = exclude archived"
          },
          {
            "schema": {
              "minimum": 1,
              "maximum": 100,
              "default": 20,
              "type": "integer"
            },
            "in": "query",
            "name": "limit",
            "required": false
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "cursor",
            "required": false,
            "description": "Cursor for pagination (created_at ISO string of last item)"
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "items",
                    "next_cursor"
                  ],
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "id",
                          "user_id",
                          "type",
                          "severity",
                          "title",
                          "message",
                          "entity_type",
                          "entity_id",
                          "data",
                          "is_read",
                          "read_at",
                          "archived_at",
                          "actor_id",
                          "created_at"
                        ],
                        "properties": {
                          "id": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "user_id": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "type": {
                            "type": "string"
                          },
                          "severity": {
                            "type": "string"
                          },
                          "title": {
                            "type": "string"
                          },
                          "message": {
                            "type": "string"
                          },
                          "entity_type": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "entity_id": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "data": {
                            "anyOf": [
                              {
                                "$comment": "json-value",
                                "description": "Arbitrary JSON value with nested arrays and objects."
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "is_read": {
                            "type": "boolean"
                          },
                          "read_at": {
                            "anyOf": [
                              {
                                "format": "date-time",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "archived_at": {
                            "anyOf": [
                              {
                                "format": "date-time",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "actor_id": {
                            "anyOf": [
                              {
                                "format": "uuid",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "created_at": {
                            "format": "date-time",
                            "type": "string"
                          }
                        }
                      }
                    },
                    "next_cursor": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/notifications/unread-count": {
      "get": {
        "operationId": "getApiV1NotificationsUnreadCount",
        "summary": "Get unread notification count",
        "tags": [
          "notifications"
        ],
        "description": "Returns the count of unread notifications for the authenticated user. Designed for frequent polling (e.g. every 30s).",
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "count"
                  ],
                  "properties": {
                    "count": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/notifications/{id}/read": {
      "patch": {
        "operationId": "patchApiV1NotificationsByIdRead",
        "summary": "Mark notification as read",
        "tags": [
          "notifications"
        ],
        "description": "Marks a single notification as read for the authenticated user.",
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "id",
                    "user_id",
                    "type",
                    "severity",
                    "title",
                    "message",
                    "entity_type",
                    "entity_id",
                    "data",
                    "is_read",
                    "read_at",
                    "archived_at",
                    "actor_id",
                    "created_at"
                  ],
                  "properties": {
                    "id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "user_id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "type": {
                      "type": "string"
                    },
                    "severity": {
                      "type": "string"
                    },
                    "title": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "entity_type": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "entity_id": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "data": {
                      "anyOf": [
                        {
                          "$comment": "json-value",
                          "description": "Arbitrary JSON value with nested arrays and objects."
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "is_read": {
                      "type": "boolean"
                    },
                    "read_at": {
                      "anyOf": [
                        {
                          "format": "date-time",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "archived_at": {
                      "anyOf": [
                        {
                          "format": "date-time",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "actor_id": {
                      "anyOf": [
                        {
                          "format": "uuid",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "created_at": {
                      "format": "date-time",
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/notifications/read-all": {
      "patch": {
        "operationId": "patchApiV1NotificationsReadAll",
        "summary": "Mark all notifications as read",
        "tags": [
          "notifications"
        ],
        "description": "Marks all unread notifications as read for the authenticated user.",
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "updated"
                  ],
                  "properties": {
                    "updated": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/notifications/{id}": {
      "delete": {
        "operationId": "deleteApiV1NotificationsById",
        "summary": "Delete notification",
        "tags": [
          "notifications"
        ],
        "description": "Deletes a single notification for the authenticated user.",
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "204": {
            "description": "No content"
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/notifications/{id}/archive": {
      "patch": {
        "operationId": "patchApiV1NotificationsByIdArchive",
        "summary": "Archive notification",
        "tags": [
          "notifications"
        ],
        "description": "Archives a single notification for the authenticated user.",
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "id",
                    "user_id",
                    "type",
                    "severity",
                    "title",
                    "message",
                    "entity_type",
                    "entity_id",
                    "data",
                    "is_read",
                    "read_at",
                    "archived_at",
                    "actor_id",
                    "created_at"
                  ],
                  "properties": {
                    "id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "user_id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "type": {
                      "type": "string"
                    },
                    "severity": {
                      "type": "string"
                    },
                    "title": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "entity_type": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "entity_id": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "data": {
                      "anyOf": [
                        {
                          "$comment": "json-value",
                          "description": "Arbitrary JSON value with nested arrays and objects."
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "is_read": {
                      "type": "boolean"
                    },
                    "read_at": {
                      "anyOf": [
                        {
                          "format": "date-time",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "archived_at": {
                      "anyOf": [
                        {
                          "format": "date-time",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "actor_id": {
                      "anyOf": [
                        {
                          "format": "uuid",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "created_at": {
                      "format": "date-time",
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/notifications/{id}/unarchive": {
      "patch": {
        "operationId": "patchApiV1NotificationsByIdUnarchive",
        "summary": "Unarchive notification",
        "tags": [
          "notifications"
        ],
        "description": "Unarchives a single notification for the authenticated user.",
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "id",
                    "user_id",
                    "type",
                    "severity",
                    "title",
                    "message",
                    "entity_type",
                    "entity_id",
                    "data",
                    "is_read",
                    "read_at",
                    "archived_at",
                    "actor_id",
                    "created_at"
                  ],
                  "properties": {
                    "id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "user_id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "type": {
                      "type": "string"
                    },
                    "severity": {
                      "type": "string"
                    },
                    "title": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "entity_type": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "entity_id": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "data": {
                      "anyOf": [
                        {
                          "$comment": "json-value",
                          "description": "Arbitrary JSON value with nested arrays and objects."
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "is_read": {
                      "type": "boolean"
                    },
                    "read_at": {
                      "anyOf": [
                        {
                          "format": "date-time",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "archived_at": {
                      "anyOf": [
                        {
                          "format": "date-time",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "actor_id": {
                      "anyOf": [
                        {
                          "format": "uuid",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "created_at": {
                      "format": "date-time",
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/notifications/archive-all": {
      "patch": {
        "operationId": "patchApiV1NotificationsArchiveAll",
        "summary": "Archive all notifications",
        "tags": [
          "notifications"
        ],
        "description": "Archives all non-archived notifications for the authenticated user.",
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "archived"
                  ],
                  "properties": {
                    "archived": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/notifications/preferences": {
      "get": {
        "operationId": "getApiV1NotificationsPreferences",
        "summary": "Get notification preferences",
        "tags": [
          "notifications"
        ],
        "description": "Returns the full notification preference matrix for the authenticated user, with role-based defaults filled in for uncustomized types.",
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "preferences",
                    "categories"
                  ],
                  "properties": {
                    "preferences": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "notification_type",
                          "in_app",
                          "email",
                          "push",
                          "telegram"
                        ],
                        "properties": {
                          "notification_type": {
                            "type": "string"
                          },
                          "in_app": {
                            "type": "boolean"
                          },
                          "email": {
                            "type": "boolean"
                          },
                          "push": {
                            "type": "boolean"
                          },
                          "telegram": {
                            "type": "boolean"
                          }
                        }
                      }
                    },
                    "categories": {
                      "type": "object",
                      "additionalProperties": {
                        "type": "array",
                        "items": {
                          "type": "string"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      },
      "put": {
        "operationId": "putApiV1NotificationsPreferences",
        "summary": "Update notification preferences",
        "tags": [
          "notifications"
        ],
        "description": "Upserts notification preferences for the authenticated user. Only the types included in the request body are updated; others remain unchanged.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "preferences"
                ],
                "properties": {
                  "preferences": {
                    "minItems": 1,
                    "maxItems": 47,
                    "type": "array",
                    "items": {
                      "additionalProperties": false,
                      "type": "object",
                      "required": [
                        "notification_type",
                        "in_app",
                        "email",
                        "push",
                        "telegram"
                      ],
                      "properties": {
                        "notification_type": {
                          "type": "string"
                        },
                        "in_app": {
                          "type": "boolean"
                        },
                        "email": {
                          "type": "boolean"
                        },
                        "push": {
                          "type": "boolean"
                        },
                        "telegram": {
                          "type": "boolean"
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "preferences",
                    "categories"
                  ],
                  "properties": {
                    "preferences": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "notification_type",
                          "in_app",
                          "email",
                          "push",
                          "telegram"
                        ],
                        "properties": {
                          "notification_type": {
                            "type": "string"
                          },
                          "in_app": {
                            "type": "boolean"
                          },
                          "email": {
                            "type": "boolean"
                          },
                          "push": {
                            "type": "boolean"
                          },
                          "telegram": {
                            "type": "boolean"
                          }
                        }
                      }
                    },
                    "categories": {
                      "type": "object",
                      "additionalProperties": {
                        "type": "array",
                        "items": {
                          "type": "string"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      },
      "delete": {
        "operationId": "deleteApiV1NotificationsPreferences",
        "summary": "Reset notification preferences",
        "tags": [
          "notifications"
        ],
        "description": "Deletes all custom notification preferences for the authenticated user, reverting to role-based defaults.",
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "preferences",
                    "categories"
                  ],
                  "properties": {
                    "preferences": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "notification_type",
                          "in_app",
                          "email",
                          "push",
                          "telegram"
                        ],
                        "properties": {
                          "notification_type": {
                            "type": "string"
                          },
                          "in_app": {
                            "type": "boolean"
                          },
                          "email": {
                            "type": "boolean"
                          },
                          "push": {
                            "type": "boolean"
                          },
                          "telegram": {
                            "type": "boolean"
                          }
                        }
                      }
                    },
                    "categories": {
                      "type": "object",
                      "additionalProperties": {
                        "type": "array",
                        "items": {
                          "type": "string"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/notifications/available-kpi-triggers": {
      "get": {
        "operationId": "getApiV1NotificationsAvailableKpiTriggers",
        "summary": "List available KPI triggers for notifications",
        "tags": [
          "notifications"
        ],
        "description": "Returns action-type KPIs from action_types_canonical that can be used as notification triggers. Includes both v23 and v25 action types.",
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "kpi_triggers"
                  ],
                  "properties": {
                    "kpi_triggers": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "key",
                          "label_en",
                          "label_it",
                          "api_version"
                        ],
                        "properties": {
                          "key": {
                            "type": "string"
                          },
                          "label_en": {
                            "type": "string"
                          },
                          "label_it": {
                            "type": "string"
                          },
                          "api_version": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/onboarding/meta-assets": {
      "get": {
        "operationId": "getApiV1OnboardingMetaAssets",
        "summary": "Get available Meta assets for onboarding wizard",
        "tags": [
          "onboarding"
        ],
        "description": "Returns ad accounts and fan pages available for the current user, grouped by business. Used in the post-OAuth onboarding flow.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "businesses",
                    "ad_accounts",
                    "pages",
                    "meta_user"
                  ],
                  "properties": {
                    "businesses": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "id",
                          "name"
                        ],
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "name": {
                            "type": "string"
                          }
                        }
                      }
                    },
                    "ad_accounts": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "id",
                          "account_id",
                          "name",
                          "currency",
                          "account_status",
                          "business_id",
                          "connected"
                        ],
                        "properties": {
                          "id": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "account_id": {
                            "type": "string"
                          },
                          "name": {
                            "type": "string"
                          },
                          "currency": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "account_status": {
                            "anyOf": [
                              {
                                "type": "integer"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "business_id": {
                            "type": "string"
                          },
                          "connected": {
                            "type": "boolean"
                          }
                        }
                      }
                    },
                    "pages": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "id",
                          "page_id",
                          "name",
                          "business_id",
                          "connected"
                        ],
                        "properties": {
                          "id": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "page_id": {
                            "type": "string"
                          },
                          "name": {
                            "type": "string"
                          },
                          "business_id": {
                            "type": "string"
                          },
                          "connected": {
                            "type": "boolean"
                          }
                        }
                      }
                    },
                    "meta_user": {
                      "anyOf": [
                        {
                          "type": "object",
                          "required": [
                            "name",
                            "email"
                          ],
                          "properties": {
                            "name": {
                              "type": "string"
                            },
                            "email": {
                              "anyOf": [
                                {
                                  "type": "string"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            }
                          }
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/onboarding/complete": {
      "post": {
        "operationId": "postApiV1OnboardingComplete",
        "summary": "Complete Meta onboarding",
        "tags": [
          "onboarding"
        ],
        "description": "Assigns selected ad accounts and fan pages, updates onboarding state, and triggers data sync.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "account_ids",
                  "page_ids"
                ],
                "properties": {
                  "account_ids": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  },
                  "page_ids": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "assigned_accounts",
                    "assigned_pages",
                    "sync_started"
                  ],
                  "properties": {
                    "assigned_accounts": {
                      "type": "integer"
                    },
                    "assigned_pages": {
                      "type": "integer"
                    },
                    "sync_started": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/onboarding/progress": {
      "patch": {
        "operationId": "patchApiV1OnboardingProgress",
        "summary": "Save onboarding progress",
        "tags": [
          "onboarding"
        ],
        "description": "Persists the current onboarding step and selections for resume after page refresh.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "step"
                ],
                "properties": {
                  "step": {
                    "minimum": 1,
                    "maximum": 4,
                    "type": "integer"
                  },
                  "selected_accounts": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  },
                  "selected_pages": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "ok"
                  ],
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/onboarding/setup-checklist/dismiss": {
      "post": {
        "operationId": "postApiV1OnboardingSetupChecklistDismiss",
        "summary": "Dismiss the dashboard setup checklist",
        "tags": [
          "onboarding"
        ],
        "description": "Marks the setup checklist/homepage onboarding section as dismissed for the current user.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "onboarding_state"
                  ],
                  "properties": {
                    "onboarding_state": {
                      "description": "JSON object with nested arrays and objects.",
                      "type": "object",
                      "additionalProperties": {
                        "$comment": "json-value",
                        "description": "Arbitrary JSON value with nested arrays and objects."
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/onboarding/wizard/skip": {
      "post": {
        "operationId": "postApiV1OnboardingWizardSkip",
        "summary": "Skip onboarding wizard",
        "tags": [
          "onboarding"
        ],
        "description": "Marks only the onboarding wizard as skipped for the current user.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "onboarding_state"
                  ],
                  "properties": {
                    "onboarding_state": {
                      "description": "JSON object with nested arrays and objects.",
                      "type": "object",
                      "additionalProperties": {
                        "$comment": "json-value",
                        "description": "Arbitrary JSON value with nested arrays and objects."
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/onboarding/skip-all": {
      "post": {
        "operationId": "postApiV1OnboardingSkipAll",
        "summary": "Skip onboarding wizard and dismiss setup checklist",
        "tags": [
          "onboarding"
        ],
        "description": "Marks the onboarding wizard as skipped and dismisses the setup checklist so the current user can access the dashboard without onboarding redirects.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "onboarding_state"
                  ],
                  "properties": {
                    "onboarding_state": {
                      "description": "JSON object with nested arrays and objects.",
                      "type": "object",
                      "additionalProperties": {
                        "$comment": "json-value",
                        "description": "Arbitrary JSON value with nested arrays and objects."
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/onboarding/enterprise/complete": {
      "post": {
        "operationId": "postApiV1OnboardingEnterpriseComplete",
        "summary": "Mark enterprise onboarding as completed",
        "tags": [
          "onboarding"
        ],
        "description": "Persists onboarding_state.enterprise_onboarding_completed = true for the current user so the enterprise-onboarding protected-route gate is satisfied across devices.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "onboarding_state"
                  ],
                  "properties": {
                    "onboarding_state": {
                      "description": "JSON object with nested arrays and objects.",
                      "type": "object",
                      "additionalProperties": {
                        "$comment": "json-value",
                        "description": "Arbitrary JSON value with nested arrays and objects."
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/onboarding/wizard-complete": {
      "post": {
        "operationId": "postApiV1OnboardingWizardComplete",
        "summary": "Mark the onboarding wizard as completed (PRD-37)",
        "tags": [
          "onboarding"
        ],
        "description": "Idempotently records onboarding completion time and optional wizard duration for the current user session.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "properties": {
                  "duration_sec": {
                    "minimum": 0,
                    "maximum": 604800,
                    "type": "integer"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "already_completed",
                    "completed_at"
                  ],
                  "properties": {
                    "already_completed": {
                      "type": "boolean"
                    },
                    "completed_at": {
                      "format": "date-time",
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/onboarding/profile": {
      "put": {
        "operationId": "putApiV1OnboardingProfile",
        "summary": "Persist the onboarding wizard profile snapshot (PRD-N1)",
        "tags": [
          "onboarding"
        ],
        "description": "Stores the selected segment, workspace profile, primary platforms, goals, and ad-spend band on the current user session.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "properties": {
                  "segment": {
                    "anyOf": [
                      {
                        "type": "string",
                        "enum": [
                          "agency"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "dtc"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "media_buyer"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "dropshipper"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "generic"
                        ]
                      }
                    ]
                  },
                  "workspace_profile": {
                    "maxLength": 40,
                    "type": "string"
                  },
                  "primary_platforms": {
                    "maxItems": 12,
                    "type": "array",
                    "items": {
                      "maxLength": 40,
                      "type": "string"
                    }
                  },
                  "primary_goals": {
                    "maxItems": 12,
                    "type": "array",
                    "items": {
                      "maxLength": 40,
                      "type": "string"
                    }
                  },
                  "monthly_ad_spend_band": {
                    "maxLength": 40,
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "ok"
                  ],
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/onboarding/launch-progress": {
      "get": {
        "operationId": "getApiV1OnboardingLaunchProgress",
        "summary": "Get \"Launch your first campaign\" onboarding progress",
        "tags": [
          "onboarding"
        ],
        "description": "Returns the per-step completion state for the guided launch onboarding, derived from real backend state (Meta connection, synced/associated assets, validated pixel, Creative Hub asset, first successful publish).",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "steps",
                    "completed",
                    "current_step",
                    "completion_percent"
                  ],
                  "properties": {
                    "steps": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "key",
                          "done"
                        ],
                        "properties": {
                          "key": {
                            "anyOf": [
                              {
                                "type": "string",
                                "enum": [
                                  "connect_meta"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "sync_accounts"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "associate_account"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "associate_page"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "associate_pixel"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "upload_creative"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "launch_campaign"
                                ]
                              }
                            ]
                          },
                          "done": {
                            "type": "boolean"
                          }
                        }
                      }
                    },
                    "completed": {
                      "type": "boolean"
                    },
                    "current_step": {
                      "anyOf": [
                        {
                          "anyOf": [
                            {
                              "type": "string",
                              "enum": [
                                "connect_meta"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "sync_accounts"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "associate_account"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "associate_page"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "associate_pixel"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "upload_creative"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "launch_campaign"
                              ]
                            }
                          ]
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "completion_percent": {
                      "minimum": 0,
                      "maximum": 100,
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/partner/program-status": {
      "get": {
        "operationId": "getPartnerProgramStatus",
        "summary": "La coda candidature è aperta?",
        "tags": [
          "partner"
        ],
        "description": "Dice se la coda candidature è aperta. Rotta PUBBLICA e senza sessione: la serve la pagina `/partners/apply`, che deve poter mostrare uno stato onesto («il programma non è ancora aperto») invece di un form che promette una risposta in 2 giorni lavorativi mentre la porta è chiusa. Non è un oracolo: espone lo stato del PROGRAMMA (il commutatore `partner_track_b_enroll`), che è identico per chiunque chieda e non nomina alcuna persona, alcuna email e alcuna pratica. La lettura è in-memory (cache dei flag), quindi un toggle dal backoffice atterra entro una finestra di refresh.",
        "responses": {
          "200": {
            "description": "Stato della porta pubblica del Programma Partner. Esiste perché la pagina `/partners/apply` non ha una sessione da cui leggere i flag: senza questa rotta il frontend potrebbe solo indovinare, e indovinerebbe «aperto» — cioè mostrerebbe un form con uno SLA di 2 giorni davanti a una coda chiusa.",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "description": "Stato della porta pubblica del Programma Partner. Esiste perché la pagina `/partners/apply` non ha una sessione da cui leggere i flag: senza questa rotta il frontend potrebbe solo indovinare, e indovinerebbe «aperto» — cioè mostrerebbe un form con uno SLA di 2 giorni davanti a una coda chiusa.",
                  "type": "object",
                  "required": [
                    "applications_open"
                  ],
                  "properties": {
                    "applications_open": {
                      "description": "La coda candidature è aperta? È il commutatore `partner_track_b_enroll`, uguale per chiunque chieda: non dipende da chi guarda e non nomina nessuno.",
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "Errore della candidatura pubblica. Non conferma mai l’esistenza di un’email o di una pratica.",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "description": "Errore della candidatura pubblica. Non conferma mai l’esistenza di un’email o di una pratica.",
                  "type": "object",
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ],
                  "properties": {
                    "error": {
                      "description": "Etichetta dell’errore.",
                      "type": "string"
                    },
                    "message": {
                      "description": "Messaggio leggibile. Non nomina mai un’email né una pratica.",
                      "type": "string"
                    },
                    "statusCode": {
                      "description": "Stato HTTP.",
                      "type": "integer"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/partner/applications": {
      "post": {
        "operationId": "createPartnerApplication",
        "summary": "Candidatura al Programma Partner",
        "tags": [
          "partner"
        ],
        "description": "Registra una candidatura al Programma Partner. ⚠️ Risponde 403 finché il commutatore `partner_track_b_enroll` è spento: la coda candidature è chiusa e NESSUNA pratica viene creata — il corpo del 403 è una costante che non dipende dai dati inviati. Rotta PUBBLICA e senza account: non crea alcuna user_session, alcuna organizzazione e alcuna email di verifica — l’account nasce solo all’approvazione. ★ Risponde SEMPRE 202 con lo stesso corpo, anche se l’email è già candidata o appartiene a un partner già approvato: nessun endpoint di questo programma conferma mai l’esistenza di un’email. Il link con cui seguire la pratica arriva per email, non nella risposta. Due limiti, due comportamenti diversi: 5/h per IP risponde 429; 3/h per identità email è applicato in silenzio, perché un 429 sull’email sarebbe esso stesso l’oracolo che questa rotta evita. ⚠️ `collection_mode: \"cash\"` esige `vat_number`: senza, la risposta è 400 e nessuna pratica viene creata. È lo stesso vincolo che l’approvazione applicherebbe (`vat_required`) e che il CHECK `ck_partner_cash_needs_vat` imporrebbe sull’anagrafica — anticiparlo qui evita una pratica che nasce già inapprovabile e un rifiuto che il candidato scopre mesi dopo. Il controllo dipende solo dal corpo inviato: non legge il database e non è un oracolo su alcuna identità.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "branch_answers",
                  "collection_mode",
                  "country_code",
                  "email",
                  "full_name",
                  "how_you_bring",
                  "lane",
                  "tos_accepted",
                  "tos_version",
                  "vat_status",
                  "advertising_disclosure_commitment"
                ],
                "properties": {
                  "audience_sector": {
                    "description": "Pubblico o settore.",
                    "maxLength": 120,
                    "minLength": 2,
                    "type": "string"
                  },
                  "branch_answers": {
                    "description": "Ramo della corsia dichiarata. `kind` deve coincidere con `lane`: se non coincide la richiesta è 400, perché inviare i dati di una corsia diversa da quella scelta è un errore del client, non una scelta.",
                    "anyOf": [
                      {
                        "additionalProperties": false,
                        "type": "object",
                        "required": [
                          "audience_it_eu_pct",
                          "contents_last_90d",
                          "kind",
                          "platforms"
                        ],
                        "properties": {
                          "audience_it_eu_pct": {
                            "description": "Percentuale di audience IT/UE.",
                            "maximum": 100,
                            "minimum": 0,
                            "type": "integer"
                          },
                          "contents_last_90d": {
                            "description": "Contenuti su tool/ads negli ultimi 90 giorni.",
                            "minimum": 0,
                            "type": "integer"
                          },
                          "kind": {
                            "type": "string",
                            "enum": [
                              "C1_creator"
                            ]
                          },
                          "platforms": {
                            "description": "Piattaforme su cui pubblichi. Nessuna soglia di follower: non è un criterio.",
                            "maxItems": 5,
                            "minItems": 1,
                            "type": "array",
                            "items": {
                              "maxLength": 40,
                              "minLength": 2,
                              "type": "string"
                            }
                          }
                        }
                      },
                      {
                        "additionalProperties": false,
                        "type": "object",
                        "required": [
                          "active_30d",
                          "kind",
                          "members",
                          "paid_community",
                          "platform",
                          "posts_per_week"
                        ],
                        "properties": {
                          "active_30d": {
                            "description": "Membri attivi negli ultimi 30 giorni.",
                            "minimum": 0,
                            "type": "integer"
                          },
                          "kind": {
                            "type": "string",
                            "enum": [
                              "C2_community"
                            ]
                          },
                          "members": {
                            "description": "Membri totali.",
                            "minimum": 0,
                            "type": "integer"
                          },
                          "paid_community": {
                            "description": "Community a pagamento.",
                            "type": "boolean"
                          },
                          "platform": {
                            "description": "Piattaforma della community.",
                            "maxLength": 40,
                            "minLength": 2,
                            "type": "string"
                          },
                          "posts_per_week": {
                            "description": "Post a settimana.",
                            "minimum": 0,
                            "type": "integer"
                          }
                        }
                      },
                      {
                        "additionalProperties": false,
                        "type": "object",
                        "required": [
                          "kind",
                          "license_available",
                          "portfolio_urls"
                        ],
                        "properties": {
                          "kind": {
                            "type": "string",
                            "enum": [
                              "C3_ugc"
                            ]
                          },
                          "license_available": {
                            "description": "Disponibilità a firmare la licenza d’uso.",
                            "type": "boolean"
                          },
                          "portfolio_urls": {
                            "description": "URL degli asset di portfolio.",
                            "maxItems": 10,
                            "minItems": 1,
                            "type": "array",
                            "items": {
                              "format": "uri",
                              "maxLength": 500,
                              "type": "string"
                            }
                          }
                        }
                      },
                      {
                        "additionalProperties": false,
                        "type": "object",
                        "required": [
                          "archive_url",
                          "kind",
                          "open_rate_pct",
                          "sends_last_90d",
                          "subscribers"
                        ],
                        "properties": {
                          "archive_url": {
                            "description": "Archivio pubblico della newsletter.",
                            "format": "uri",
                            "maxLength": 500,
                            "type": "string"
                          },
                          "kind": {
                            "type": "string",
                            "enum": [
                              "C4_newsletter"
                            ]
                          },
                          "open_rate_pct": {
                            "description": "Open rate dichiarato.",
                            "maximum": 100,
                            "minimum": 0,
                            "type": "integer"
                          },
                          "sends_last_90d": {
                            "description": "Invii negli ultimi 90 giorni.",
                            "minimum": 0,
                            "type": "integer"
                          },
                          "subscribers": {
                            "description": "Iscritti.",
                            "minimum": 0,
                            "type": "integer"
                          }
                        }
                      },
                      {
                        "additionalProperties": false,
                        "type": "object",
                        "required": [
                          "kind",
                          "ongoing_professional_relationship",
                          "profession"
                        ],
                        "properties": {
                          "kind": {
                            "type": "string",
                            "enum": [
                              "C5_referrer"
                            ]
                          },
                          "ongoing_professional_relationship": {
                            "description": "Rapporto professionale in corso con chi segnalerai: se vero, scatta l’obbligo di disclosure.",
                            "type": "boolean"
                          },
                          "profession": {
                            "description": "Professione.",
                            "maxLength": 120,
                            "minLength": 2,
                            "type": "string"
                          }
                        }
                      },
                      {
                        "additionalProperties": false,
                        "type": "object",
                        "required": [
                          "agency_name",
                          "clients_count",
                          "kind",
                          "services"
                        ],
                        "properties": {
                          "agency_name": {
                            "description": "Nome dell’agenzia.",
                            "maxLength": 200,
                            "minLength": 2,
                            "type": "string"
                          },
                          "clients_count": {
                            "description": "Clienti gestiti.",
                            "minimum": 0,
                            "type": "integer"
                          },
                          "kind": {
                            "type": "string",
                            "enum": [
                              "C6_agency"
                            ]
                          },
                          "services": {
                            "description": "Servizi offerti.",
                            "maxItems": 10,
                            "minItems": 1,
                            "type": "array",
                            "items": {
                              "maxLength": 60,
                              "minLength": 2,
                              "type": "string"
                            }
                          }
                        }
                      }
                    ]
                  },
                  "collection_mode": {
                    "description": "Modalità di riscossione richiesta (§6.6). Resta una richiesta: decide l’approvatore.",
                    "anyOf": [
                      {
                        "type": "string",
                        "enum": [
                          "cash"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "accrual"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "community_benefit"
                        ]
                      }
                    ]
                  },
                  "country_code": {
                    "description": "Paese ISO-3166-1 alpha-2.",
                    "maxLength": 2,
                    "minLength": 2,
                    "type": "string"
                  },
                  "email": {
                    "description": "Email di contatto.",
                    "format": "email",
                    "maxLength": 320,
                    "type": "string"
                  },
                  "full_name": {
                    "description": "Nome e cognome.",
                    "maxLength": 120,
                    "minLength": 2,
                    "type": "string"
                  },
                  "how_you_bring": {
                    "description": "Come porterai clienti. È il campo che l’approvatore legge per primo (§2.4).",
                    "maxLength": 300,
                    "minLength": 30,
                    "type": "string"
                  },
                  "lane": {
                    "description": "Corsia di ingresso dichiarata. Obbligatoria dal giorno 1 (§2.3).",
                    "anyOf": [
                      {
                        "type": "string",
                        "enum": [
                          "C1_creator"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "C2_community"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "C3_ugc"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "C4_newsletter"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "C5_referrer"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "C6_agency"
                        ]
                      }
                    ]
                  },
                  "primary_url": {
                    "description": "URL principale (sito, canale, portfolio).",
                    "format": "uri",
                    "maxLength": 500,
                    "type": "string"
                  },
                  "tos_accepted": {
                    "description": "Accettazione esplicita dei T&C versionati.",
                    "type": "boolean",
                    "enum": [
                      true
                    ]
                  },
                  "tos_version": {
                    "description": "Versione dei T&C accettata.",
                    "maxLength": 20,
                    "minLength": 1,
                    "type": "string"
                  },
                  "utm": {
                    "additionalProperties": false,
                    "description": "Provenienza della candidatura.",
                    "type": "object",
                    "properties": {
                      "campaign": {
                        "maxLength": 120,
                        "type": "string"
                      },
                      "content": {
                        "maxLength": 120,
                        "type": "string"
                      },
                      "medium": {
                        "maxLength": 120,
                        "type": "string"
                      },
                      "source": {
                        "maxLength": 120,
                        "type": "string"
                      },
                      "term": {
                        "maxLength": 120,
                        "type": "string"
                      }
                    }
                  },
                  "vat_number": {
                    "description": "P.IVA / VAT, se dichiarata.",
                    "maxLength": 32,
                    "minLength": 4,
                    "type": "string"
                  },
                  "vat_status": {
                    "description": "Stato della partita IVA.",
                    "anyOf": [
                      {
                        "type": "string",
                        "enum": [
                          "yes"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "no"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "opening"
                        ]
                      }
                    ]
                  },
                  "advertising_disclosure_commitment": {
                    "description": "Impegno a dichiarare la natura pubblicitaria dei contenuti.",
                    "type": "boolean",
                    "enum": [
                      true
                    ]
                  }
                }
              }
            }
          }
        },
        "security": [],
        "responses": {
          "202": {
            "description": "Ricevuta della candidatura. ★ IDENTICA per email nuova, email già candidata ed email di un partner già approvato: la differenza non è osservabile dal chiamante. Il link della pratica arriva per email.",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "description": "Ricevuta della candidatura. ★ IDENTICA per email nuova, email già candidata ed email di un partner già approvato: la differenza non è osservabile dal chiamante. Il link della pratica arriva per email.",
                  "type": "object",
                  "required": [
                    "queue_paused",
                    "status"
                  ],
                  "properties": {
                    "queue_paused": {
                      "description": "La coda ha superato la soglia di §7.2 M4 e il reclutamento è sospeso. Il lead è comunque registrato: non si perde mai un contatto. Non dipende dall’email inviata, quindi non è un oracolo.",
                      "type": "boolean"
                    },
                    "status": {
                      "description": "Sempre `received`. Non riflette lo stato reale della pratica.",
                      "type": "string",
                      "enum": [
                        "received"
                      ]
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Errore della candidatura pubblica. Non conferma mai l’esistenza di un’email o di una pratica.",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "description": "Errore della candidatura pubblica. Non conferma mai l’esistenza di un’email o di una pratica.",
                  "type": "object",
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ],
                  "properties": {
                    "error": {
                      "description": "Etichetta dell’errore.",
                      "type": "string"
                    },
                    "message": {
                      "description": "Messaggio leggibile. Non nomina mai un’email né una pratica.",
                      "type": "string"
                    },
                    "statusCode": {
                      "description": "Stato HTTP.",
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Errore della candidatura pubblica. Non conferma mai l’esistenza di un’email o di una pratica.",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "description": "Errore della candidatura pubblica. Non conferma mai l’esistenza di un’email o di una pratica.",
                  "type": "object",
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ],
                  "properties": {
                    "error": {
                      "description": "Etichetta dell’errore.",
                      "type": "string"
                    },
                    "message": {
                      "description": "Messaggio leggibile. Non nomina mai un’email né una pratica.",
                      "type": "string"
                    },
                    "statusCode": {
                      "description": "Stato HTTP.",
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "Errore della candidatura pubblica. Non conferma mai l’esistenza di un’email o di una pratica.",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "description": "Errore della candidatura pubblica. Non conferma mai l’esistenza di un’email o di una pratica.",
                  "type": "object",
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ],
                  "properties": {
                    "error": {
                      "description": "Etichetta dell’errore.",
                      "type": "string"
                    },
                    "message": {
                      "description": "Messaggio leggibile. Non nomina mai un’email né una pratica.",
                      "type": "string"
                    },
                    "statusCode": {
                      "description": "Stato HTTP.",
                      "type": "integer"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/partner/applications/{token}": {
      "get": {
        "operationId": "getPartnerApplicationByToken",
        "summary": "Stato della propria candidatura",
        "tags": [
          "partner"
        ],
        "description": "Stato della propria candidatura a partire dal token opaco consegnato per email. Il token è un ULID a 26 caratteri e non contiene l’id della pratica: non esiste un identificatore sequenziale da incrementare. ⚠️ La risposta non porta mai il motivo dettagliato di un rifiuto né le note interne (§6.11): il candidato vede lo stato, non il giudizio.",
        "parameters": [
          {
            "schema": {
              "maxLength": 26,
              "minLength": 26,
              "pattern": "^[0-9A-HJKMNP-TV-Z]{26}$",
              "type": "string"
            },
            "in": "path",
            "name": "token",
            "required": true,
            "description": "Token opaco della pratica (ULID a 26 caratteri). Non contiene l’id e non è enumerabile."
          }
        ],
        "responses": {
          "200": {
            "description": "Stato della propria pratica. ⚠️ Nessun motivo di rifiuto dettagliato e nessuna nota interna: §6.11 vieta la motivazione dettagliata di scarto. Il candidato vede lo stato, non il giudizio.",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "description": "Stato della propria pratica. ⚠️ Nessun motivo di rifiuto dettagliato e nessuna nota interna: §6.11 vieta la motivazione dettagliata di scarto. Il candidato vede lo stato, non il giudizio.",
                  "type": "object",
                  "required": [
                    "info_question",
                    "lane",
                    "sla_due_at",
                    "status",
                    "submitted_at"
                  ],
                  "properties": {
                    "info_question": {
                      "description": "La domanda posta dall’approvatore, quando lo stato è `info_requested`.",
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "lane": {
                      "description": "Corsia dichiarata.",
                      "type": "string"
                    },
                    "sla_due_at": {
                      "description": "Entro quando rispondiamo. **`null` sugli stati chiusi** (approvata, rifiutata, ritirata, scaduta): su una pratica già decisa nessuna risposta è più dovuta, e prometterne una sarebbe falso (D21).",
                      "anyOf": [
                        {
                          "format": "date-time",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "status": {
                      "description": "Stato della pratica.",
                      "type": "string"
                    },
                    "submitted_at": {
                      "description": "Quando è stata inviata.",
                      "format": "date-time",
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Errore della candidatura pubblica. Non conferma mai l’esistenza di un’email o di una pratica.",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "description": "Errore della candidatura pubblica. Non conferma mai l’esistenza di un’email o di una pratica.",
                  "type": "object",
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ],
                  "properties": {
                    "error": {
                      "description": "Etichetta dell’errore.",
                      "type": "string"
                    },
                    "message": {
                      "description": "Messaggio leggibile. Non nomina mai un’email né una pratica.",
                      "type": "string"
                    },
                    "statusCode": {
                      "description": "Stato HTTP.",
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Errore della candidatura pubblica. Non conferma mai l’esistenza di un’email o di una pratica.",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "description": "Errore della candidatura pubblica. Non conferma mai l’esistenza di un’email o di una pratica.",
                  "type": "object",
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ],
                  "properties": {
                    "error": {
                      "description": "Etichetta dell’errore.",
                      "type": "string"
                    },
                    "message": {
                      "description": "Messaggio leggibile. Non nomina mai un’email né una pratica.",
                      "type": "string"
                    },
                    "statusCode": {
                      "description": "Stato HTTP.",
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "Errore della candidatura pubblica. Non conferma mai l’esistenza di un’email o di una pratica.",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "description": "Errore della candidatura pubblica. Non conferma mai l’esistenza di un’email o di una pratica.",
                  "type": "object",
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ],
                  "properties": {
                    "error": {
                      "description": "Etichetta dell’errore.",
                      "type": "string"
                    },
                    "message": {
                      "description": "Messaggio leggibile. Non nomina mai un’email né una pratica.",
                      "type": "string"
                    },
                    "statusCode": {
                      "description": "Stato HTTP.",
                      "type": "integer"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/partner/applications/{token}/info": {
      "post": {
        "operationId": "answerPartnerApplicationInfoRequest",
        "summary": "Risposta alla richiesta di informazioni",
        "tags": [
          "partner"
        ],
        "description": "Risponde alla richiesta di informazioni dell’approvatore. Vale UNA SOLA VOLTA per richiesta: la pratica torna in stato `received` e una seconda risposta non ha effetto — questa non è una chat, è un fascicolo. Un token valido su una pratica che non è in `info_requested` risponde 404 come uno sconosciuto: distinguere i due casi direbbe in che stato è una pratica a chi ha solo il link.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "answer"
                ],
                "properties": {
                  "answer": {
                    "description": "Risposta alla richiesta di informazioni.",
                    "maxLength": 2000,
                    "minLength": 1,
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "schema": {
              "maxLength": 26,
              "minLength": 26,
              "pattern": "^[0-9A-HJKMNP-TV-Z]{26}$",
              "type": "string"
            },
            "in": "path",
            "name": "token",
            "required": true,
            "description": "Token opaco della pratica (ULID a 26 caratteri). Non contiene l’id e non è enumerabile."
          }
        ],
        "responses": {
          "200": {
            "description": "Risposta registrata: la pratica torna nello stato `received`.",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "description": "Risposta registrata: la pratica torna nello stato `received`.",
                  "type": "object",
                  "required": [
                    "status"
                  ],
                  "properties": {
                    "status": {
                      "description": "La pratica torna in coda.",
                      "type": "string",
                      "enum": [
                        "received"
                      ]
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Errore della candidatura pubblica. Non conferma mai l’esistenza di un’email o di una pratica.",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "description": "Errore della candidatura pubblica. Non conferma mai l’esistenza di un’email o di una pratica.",
                  "type": "object",
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ],
                  "properties": {
                    "error": {
                      "description": "Etichetta dell’errore.",
                      "type": "string"
                    },
                    "message": {
                      "description": "Messaggio leggibile. Non nomina mai un’email né una pratica.",
                      "type": "string"
                    },
                    "statusCode": {
                      "description": "Stato HTTP.",
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Errore della candidatura pubblica. Non conferma mai l’esistenza di un’email o di una pratica.",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "description": "Errore della candidatura pubblica. Non conferma mai l’esistenza di un’email o di una pratica.",
                  "type": "object",
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ],
                  "properties": {
                    "error": {
                      "description": "Etichetta dell’errore.",
                      "type": "string"
                    },
                    "message": {
                      "description": "Messaggio leggibile. Non nomina mai un’email né una pratica.",
                      "type": "string"
                    },
                    "statusCode": {
                      "description": "Stato HTTP.",
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "Errore della candidatura pubblica. Non conferma mai l’esistenza di un’email o di una pratica.",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "description": "Errore della candidatura pubblica. Non conferma mai l’esistenza di un’email o di una pratica.",
                  "type": "object",
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ],
                  "properties": {
                    "error": {
                      "description": "Etichetta dell’errore.",
                      "type": "string"
                    },
                    "message": {
                      "description": "Messaggio leggibile. Non nomina mai un’email né una pratica.",
                      "type": "string"
                    },
                    "statusCode": {
                      "description": "Stato HTTP.",
                      "type": "integer"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/partner/attribution/redeem-code": {
      "post": {
        "operationId": "partnerRedeemAttributionCode",
        "summary": "Riscatta un codice invito entro la finestra di grazia",
        "tags": [
          "partner"
        ],
        "description": "Applica un codice partner (o lo slug vanity del suo link) a un account registrato da meno di 7 giorni, SOLO se la cascata L1-L3 non ha già prodotto un vincitore. Un’attribuzione esistente non viene mai sovrascritta. La risposta normale è 200: `applied` dice se il codice ha attribuito e `reason` perché no. `already_attributed` e `grace_expired` sono restituiti PRIMA di qualunque lookup del codice, così la rotta non può essere usata per scoprire quali codici esistono. Il 409 è l’unico esito che non è di dominio: il database ha rifiutato la scrittura per un conflitto che lo stato non spiega (collisione tecnica), nulla è stato scritto e la richiesta si può ritentare.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "description": "Codice o slug da riscattare entro la finestra di grazia.",
                "type": "object",
                "required": [
                  "code"
                ],
                "properties": {
                  "code": {
                    "description": "Codice invito del partner (base32 Crockford maiuscolo, 8-20 caratteri) OPPURE lo slug vanity del suo link (3-30 caratteri, minuscolo, trattini solo interni: `marco-ads`). Sono le due cose che una persona può avere in mano senza aver cliccato: il codice dettato a voce e l’indirizzo stampato su un volantino.",
                    "maxLength": 30,
                    "minLength": 3,
                    "pattern": "^[A-Za-z0-9][A-Za-z0-9-]{1,28}[A-Za-z0-9]$",
                    "type": "string"
                  }
                }
              }
            }
          },
          "description": "Codice o slug da riscattare entro la finestra di grazia."
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Esito della riscossione in grazia.",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "description": "Esito della riscossione in grazia.",
                  "type": "object",
                  "required": [
                    "applied"
                  ],
                  "properties": {
                    "applied": {
                      "description": "true solo se il codice ha prodotto un’attribuzione nuova per questo account.",
                      "type": "boolean"
                    },
                    "reason": {
                      "description": "Perché il codice non è stato applicato. Presente solo quando `applied` è false. `already_attributed` e `grace_expired` sono decisi prima di qualunque lookup del codice: la rotta non rivela mai se un codice esiste.",
                      "anyOf": [
                        {
                          "type": "string",
                          "enum": [
                            "already_attributed"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "code_not_found"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "engine_off"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "excluded"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "grace_expired"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "program_unavailable"
                          ]
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Errore standard del backend.",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "description": "Errore standard del backend.",
                  "type": "object",
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ],
                  "properties": {
                    "code": {
                      "description": "Codice macchina dell’errore, quando disponibile.",
                      "type": "string"
                    },
                    "error": {
                      "description": "Etichetta breve dell’errore.",
                      "type": "string"
                    },
                    "message": {
                      "description": "Messaggio leggibile.",
                      "type": "string"
                    },
                    "request_id": {
                      "description": "Id della richiesta, per il supporto.",
                      "type": "string"
                    },
                    "statusCode": {
                      "description": "Codice di stato HTTP ripetuto nel corpo.",
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Errore standard del backend.",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "description": "Errore standard del backend.",
                  "type": "object",
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ],
                  "properties": {
                    "code": {
                      "description": "Codice macchina dell’errore, quando disponibile.",
                      "type": "string"
                    },
                    "error": {
                      "description": "Etichetta breve dell’errore.",
                      "type": "string"
                    },
                    "message": {
                      "description": "Messaggio leggibile.",
                      "type": "string"
                    },
                    "request_id": {
                      "description": "Id della richiesta, per il supporto.",
                      "type": "string"
                    },
                    "statusCode": {
                      "description": "Codice di stato HTTP ripetuto nel corpo.",
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "Errore standard del backend.",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "description": "Errore standard del backend.",
                  "type": "object",
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ],
                  "properties": {
                    "code": {
                      "description": "Codice macchina dell’errore, quando disponibile.",
                      "type": "string"
                    },
                    "error": {
                      "description": "Etichetta breve dell’errore.",
                      "type": "string"
                    },
                    "message": {
                      "description": "Messaggio leggibile.",
                      "type": "string"
                    },
                    "request_id": {
                      "description": "Id della richiesta, per il supporto.",
                      "type": "string"
                    },
                    "statusCode": {
                      "description": "Codice di stato HTTP ripetuto nel corpo.",
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "Errore standard del backend.",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "description": "Errore standard del backend.",
                  "type": "object",
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ],
                  "properties": {
                    "code": {
                      "description": "Codice macchina dell’errore, quando disponibile.",
                      "type": "string"
                    },
                    "error": {
                      "description": "Etichetta breve dell’errore.",
                      "type": "string"
                    },
                    "message": {
                      "description": "Messaggio leggibile.",
                      "type": "string"
                    },
                    "request_id": {
                      "description": "Id della richiesta, per il supporto.",
                      "type": "string"
                    },
                    "statusCode": {
                      "description": "Codice di stato HTTP ripetuto nel corpo.",
                      "type": "integer"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/partner/attribution/forget": {
      "post": {
        "operationId": "partnerForgetAttribution",
        "summary": "Cancella i riferimenti di attribuzione del richiedente",
        "tags": [
          "partner"
        ],
        "description": "CANCELLA: le righe di `partner_identity_map` del richiedente — il solo collegamento diretto fra un referral e la persona (contact_class incluso) — ed emette il `Set-Cookie` che spegne `wv_at` e alza la valvola di opposizione `wv_nc=1`, così nessun click futuro verrà più attribuito. RESTA, e va detto per intero: `partner_referral` (pseudonimo `public_ref`, ma con `referred_organization_id` valorizzato quando l’organizzazione esisteva già — chi ha accesso a quella tabella può quindi ancora risalire all’Organizzazione, non alla persona); `partner_attribution_decision` e i suoi candidati, immutabili per trigger e con `subject_user_id` che resta finché l’account esiste (diventa NULL solo alla cancellazione dell’utente, ON DELETE SET NULL); il ledger commissioni e le commissioni già maturate, append-only. Nessuna di queste righe viene toccata: sono prova contabile e fiscale. Idempotente: una seconda chiamata risponde 200 con `removed: 0`.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Esito della cancellazione dei riferimenti di attribuzione.",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "description": "Esito della cancellazione dei riferimenti di attribuzione.",
                  "type": "object",
                  "required": [
                    "removed"
                  ],
                  "properties": {
                    "removed": {
                      "description": "Righe di `partner_identity_map` cancellate: 1 se il richiedente era un referito tracciato, 0 se non c’era nulla da cancellare (esito valido, la chiamata è idempotente).",
                      "minimum": 0,
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Errore standard del backend.",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "description": "Errore standard del backend.",
                  "type": "object",
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ],
                  "properties": {
                    "code": {
                      "description": "Codice macchina dell’errore, quando disponibile.",
                      "type": "string"
                    },
                    "error": {
                      "description": "Etichetta breve dell’errore.",
                      "type": "string"
                    },
                    "message": {
                      "description": "Messaggio leggibile.",
                      "type": "string"
                    },
                    "request_id": {
                      "description": "Id della richiesta, per il supporto.",
                      "type": "string"
                    },
                    "statusCode": {
                      "description": "Codice di stato HTTP ripetuto nel corpo.",
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "Errore standard del backend.",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "description": "Errore standard del backend.",
                  "type": "object",
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ],
                  "properties": {
                    "code": {
                      "description": "Codice macchina dell’errore, quando disponibile.",
                      "type": "string"
                    },
                    "error": {
                      "description": "Etichetta breve dell’errore.",
                      "type": "string"
                    },
                    "message": {
                      "description": "Messaggio leggibile.",
                      "type": "string"
                    },
                    "request_id": {
                      "description": "Id della richiesta, per il supporto.",
                      "type": "string"
                    },
                    "statusCode": {
                      "description": "Codice di stato HTTP ripetuto nel corpo.",
                      "type": "integer"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/referral/bridge-offer": {
      "get": {
        "operationId": "getPartnerBridgeOffer",
        "summary": "L’offerta di passaggio al Binario B che mi aspetta",
        "tags": [
          "partner"
        ],
        "description": "L’offerta di passaggio al Programma Partner che aspetta chi chiama, se ce n’è una ancora da accettare. `204` quando non c’è nulla da accettare — indistintamente perché non esiste alcuna offerta o perché è già stata accettata: distinguere i due casi renderebbe questa rotta un oracolo sull’esistenza di un’offerta. La risposta porta il documento e la versione da accettare, mai il token della pratica.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "L’offerta di passaggio al Binario B che aspetta chi chiama. ⚠️ Non porta il token della pratica: quello è la chiave di lettura del fascicolo e non ha ragione di uscire da qui.",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "description": "L’offerta di passaggio al Binario B che aspetta chi chiama. ⚠️ Non porta il token della pratica: quello è la chiave di lettura del fascicolo e non ha ragione di uscire da qui.",
                  "type": "object",
                  "required": [
                    "offered_at",
                    "reason",
                    "tc_document_id",
                    "tc_version"
                  ],
                  "properties": {
                    "offered_at": {
                      "description": "Quando l’offerta è nata. È l’unica data che esiste finché non la si accetta.",
                      "format": "date-time",
                      "type": "string"
                    },
                    "reason": {
                      "description": "Perché è nata: `cap_reached` (tetto del Binario A) o `third_matured_conversion`.",
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "tc_document_id": {
                      "description": "Il documento da accettare. Oggi sempre `partnerTerms`.",
                      "type": "string"
                    },
                    "tc_version": {
                      "description": "La versione proposta: è quella che va rimandata all’accettazione.",
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "204": {
            "description": "Nessuna offerta da accettare."
          },
          "401": {
            "description": "Errore standard del backend.",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "description": "Errore standard del backend.",
                  "type": "object",
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ],
                  "properties": {
                    "code": {
                      "description": "Codice macchina dell’errore, quando disponibile.",
                      "type": "string"
                    },
                    "error": {
                      "description": "Etichetta breve dell’errore.",
                      "type": "string"
                    },
                    "message": {
                      "description": "Messaggio leggibile.",
                      "type": "string"
                    },
                    "statusCode": {
                      "description": "Codice di stato HTTP ripetuto nel corpo.",
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "Errore standard del backend.",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "description": "Errore standard del backend.",
                  "type": "object",
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ],
                  "properties": {
                    "code": {
                      "description": "Codice macchina dell’errore, quando disponibile.",
                      "type": "string"
                    },
                    "error": {
                      "description": "Etichetta breve dell’errore.",
                      "type": "string"
                    },
                    "message": {
                      "description": "Messaggio leggibile.",
                      "type": "string"
                    },
                    "statusCode": {
                      "description": "Codice di stato HTTP ripetuto nel corpo.",
                      "type": "integer"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/referral/bridge-offer/accept": {
      "post": {
        "operationId": "acceptPartnerBridgeOffer",
        "summary": "Accetto i termini e passo al Binario B",
        "tags": [
          "partner"
        ],
        "description": "Accetta i termini dell’offerta di passaggio al Binario B. ★ È l’ATTO che il ponte non aveva: registra `tc_accepted_at`, l’IP, lo user-agent, l’impronta del testo e la versione — gli stessi cinque campi che la candidatura pubblica raccoglie, perché una prova di consenso non può avere due forme a seconda di dove entra — e porta la pratica in `received`, cioè nella coda normale. Finché questo atto non avviene l’approvazione risponde `409 tc_not_accepted` e il vincolo `ck_papp_approved_needs_consent` rifiuta comunque la transizione: nessuno può essere approvato senza aver accettato. `404` quando non c’è nulla da accettare (nessuna offerta, o già accettata: i due casi rispondono identico). `409 stale_version` quando la versione inviata non è quella corrente. `403` quando il programma è chiuso: accettare a porta chiusa scriverebbe un consenso write-once su un percorso che non può proseguire.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "tos_version"
                ],
                "properties": {
                  "tos_version": {
                    "description": "La versione dei T&C partner che si sta accettando. Deve essere quella CORRENTE: accettare una versione vecchia scriverebbe una prova di consenso su un testo diverso da quello mostrato.",
                    "maxLength": 20,
                    "minLength": 1,
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "status"
                  ],
                  "properties": {
                    "status": {
                      "description": "La pratica è entrata nella coda normale: da qui in poi è una candidatura come le altre.",
                      "type": "string",
                      "enum": [
                        "received"
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Errore standard del backend.",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "description": "Errore standard del backend.",
                  "type": "object",
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ],
                  "properties": {
                    "code": {
                      "description": "Codice macchina dell’errore, quando disponibile.",
                      "type": "string"
                    },
                    "error": {
                      "description": "Etichetta breve dell’errore.",
                      "type": "string"
                    },
                    "message": {
                      "description": "Messaggio leggibile.",
                      "type": "string"
                    },
                    "statusCode": {
                      "description": "Codice di stato HTTP ripetuto nel corpo.",
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Errore standard del backend.",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "description": "Errore standard del backend.",
                  "type": "object",
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ],
                  "properties": {
                    "code": {
                      "description": "Codice macchina dell’errore, quando disponibile.",
                      "type": "string"
                    },
                    "error": {
                      "description": "Etichetta breve dell’errore.",
                      "type": "string"
                    },
                    "message": {
                      "description": "Messaggio leggibile.",
                      "type": "string"
                    },
                    "statusCode": {
                      "description": "Codice di stato HTTP ripetuto nel corpo.",
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Errore standard del backend.",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "description": "Errore standard del backend.",
                  "type": "object",
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ],
                  "properties": {
                    "code": {
                      "description": "Codice macchina dell’errore, quando disponibile.",
                      "type": "string"
                    },
                    "error": {
                      "description": "Etichetta breve dell’errore.",
                      "type": "string"
                    },
                    "message": {
                      "description": "Messaggio leggibile.",
                      "type": "string"
                    },
                    "statusCode": {
                      "description": "Codice di stato HTTP ripetuto nel corpo.",
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "Errore standard del backend.",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "description": "Errore standard del backend.",
                  "type": "object",
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ],
                  "properties": {
                    "code": {
                      "description": "Codice macchina dell’errore, quando disponibile.",
                      "type": "string"
                    },
                    "error": {
                      "description": "Etichetta breve dell’errore.",
                      "type": "string"
                    },
                    "message": {
                      "description": "Messaggio leggibile.",
                      "type": "string"
                    },
                    "statusCode": {
                      "description": "Codice di stato HTTP ripetuto nel corpo.",
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "Errore standard del backend.",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "description": "Errore standard del backend.",
                  "type": "object",
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ],
                  "properties": {
                    "code": {
                      "description": "Codice macchina dell’errore, quando disponibile.",
                      "type": "string"
                    },
                    "error": {
                      "description": "Etichetta breve dell’errore.",
                      "type": "string"
                    },
                    "message": {
                      "description": "Messaggio leggibile.",
                      "type": "string"
                    },
                    "statusCode": {
                      "description": "Codice di stato HTTP ripetuto nel corpo.",
                      "type": "integer"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/partner/ledger": {
      "get": {
        "operationId": "listPartnerLedger",
        "summary": "Ledger commissioni del partner",
        "tags": [
          "partner"
        ],
        "description": "Ledger del partner, dalla scrittura più recente. Append-only: gli storni sono righe con importo negativo, mai modifiche. Il saldo NON si ricava sommando questa pagina — arriva da `/partner/me`, calcolato come SUM di tutte le scritture.",
        "parameters": [
          {
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "enum": [
                    "acquisition"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "commission"
                  ]
                }
              ]
            },
            "in": "query",
            "name": "book",
            "required": false,
            "description": "Libro contabile."
          },
          {
            "schema": {
              "maximum": 200,
              "minimum": 1,
              "type": "integer"
            },
            "in": "query",
            "name": "limit",
            "required": false,
            "description": "Righe per pagina, massimo 200."
          },
          {
            "schema": {
              "minimum": 0,
              "type": "integer"
            },
            "in": "query",
            "name": "offset",
            "required": false,
            "description": "Righe da saltare."
          }
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Pagina del ledger. Solo righe REALI: le scritture shadow sono escluse per costruzione — in shadow mode nascono tutte così, e mostrarle significherebbe esporre un saldo che nessuno pagherà mai.",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "description": "Pagina del ledger. Solo righe REALI: le scritture shadow sono escluse per costruzione — in shadow mode nascono tutte così, e mostrarle significherebbe esporre un saldo che nessuno pagherà mai.",
                  "type": "object",
                  "required": [
                    "has_more",
                    "limit",
                    "rows",
                    "total"
                  ],
                  "properties": {
                    "has_more": {
                      "description": "Esiste almeno un’altra pagina.",
                      "type": "boolean"
                    },
                    "limit": {
                      "description": "Righe per pagina effettivamente applicate.",
                      "minimum": 1,
                      "type": "integer"
                    },
                    "rows": {
                      "description": "Righe della pagina, dalla più recente.",
                      "type": "array",
                      "items": {
                        "additionalProperties": false,
                        "description": "Una scrittura del ledger, come la legge il partner.",
                        "type": "object",
                        "required": [
                          "amount_minor",
                          "book",
                          "capped_by_monthly_cap",
                          "commissionable_base_minor",
                          "correction_batch_id",
                          "currency",
                          "description",
                          "dispute",
                          "entry_id",
                          "gross_invoice_minor",
                          "hold_reason",
                          "occurred_on",
                          "rate_bp",
                          "reject_reason",
                          "status",
                          "unlock_on"
                        ],
                        "properties": {
                          "amount_minor": {
                            "description": "Importo della scrittura. NEGATIVO sugli storni: mai una modifica, sempre una riga. Minor units (centesimi) come stringa decimale.",
                            "pattern": "^-?[0-9]+$",
                            "type": "string"
                          },
                          "book": {
                            "description": "commission | acquisition. Immutabile dopo l’inserimento (criterio 14).",
                            "type": "string"
                          },
                          "capped_by_monthly_cap": {
                            "description": "Il cap mensile ha morso. `null` sulle righe senza commissione collegata.",
                            "anyOf": [
                              {
                                "type": "boolean"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "commissionable_base_minor": {
                            "description": "`null` sulle righe senza commissione collegata.",
                            "anyOf": [
                              {
                                "description": "Base imponibile già cappata. Minor units (centesimi) come stringa decimale.",
                                "pattern": "^-?[0-9]+$",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "correction_batch_id": {
                            "description": "Lega uno storno alla sua riga di sostituzione.",
                            "anyOf": [
                              {
                                "format": "uuid",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "currency": {
                            "description": "Valuta della scrittura.",
                            "type": "string"
                          },
                          "description": {
                            "description": "Tipo di movimento: accrued, reversed, payout, correction…",
                            "type": "string"
                          },
                          "dispute": {
                            "description": "La contestazione VIVA (`open` o `in_review`) su questo denaro, comunque sia stata aperta: sulla riga di ledger o sulla commissione collegata. `null` quando non ce n’è nessuna. Serve al pannello per mostrare la pratica sulla riga e per spegnere «Contesta»: senza, il partner non vede nulla dopo l’invio, riprova, e ottiene un 409 che l’interfaccia poteva evitare.",
                            "anyOf": [
                              {
                                "additionalProperties": false,
                                "type": "object",
                                "required": [
                                  "due_on",
                                  "id",
                                  "opened_on",
                                  "reason_code",
                                  "resolution_code",
                                  "resolved_on",
                                  "status"
                                ],
                                "properties": {
                                  "due_on": {
                                    "description": "Entro quando rispondiamo (SLA congelato all’apertura).",
                                    "format": "date",
                                    "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}$",
                                    "type": "string"
                                  },
                                  "id": {
                                    "description": "Numero di pratica.",
                                    "format": "uuid",
                                    "type": "string"
                                  },
                                  "opened_on": {
                                    "description": "Giorno di apertura.",
                                    "format": "date",
                                    "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}$",
                                    "type": "string"
                                  },
                                  "reason_code": {
                                    "description": "Motivo indicato all’apertura. È un CODICE, non una frase, e l’insieme è **chiuso**: uno dei sette, oppure `unknown`. La chiusura non è cosmetica — `partner_dispute.reason_code` è una `VARCHAR(40)` senza `CHECK`, e i casi aperti dal backoffice ci scrivono un codice deciso da un operatore: senza normalizzazione questa rotta spedirebbe una stringa arbitraria scritta da noi verso l’esterno.",
                                    "anyOf": [
                                      {
                                        "type": "string",
                                        "enum": [
                                          "amount_wrong"
                                        ]
                                      },
                                      {
                                        "type": "string",
                                        "enum": [
                                          "rate_wrong"
                                        ]
                                      },
                                      {
                                        "type": "string",
                                        "enum": [
                                          "missing_commission"
                                        ]
                                      },
                                      {
                                        "type": "string",
                                        "enum": [
                                          "reversal_wrong"
                                        ]
                                      },
                                      {
                                        "type": "string",
                                        "enum": [
                                          "cap_applied"
                                        ]
                                      },
                                      {
                                        "type": "string",
                                        "enum": [
                                          "window_wrong"
                                        ]
                                      },
                                      {
                                        "type": "string",
                                        "enum": [
                                          "other"
                                        ]
                                      },
                                      {
                                        "type": "string",
                                        "enum": [
                                          "unknown"
                                        ]
                                      }
                                    ]
                                  },
                                  "resolution_code": {
                                    "description": "Esito, quando la pratica è chiusa; `null` finché è viva. È un CODICE e l’insieme è **chiuso**: `partner_dispute.resolution_code` è una `VARCHAR(40)` senza `CHECK` e chi chiude un caso dal backoffice ci scrive un codice deciso da un operatore.",
                                    "anyOf": [
                                      {
                                        "type": "string",
                                        "enum": [
                                          "our_error"
                                        ]
                                      },
                                      {
                                        "type": "string",
                                        "enum": [
                                          "evidence_accepted"
                                        ]
                                      },
                                      {
                                        "type": "string",
                                        "enum": [
                                          "goodwill"
                                        ]
                                      },
                                      {
                                        "type": "string",
                                        "enum": [
                                          "data_confirmed"
                                        ]
                                      },
                                      {
                                        "type": "string",
                                        "enum": [
                                          "out_of_scope"
                                        ]
                                      },
                                      {
                                        "type": "string",
                                        "enum": [
                                          "no_response"
                                        ]
                                      },
                                      {
                                        "type": "string",
                                        "enum": [
                                          "withdrawn_by_partner"
                                        ]
                                      },
                                      {
                                        "type": "string",
                                        "enum": [
                                          "unknown"
                                        ]
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "resolved_on": {
                                    "description": "Giorno in cui la pratica è stata chiusa; `null` finché è viva.",
                                    "anyOf": [
                                      {
                                        "description": "Giorno della risposta.",
                                        "format": "date",
                                        "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}$",
                                        "type": "string"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "status": {
                                    "description": "`open` · `in_review` · `upheld` · `rejected`. ★ Gli stati TERMINALI arrivano eccome, da oggi: prima la pratica spariva dalla riga nel momento in cui riceveva una risposta, e il partner — a cui avevamo promesso «Ti rispondiamo entro il …» — non vedeva né esito né motivo.",
                                    "type": "string"
                                  }
                                }
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "entry_id": {
                            "description": "Id della scrittura.",
                            "format": "uuid",
                            "type": "string"
                          },
                          "gross_invoice_minor": {
                            "description": "`null` sulle righe senza commissione collegata.",
                            "anyOf": [
                              {
                                "description": "Imponibile della fattura prima del cap. Minor units (centesimi) come stringa decimale.",
                                "pattern": "^-?[0-9]+$",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "hold_reason": {
                            "description": "Motivo per cui la riga è FERMA (`PAYOUT_HOLD_REASONS`: manual_review, kyc_level, vies_invalid…), non scartata. Distinto da `reject_reason`: un hold è reversibile e ha `unlock_on`, uno scarto è terminale. `null` sulle righe che non sono in hold. È un CODICE, cioè una chiave i18n stabile: la frase la sceglie il pannello nella lingua del partner.",
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "occurred_on": {
                            "description": "Giorno del movimento.",
                            "format": "date",
                            "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}$",
                            "type": "string"
                          },
                          "rate_bp": {
                            "description": "Aliquota CONGELATA sulla riga, in basis point. `null` fuori dalle maturazioni.",
                            "anyOf": [
                              {
                                "type": "integer"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "reject_reason": {
                            "description": "Motivo SPECIFICO dello scarto (rimborso, chargeback, auto_referral): sulla riga del denaro il partner ha diritto di capire perché un suo euro non c’è. È l’opposto della riga persona.",
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "status": {
                            "description": "Stato della commissione collegata, oppure `settled`.",
                            "type": "string"
                          },
                          "unlock_on": {
                            "description": "`null` se non in hold.",
                            "anyOf": [
                              {
                                "description": "Data di sblocco prevista.",
                                "format": "date",
                                "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}$",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          }
                        }
                      }
                    },
                    "total": {
                      "description": "Righe totali del libro richiesto.",
                      "minimum": 0,
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Errore standard del backend.",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "description": "Errore standard del backend.",
                  "type": "object",
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ],
                  "properties": {
                    "code": {
                      "description": "Codice macchina dell’errore, quando disponibile.",
                      "type": "string"
                    },
                    "error": {
                      "description": "Etichetta breve dell’errore.",
                      "type": "string"
                    },
                    "message": {
                      "description": "Messaggio leggibile.",
                      "type": "string"
                    },
                    "statusCode": {
                      "description": "Codice di stato HTTP ripetuto nel corpo.",
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Errore standard del backend.",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "description": "Errore standard del backend.",
                  "type": "object",
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ],
                  "properties": {
                    "code": {
                      "description": "Codice macchina dell’errore, quando disponibile.",
                      "type": "string"
                    },
                    "error": {
                      "description": "Etichetta breve dell’errore.",
                      "type": "string"
                    },
                    "message": {
                      "description": "Messaggio leggibile.",
                      "type": "string"
                    },
                    "statusCode": {
                      "description": "Codice di stato HTTP ripetuto nel corpo.",
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Errore standard del backend.",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "description": "Errore standard del backend.",
                  "type": "object",
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ],
                  "properties": {
                    "code": {
                      "description": "Codice macchina dell’errore, quando disponibile.",
                      "type": "string"
                    },
                    "error": {
                      "description": "Etichetta breve dell’errore.",
                      "type": "string"
                    },
                    "message": {
                      "description": "Messaggio leggibile.",
                      "type": "string"
                    },
                    "statusCode": {
                      "description": "Codice di stato HTTP ripetuto nel corpo.",
                      "type": "integer"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/partner/ledger/{entry_id}/dispute": {
      "post": {
        "operationId": "createPartnerLedgerDispute",
        "summary": "Contesta una scrittura di ledger",
        "tags": [
          "partner"
        ],
        "description": "Apre una contestazione su una scrittura di ledger. La riga contestata NON viene modificata: il ledger è append-only e una contestazione è un fatto SU una riga, mai una modifica DELLA riga — se contestare cambiasse il dato, la contestazione distruggerebbe la prova su cui si fonda. Risponde 202 con l’id del caso e la scadenza di risposta (10 giorni lavorativi). La finestra di ammissibilità è 30 giorni dalla scrittura e viene congelata sulla riga all’apertura. Una scrittura di un altro partner risponde 403, mai 404: un 404 sarebbe un oracolo sull’esistenza di una riga altrui.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "note",
                  "reason_code"
                ],
                "properties": {
                  "note": {
                    "description": "Descrizione della contestazione.",
                    "maxLength": 1000,
                    "minLength": 1,
                    "type": "string"
                  },
                  "reason_code": {
                    "description": "Motivo scelto dal partner.",
                    "maxLength": 40,
                    "minLength": 1,
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "entry_id",
            "required": true,
            "description": "Id della scrittura contestata."
          }
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "202": {
            "description": "Accepted - processing asynchronously",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "deadline_at",
                    "dispute_id",
                    "due_at",
                    "status"
                  ],
                  "properties": {
                    "deadline_at": {
                      "description": "Termine di ammissibilità CONGELATO all’apertura. Cambiare la policy domani non riapre questo caso.",
                      "anyOf": [
                        {
                          "format": "date-time",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "dispute_id": {
                      "description": "Id della contestazione aperta.",
                      "format": "uuid",
                      "type": "string"
                    },
                    "due_at": {
                      "description": "SLA di risposta: 10 giorni LAVORATIVI dall’apertura (PARTNER_SLA.disputeResponseBusinessDays).",
                      "format": "date-time",
                      "type": "string"
                    },
                    "status": {
                      "description": "Sempre `open` alla creazione.",
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Errore standard del backend.",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "description": "Errore standard del backend.",
                  "type": "object",
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ],
                  "properties": {
                    "code": {
                      "description": "Codice macchina dell’errore, quando disponibile.",
                      "type": "string"
                    },
                    "error": {
                      "description": "Etichetta breve dell’errore.",
                      "type": "string"
                    },
                    "message": {
                      "description": "Messaggio leggibile.",
                      "type": "string"
                    },
                    "statusCode": {
                      "description": "Codice di stato HTTP ripetuto nel corpo.",
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Errore standard del backend.",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "description": "Errore standard del backend.",
                  "type": "object",
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ],
                  "properties": {
                    "code": {
                      "description": "Codice macchina dell’errore, quando disponibile.",
                      "type": "string"
                    },
                    "error": {
                      "description": "Etichetta breve dell’errore.",
                      "type": "string"
                    },
                    "message": {
                      "description": "Messaggio leggibile.",
                      "type": "string"
                    },
                    "statusCode": {
                      "description": "Codice di stato HTTP ripetuto nel corpo.",
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Errore standard del backend.",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "description": "Errore standard del backend.",
                  "type": "object",
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ],
                  "properties": {
                    "code": {
                      "description": "Codice macchina dell’errore, quando disponibile.",
                      "type": "string"
                    },
                    "error": {
                      "description": "Etichetta breve dell’errore.",
                      "type": "string"
                    },
                    "message": {
                      "description": "Messaggio leggibile.",
                      "type": "string"
                    },
                    "statusCode": {
                      "description": "Codice di stato HTTP ripetuto nel corpo.",
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "Errore standard del backend.",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "description": "Errore standard del backend.",
                  "type": "object",
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ],
                  "properties": {
                    "code": {
                      "description": "Codice macchina dell’errore, quando disponibile.",
                      "type": "string"
                    },
                    "error": {
                      "description": "Etichetta breve dell’errore.",
                      "type": "string"
                    },
                    "message": {
                      "description": "Messaggio leggibile.",
                      "type": "string"
                    },
                    "statusCode": {
                      "description": "Codice di stato HTTP ripetuto nel corpo.",
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "Errore standard del backend.",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "description": "Errore standard del backend.",
                  "type": "object",
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ],
                  "properties": {
                    "code": {
                      "description": "Codice macchina dell’errore, quando disponibile.",
                      "type": "string"
                    },
                    "error": {
                      "description": "Etichetta breve dell’errore.",
                      "type": "string"
                    },
                    "message": {
                      "description": "Messaggio leggibile.",
                      "type": "string"
                    },
                    "statusCode": {
                      "description": "Codice di stato HTTP ripetuto nel corpo.",
                      "type": "integer"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/partner/payouts": {
      "get": {
        "operationId": "listPartnerPayouts",
        "summary": "Storico dei payout",
        "tags": [
          "partner"
        ],
        "description": "Storico dei payout del partner, dal più recente.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Storico dei pagamenti.",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "description": "Storico dei pagamenti.",
                  "type": "object",
                  "required": [
                    "rows"
                  ],
                  "properties": {
                    "rows": {
                      "description": "Storico dei payout del partner.",
                      "type": "array",
                      "items": {
                        "additionalProperties": false,
                        "type": "object",
                        "required": [
                          "allocated_minor",
                          "amount_minor",
                          "batch_period",
                          "currency",
                          "hold_reason",
                          "hold_until",
                          "id",
                          "net_minor",
                          "paid_on",
                          "statement_csv_url",
                          "statement_pdf_url",
                          "status",
                          "withholding_minor"
                        ],
                        "properties": {
                          "allocated_minor": {
                            "description": "Il denaro che la riga rappresenta, pagato o TRATTENUTO che sia. Su una riga ferma è l’unico campo in cui esiste: `gross = allocated − offset` e il run non alloca il lordo di ciò che non paga, quindi `amount_minor` vale 0 e mostrarlo da solo fa leggere «pagamento da zero euro» a chi ne ha 527,50 fermi. Minor units (centesimi) come stringa decimale.",
                            "pattern": "^-?[0-9]+$",
                            "type": "string"
                          },
                          "amount_minor": {
                            "description": "Lordo del payout. Zero sulle righe ferme: l’importo vero è `allocated_minor`. Minor units (centesimi) come stringa decimale.",
                            "pattern": "^-?[0-9]+$",
                            "type": "string"
                          },
                          "batch_period": {
                            "description": "Mese di competenza del run.",
                            "format": "date",
                            "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}$",
                            "type": "string"
                          },
                          "currency": {
                            "description": "Valuta del payout.",
                            "type": "string"
                          },
                          "hold_reason": {
                            "description": "Perché la riga è FERMA (`PAYOUT_HOLD_REASONS`: kyc_level, collection_mode_accrual, program_frozen…). `null` sulle righe non ferme. È un CODICE, cioè una chiave i18n stabile: la frase la sceglie il pannello nella lingua del partner. Il database lo impone su ogni riga `held` (vincolo `ck`), quindi una riga ferma senza motivo non esiste.",
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "hold_until": {
                            "description": "`hold_sla_due_at`: la scadenza che ci siamo dati NOI, non una promessa di pagamento. `null` sulle righe non ferme. È ciò che distingue «fermo» da «fermo per sempre».",
                            "anyOf": [
                              {
                                "description": "Termine entro cui la riga ferma va lavorata.",
                                "format": "date",
                                "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}$",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "id": {
                            "description": "Id della riga di payout.",
                            "format": "uuid",
                            "type": "string"
                          },
                          "net_minor": {
                            "description": "Netto bonificato. Minor units (centesimi) come stringa decimale.",
                            "pattern": "^-?[0-9]+$",
                            "type": "string"
                          },
                          "paid_on": {
                            "description": "`null` finché non pagato.",
                            "anyOf": [
                              {
                                "description": "Giorno del bonifico.",
                                "format": "date",
                                "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}$",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "statement_csv_url": {
                            "description": "Estratto conto CSV. `null` in MVP: il documento è prodotto e firmato dal run di payout (WF8). Un URL inventato qui sarebbe un link rotto dentro un’email di pagamento.",
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "statement_pdf_url": {
                            "description": "Come sopra, in PDF.",
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "status": {
                            "description": "Stato della riga di payout.",
                            "type": "string"
                          },
                          "withholding_minor": {
                            "description": "Ritenuta applicata. Minor units (centesimi) come stringa decimale.",
                            "pattern": "^-?[0-9]+$",
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Errore standard del backend.",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "description": "Errore standard del backend.",
                  "type": "object",
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ],
                  "properties": {
                    "code": {
                      "description": "Codice macchina dell’errore, quando disponibile.",
                      "type": "string"
                    },
                    "error": {
                      "description": "Etichetta breve dell’errore.",
                      "type": "string"
                    },
                    "message": {
                      "description": "Messaggio leggibile.",
                      "type": "string"
                    },
                    "statusCode": {
                      "description": "Codice di stato HTTP ripetuto nel corpo.",
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Errore standard del backend.",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "description": "Errore standard del backend.",
                  "type": "object",
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ],
                  "properties": {
                    "code": {
                      "description": "Codice macchina dell’errore, quando disponibile.",
                      "type": "string"
                    },
                    "error": {
                      "description": "Etichetta breve dell’errore.",
                      "type": "string"
                    },
                    "message": {
                      "description": "Messaggio leggibile.",
                      "type": "string"
                    },
                    "statusCode": {
                      "description": "Codice di stato HTTP ripetuto nel corpo.",
                      "type": "integer"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/partner/statements": {
      "get": {
        "operationId": "listPartnerStatements",
        "summary": "Rendiconti mensili",
        "tags": [
          "partner"
        ],
        "description": "Rendiconti mensili del partner, dal più recente. I link sono firmati a 15 minuti e si rigenerano a ogni chiamata: è ciò che rende vera la promessa dell’email («se scadono, li ritrovi nel pannello»), che prima non lo era nei mesi senza bonifico.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "rows"
                  ],
                  "properties": {
                    "rows": {
                      "type": "array",
                      "items": {
                        "additionalProperties": false,
                        "type": "object",
                        "required": [
                          "closing_minor",
                          "csv_url",
                          "currency",
                          "generated_on",
                          "pdf_url",
                          "period",
                          "sent_on"
                        ],
                        "properties": {
                          "closing_minor": {
                            "description": "Saldo di chiusura del periodo, come stampato sul documento. Minor units (centesimi) come stringa decimale.",
                            "pattern": "^-?[0-9]+$",
                            "type": "string"
                          },
                          "csv_url": {
                            "description": "Link firmato al CSV, TTL 15 minuti. `null` quando il file non è ancora stato prodotto.",
                            "anyOf": [
                              {
                                "format": "uri",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "currency": {
                            "description": "Valuta del rendiconto.",
                            "type": "string"
                          },
                          "generated_on": {
                            "description": "Giorno di emissione del documento.",
                            "format": "date",
                            "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}$",
                            "type": "string"
                          },
                          "pdf_url": {
                            "description": "Link firmato al PDF, TTL 15 minuti. `null` quando il file non è ancora stato prodotto.",
                            "anyOf": [
                              {
                                "format": "uri",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "period": {
                            "description": "Mese di competenza, primo giorno.",
                            "format": "date",
                            "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}$",
                            "type": "string"
                          },
                          "sent_on": {
                            "description": "`null` = documento generato ma non ancora consegnato. Distingue «non gli è arrivato» da «non l’ha aperto», che portano ad azioni diverse.",
                            "anyOf": [
                              {
                                "description": "Giorno di invio dell’email.",
                                "format": "date",
                                "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}$",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Errore standard del backend.",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "description": "Errore standard del backend.",
                  "type": "object",
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ],
                  "properties": {
                    "code": {
                      "description": "Codice macchina dell’errore, quando disponibile.",
                      "type": "string"
                    },
                    "error": {
                      "description": "Etichetta breve dell’errore.",
                      "type": "string"
                    },
                    "message": {
                      "description": "Messaggio leggibile.",
                      "type": "string"
                    },
                    "statusCode": {
                      "description": "Codice di stato HTTP ripetuto nel corpo.",
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Errore standard del backend.",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "description": "Errore standard del backend.",
                  "type": "object",
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ],
                  "properties": {
                    "code": {
                      "description": "Codice macchina dell’errore, quando disponibile.",
                      "type": "string"
                    },
                    "error": {
                      "description": "Etichetta breve dell’errore.",
                      "type": "string"
                    },
                    "message": {
                      "description": "Messaggio leggibile.",
                      "type": "string"
                    },
                    "statusCode": {
                      "description": "Codice di stato HTTP ripetuto nel corpo.",
                      "type": "integer"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/partner/exports/quota": {
      "get": {
        "operationId": "getPartnerExportQuota",
        "summary": "Quota export residua",
        "tags": [
          "partner"
        ],
        "description": "Quota export della giornata. Il tetto è 5 export al giorno (§4.4).",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Quota export della giornata.",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "description": "Quota export della giornata.",
                  "type": "object",
                  "required": [
                    "limit",
                    "used_today"
                  ],
                  "properties": {
                    "limit": {
                      "description": "Export giornalieri concessi.",
                      "minimum": 0,
                      "type": "integer"
                    },
                    "used_today": {
                      "description": "Export già richiesti oggi.",
                      "minimum": 0,
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Errore standard del backend.",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "description": "Errore standard del backend.",
                  "type": "object",
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ],
                  "properties": {
                    "code": {
                      "description": "Codice macchina dell’errore, quando disponibile.",
                      "type": "string"
                    },
                    "error": {
                      "description": "Etichetta breve dell’errore.",
                      "type": "string"
                    },
                    "message": {
                      "description": "Messaggio leggibile.",
                      "type": "string"
                    },
                    "statusCode": {
                      "description": "Codice di stato HTTP ripetuto nel corpo.",
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Errore standard del backend.",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "description": "Errore standard del backend.",
                  "type": "object",
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ],
                  "properties": {
                    "code": {
                      "description": "Codice macchina dell’errore, quando disponibile.",
                      "type": "string"
                    },
                    "error": {
                      "description": "Etichetta breve dell’errore.",
                      "type": "string"
                    },
                    "message": {
                      "description": "Messaggio leggibile.",
                      "type": "string"
                    },
                    "statusCode": {
                      "description": "Codice di stato HTTP ripetuto nel corpo.",
                      "type": "integer"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/partner/exports": {
      "post": {
        "operationId": "createPartnerExport",
        "summary": "Richiedi un export firmato",
        "tags": [
          "partner"
        ],
        "description": "Crea un link di export firmato, valido 15 minuti e **monouso**. L’export contiene SOLO l’id opaco: nessun nome, nessuna email, nessuna azienda — a T0 come a T1. La finestra `from`/`to` è firmata nel token e viene applicata al contenuto. Il tetto è di 10.000 righe: oltre, il file dichiara il troncamento in una riga dedicata. 429 quando la quota giornaliera è esaurita.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "from",
                  "kind",
                  "to"
                ],
                "properties": {
                  "from": {
                    "description": "Inizio della finestra esportata.",
                    "format": "date",
                    "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}$",
                    "type": "string"
                  },
                  "kind": {
                    "description": "Cosa esportare.",
                    "anyOf": [
                      {
                        "type": "string",
                        "enum": [
                          "ledger"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "referrals"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "traffic"
                        ]
                      }
                    ]
                  },
                  "to": {
                    "description": "Fine della finestra esportata.",
                    "format": "date",
                    "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}$",
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "201": {
            "description": "Link di export firmato. Il token porta il `partner_id` DENTRO la firma e il download lo riverifica contro la sessione: un link copiato in una chat non diventa un accesso ai dati di un altro partner nemmeno per quei 15 minuti.",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "description": "Link di export firmato. Il token porta il `partner_id` DENTRO la firma e il download lo riverifica contro la sessione: un link copiato in una chat non diventa un accesso ai dati di un altro partner nemmeno per quei 15 minuti.",
                  "type": "object",
                  "required": [
                    "expires_at",
                    "kind",
                    "url"
                  ],
                  "properties": {
                    "expires_at": {
                      "description": "Scadenza del link firmato.",
                      "format": "date-time",
                      "type": "string"
                    },
                    "kind": {
                      "description": "Tipo di export prodotto.",
                      "anyOf": [
                        {
                          "type": "string",
                          "enum": [
                            "ledger"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "referrals"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "traffic"
                          ]
                        }
                      ]
                    },
                    "url": {
                      "description": "URL firmato del download. Vale 15 minuti e solo per questa sessione.",
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Errore standard del backend.",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "description": "Errore standard del backend.",
                  "type": "object",
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ],
                  "properties": {
                    "code": {
                      "description": "Codice macchina dell’errore, quando disponibile.",
                      "type": "string"
                    },
                    "error": {
                      "description": "Etichetta breve dell’errore.",
                      "type": "string"
                    },
                    "message": {
                      "description": "Messaggio leggibile.",
                      "type": "string"
                    },
                    "statusCode": {
                      "description": "Codice di stato HTTP ripetuto nel corpo.",
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Errore standard del backend.",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "description": "Errore standard del backend.",
                  "type": "object",
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ],
                  "properties": {
                    "code": {
                      "description": "Codice macchina dell’errore, quando disponibile.",
                      "type": "string"
                    },
                    "error": {
                      "description": "Etichetta breve dell’errore.",
                      "type": "string"
                    },
                    "message": {
                      "description": "Messaggio leggibile.",
                      "type": "string"
                    },
                    "statusCode": {
                      "description": "Codice di stato HTTP ripetuto nel corpo.",
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Errore standard del backend.",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "description": "Errore standard del backend.",
                  "type": "object",
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ],
                  "properties": {
                    "code": {
                      "description": "Codice macchina dell’errore, quando disponibile.",
                      "type": "string"
                    },
                    "error": {
                      "description": "Etichetta breve dell’errore.",
                      "type": "string"
                    },
                    "message": {
                      "description": "Messaggio leggibile.",
                      "type": "string"
                    },
                    "statusCode": {
                      "description": "Codice di stato HTTP ripetuto nel corpo.",
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "Errore standard del backend.",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "description": "Errore standard del backend.",
                  "type": "object",
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ],
                  "properties": {
                    "code": {
                      "description": "Codice macchina dell’errore, quando disponibile.",
                      "type": "string"
                    },
                    "error": {
                      "description": "Etichetta breve dell’errore.",
                      "type": "string"
                    },
                    "message": {
                      "description": "Messaggio leggibile.",
                      "type": "string"
                    },
                    "statusCode": {
                      "description": "Codice di stato HTTP ripetuto nel corpo.",
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "Errore standard del backend.",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "description": "Errore standard del backend.",
                  "type": "object",
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ],
                  "properties": {
                    "code": {
                      "description": "Codice macchina dell’errore, quando disponibile.",
                      "type": "string"
                    },
                    "error": {
                      "description": "Etichetta breve dell’errore.",
                      "type": "string"
                    },
                    "message": {
                      "description": "Messaggio leggibile.",
                      "type": "string"
                    },
                    "statusCode": {
                      "description": "Codice di stato HTTP ripetuto nel corpo.",
                      "type": "integer"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/partner/exports/download": {
      "get": {
        "operationId": "downloadPartnerExport",
        "summary": "Scarica un export firmato",
        "tags": [
          "partner"
        ],
        "description": "Scarica un export creato da `POST /partner/exports`. Il token viaggia in QUERY e non in path: un parametro di path è limitato a 100 caratteri da Fastify e un token firmato ne supera 200, quindi in path il link consegnato risponderebbe 404. Il token è firmato, scade in 15 minuti e porta il `partner_id` dentro la firma: viene riverificato contro la sessione, quindi un link condiviso non apre i dati di nessun altro. È **monouso** (§4.6): il primo download lo consuma e ogni tentativo successivo risponde 403 con lo stesso corpo di un token scaduto, manomesso o di un altro partner — i quattro casi sono indistinguibili di proposito. Ogni emissione e ogni download lasciano una riga nel registro `partner_export_audit` (§13.2). Il CSV contiene solo l’ID opaco e un watermark per-partner in coda; se il tetto di righe morde, il file lo DICHIARA con una riga `# wevion-partner-export-truncated,<righe>,<tetto>,<dal>,<al>` prima del watermark.",
        "parameters": [
          {
            "schema": {
              "maxLength": 512,
              "minLength": 1,
              "type": "string"
            },
            "in": "query",
            "name": "token",
            "required": true,
            "description": "Token firmato."
          }
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "CSV dell’export richiesto. Nessuna colonna di identità, né a T0 né a T1.",
            "content": {
              "text/csv": {
                "schema": {
                  "description": "CSV dell’export.",
                  "type": "string"
                }
              }
            }
          },
          "401": {
            "description": "Sessione assente o scaduta.",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "description": "Errore standard del backend.",
                  "type": "object",
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ],
                  "properties": {
                    "code": {
                      "description": "Codice macchina dell’errore, quando disponibile.",
                      "type": "string"
                    },
                    "error": {
                      "description": "Etichetta breve dell’errore.",
                      "type": "string"
                    },
                    "message": {
                      "description": "Messaggio leggibile.",
                      "type": "string"
                    },
                    "statusCode": {
                      "description": "Codice di stato HTTP ripetuto nel corpo.",
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Token scaduto, manomesso, già scaricato (monouso) o appartenente a un altro partner: stesso corpo in tutti i casi.",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "description": "Errore standard del backend.",
                  "type": "object",
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ],
                  "properties": {
                    "code": {
                      "description": "Codice macchina dell’errore, quando disponibile.",
                      "type": "string"
                    },
                    "error": {
                      "description": "Etichetta breve dell’errore.",
                      "type": "string"
                    },
                    "message": {
                      "description": "Messaggio leggibile.",
                      "type": "string"
                    },
                    "statusCode": {
                      "description": "Codice di stato HTTP ripetuto nel corpo.",
                      "type": "integer"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/partner/me": {
      "get": {
        "operationId": "getPartnerMe",
        "summary": "Identità e stato del partner autenticato",
        "tags": [
          "partner"
        ],
        "description": "Identità del partner autenticato con link primario risolto, coupon, saldo in tre numeri, prossimo pagamento con i suoi blocchi e i tre orologi. Nessun importo compare in `/auth/me`: lo store del frontend è persistito e mostrerebbe cifre stantie. 403 quando la sessione non ha un partner attivo.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Identità, link, coupon, saldo e orologi del partner autenticato. È l’unica chiamata montata dalla shell del pannello: l’header non fa query proprie.",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "description": "Identità, link, coupon, saldo e orologi del partner autenticato. È l’unica chiamata montata dalla shell del pannello: l’header non fa query proprie.",
                  "type": "object",
                  "required": [
                    "balance",
                    "clocks",
                    "code",
                    "collection_mode",
                    "coupon",
                    "credit",
                    "frozen",
                    "kyc_level",
                    "lane",
                    "next_payout",
                    "partner_id",
                    "partner_profile",
                    "payout_request",
                    "payout_ready",
                    "primary_link",
                    "public_profile",
                    "reconsent",
                    "redirector_origin",
                    "slug_changes_remaining",
                    "status",
                    "tier"
                  ],
                  "properties": {
                    "balance": {
                      "additionalProperties": false,
                      "description": "I tre numeri del saldo (§4.3). `maturing + available` è esattamente SUM(ledger): il saldo non è una colonna, è la somma delle scritture, ricalcolata a ogni lettura.",
                      "type": "object",
                      "required": [
                        "available_minor",
                        "currency",
                        "maturing_minor",
                        "paid_lifetime_minor"
                      ],
                      "properties": {
                        "available_minor": {
                          "description": "Disponibile: maturato e sbloccato. Minor units (centesimi) come stringa decimale.",
                          "pattern": "^-?[0-9]+$",
                          "type": "string"
                        },
                        "currency": {
                          "description": "Valuta del saldo. In MVP il libro commissioni è EUR.",
                          "type": "string"
                        },
                        "maturing_minor": {
                          "description": "In maturazione: accantonato ma ancora in hold. Minor units (centesimi) come stringa decimale.",
                          "pattern": "^-?[0-9]+$",
                          "type": "string"
                        },
                        "paid_lifetime_minor": {
                          "description": "Pagato a vita: somma dei bonifici già eseguiti. Minor units (centesimi) come stringa decimale.",
                          "pattern": "^-?[0-9]+$",
                          "type": "string"
                        }
                      }
                    },
                    "clocks": {
                      "additionalProperties": false,
                      "description": "I tre orologi (§4.3). Sono distinti perché avanzano a velocità diverse: mostrarne uno solo, o peggio scrivere «in tempo reale», è il modo più rapido per perdere la fiducia sul numero del denaro.",
                      "type": "object",
                      "required": [
                        "activity_as_of",
                        "aggregates_as_of",
                        "money_as_of"
                      ],
                      "properties": {
                        "activity_as_of": {
                          "description": "Ultimo click osservato.",
                          "format": "date-time",
                          "type": "string"
                        },
                        "aggregates_as_of": {
                          "description": "Ultimo ricalcolo dei rollup giornalieri.",
                          "format": "date-time",
                          "type": "string"
                        },
                        "money_as_of": {
                          "description": "Ultima scrittura di denaro sul ledger.",
                          "format": "date-time",
                          "type": "string"
                        }
                      }
                    },
                    "code": {
                      "description": "Il **codice invito** del partner: quello che detta a voce e che il referito digita nel campo «Codice invito» in registrazione. `null` finché non ne ha uno attivo. ⚠️ NON è `coupon.code` (uno sconto per il referito) né lo slug di `primary_link` (un URL): sono tre cose diverse, e prima questa era l’unica che il pannello non sapeva mostrare al suo proprietario — il dato era in tabella, ma il pannello ne leggeva solo l’id.",
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "collection_mode": {
                      "description": "cash | accrual | community_benefit (§6.6).",
                      "type": "string"
                    },
                    "coupon": {
                      "description": "Coupon del partner, `null` se non ne ha uno attivo.",
                      "anyOf": [
                        {
                          "additionalProperties": false,
                          "type": "object",
                          "required": [
                            "code",
                            "discount_label"
                          ],
                          "properties": {
                            "code": {
                              "description": "Codice coupon personale, co-primario col link.",
                              "type": "string"
                            },
                            "discount_label": {
                              "description": "Livello di catalogo dello sconto applicato.",
                              "type": "string"
                            }
                          }
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "credit": {
                      "description": "Credito di fatturazione del Binario A, `null` per chi non è un cliente-referrer.",
                      "anyOf": [
                        {
                          "additionalProperties": false,
                          "type": "object",
                          "required": [
                            "applied_invoices",
                            "available_minor",
                            "currency",
                            "locked_minor",
                            "next_expiry_at",
                            "pending_review_minor",
                            "reserved_minor"
                          ],
                          "properties": {
                            "applied_invoices": {
                              "description": "Fatture DISTINTE che hanno ricevuto il credito. ⚠️ Non è il numero di clienti portati: il pannello mostrava quello, e un cliente con credito 0 leggeva «applicato a 2 fatture».",
                              "minimum": 0,
                              "type": "integer"
                            },
                            "available_minor": {
                              "description": "Spendibile ORA sulla prossima fattura. Minor units (centesimi) come stringa decimale.",
                              "pattern": "^-?[0-9]+$",
                              "type": "string"
                            },
                            "currency": {
                              "description": "Valuta del credito. Il libro del Binario A è EUR.",
                              "type": "string"
                            },
                            "locked_minor": {
                              "description": "Maturato ma non spendibile: nessun abbonamento capace di consumarlo (§2.6). Minor units (centesimi) come stringa decimale.",
                              "pattern": "^-?[0-9]+$",
                              "type": "string"
                            },
                            "next_expiry_at": {
                              "description": "Prima scadenza utile fra le maturazioni ancora coperte dal residuo.",
                              "anyOf": [
                                {
                                  "format": "date-time",
                                  "type": "string"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "pending_review_minor": {
                              "description": "Maturato, non revocato, fermo in revisione umana (§6.4 A3). Minor units (centesimi) come stringa decimale.",
                              "pattern": "^-?[0-9]+$",
                              "type": "string"
                            },
                            "reserved_minor": {
                              "description": "Già spinto sul saldo Stripe, non ancora riconciliato. Minor units (centesimi) come stringa decimale.",
                              "pattern": "^-?[0-9]+$",
                              "type": "string"
                            }
                          }
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "frozen": {
                      "description": "Kill-switch armato: il denaro è congelato, il tracking no.",
                      "type": "boolean"
                    },
                    "kyc_level": {
                      "description": "Livello KYC 0-3 (§6.5).",
                      "maximum": 3,
                      "minimum": 0,
                      "type": "integer"
                    },
                    "lane": {
                      "description": "Corsia C1_creator..C6_agency; NULL sul Binario A.",
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "next_payout": {
                      "additionalProperties": false,
                      "description": "Prossimo pagamento con, in chiaro, cosa manca.",
                      "type": "object",
                      "required": [
                        "amount_minor",
                        "blockers",
                        "date",
                        "held",
                        "threshold_minor"
                      ],
                      "properties": {
                        "amount_minor": {
                          "description": "Importo che verrebbe pagato oggi. Minor units (centesimi) come stringa decimale.",
                          "pattern": "^-?[0-9]+$",
                          "type": "string"
                        },
                        "blockers": {
                          "description": "Cosa impedisce il bonifico, dall’insieme chiuso `PARTNER_PANEL_BLOCKERS` (`lib/partner-reason-codes.ts`): program_frozen, cash_closed, kyc_l1_missing, vat_missing, docs_missing, vies_invalid, awaiting_program_activation, below_threshold. ⚠️ NON è l’enum `PAYOUT_HOLD_REASONS`, che dice perché una riga di payout già creata è ferma e parla a un operatore: questo dice perché un bonifico non nascerà, e parla al partner. Il tipo resta `string` di proposito, così un client vecchio non si rompe se l’insieme cresce.",
                          "type": "array",
                          "items": {
                            "description": "Codice del blocco.",
                            "type": "string"
                          }
                        },
                        "date": {
                          "description": "Data del prossimo run di payout.",
                          "format": "date",
                          "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}$",
                          "type": "string"
                        },
                        "held": {
                          "additionalProperties": false,
                          "description": "★ I pagamenti GIÀ fermi, che `blockers` per costruzione non può vedere: `blockers` guarda lo stato del partner ADESSO e dice se un bonifico nascerà, queste righe dicono che un bonifico è nato e si è fermato. Divergono proprio nel caso che conta, perché il motivo del fermo è una fotografia dell’istante del run e non viene mai rivalutato: un partner che si è messo in regola ha `blockers: []` e le sue righe restano ferme lo stesso. NON è un blocco — la data resta vera per le righe pronte — ma va detto accanto alla data, o il pannello promette un bonifico sopra tre pagamenti che non partiranno.",
                          "type": "object",
                          "required": [
                            "amount_minor",
                            "count"
                          ],
                          "properties": {
                            "amount_minor": {
                              "description": "Denaro complessivamente trattenuto da quelle righe (`allocated_eur_minor`). Minor units (centesimi) come stringa decimale.",
                              "pattern": "^-?[0-9]+$",
                              "type": "string"
                            },
                            "count": {
                              "description": "Quante righe di payout sono ferme.",
                              "minimum": 0,
                              "type": "integer"
                            }
                          }
                        },
                        "threshold_minor": {
                          "description": "Soglia minima di payout. Minor units (centesimi) come stringa decimale.",
                          "pattern": "^-?[0-9]+$",
                          "type": "string"
                        }
                      }
                    },
                    "partner_id": {
                      "description": "Id opaco del partner.",
                      "format": "uuid",
                      "type": "string"
                    },
                    "partner_profile": {
                      "description": "Configurazione dashboard a 4 valori. SOLA LETTURA (§12.5).",
                      "type": "string"
                    },
                    "payout_request": {
                      "description": "Sportello del prelievo. `null` per chi non incassa in denaro: Binario A (compensato in credito di fatturazione) e `collection_mode` diverso da `cash` (`accrual`, `community_benefit`, cioè chi ha scelto di NON essere pagato). ★ È il blocco che trasforma il ciclo da «raccoglie tutti» a «raccoglie chi ha chiesto».",
                      "anyOf": [
                        {
                          "additionalProperties": false,
                          "type": "object",
                          "required": [
                            "available_minor",
                            "can_request",
                            "currency",
                            "missing_minor",
                            "request",
                            "threshold_minor"
                          ],
                          "properties": {
                            "available_minor": {
                              "description": "Saldo disponibile adesso: è ciò che verrebbe chiesto. Minor units (centesimi) come stringa decimale.",
                              "pattern": "^-?[0-9]+$",
                              "type": "string"
                            },
                            "can_request": {
                              "description": "⚠️ NON è «sono sopra soglia»: è «nessun blocco **e** nessuna richiesta già viva». La soglia è uno dei blocchi (`below_threshold`), quindi l’insieme è quello di `next_payout.blockers` e non un secondo giudizio sullo stesso saldo. Falso con una richiesta aperta: il pulsante è spento perché ce n’è una, non perché manchi qualcosa — e il pannello deve dire quale delle due.",
                              "type": "boolean"
                            },
                            "currency": {
                              "description": "Valuta del wallet. Sempre EUR nell’MVP.",
                              "type": "string"
                            },
                            "missing_minor": {
                              "description": "Quanto manca alla soglia, `0` quando è raggiunta. Esiste perché «non disponibile» non è una risposta: un pulsante spento deve dire perché e quanto manca. Mai negativo. Minor units (centesimi) come stringa decimale.",
                              "pattern": "^-?[0-9]+$",
                              "type": "string"
                            },
                            "request": {
                              "description": "La richiesta viva, o — se non ce n’è — **l’ultima chiusa**. Non sparisce dopo l’invio né dopo il pagamento: una richiesta che sparisce nel momento in cui viene servita è il difetto appena chiuso sulle contestazioni, e qui sarebbe peggiore, perché sparirebbe proprio quando arrivano i soldi.",
                              "anyOf": [
                                {
                                  "additionalProperties": false,
                                  "type": "object",
                                  "required": [
                                    "amount_minor",
                                    "cancelled_on",
                                    "paid_on",
                                    "promised_on",
                                    "request_id",
                                    "requested_on",
                                    "status"
                                  ],
                                  "properties": {
                                    "amount_minor": {
                                      "description": "⚠️ **Fotografia** del disponibile all’istante della richiesta, NON un’obbligazione: il ciclo paga ciò che il ledger dice quando gira. Va mostrato come «hai chiesto», mai come «riceverai». Minor units (centesimi) come stringa decimale.",
                                      "pattern": "^-?[0-9]+$",
                                      "type": "string"
                                    },
                                    "cancelled_on": {
                                      "description": "Valorizzato solo su `cancelled`.",
                                      "anyOf": [
                                        {
                                          "description": "Giorno dell’annullamento.",
                                          "format": "date",
                                          "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}$",
                                          "type": "string"
                                        },
                                        {
                                          "type": "null"
                                        }
                                      ]
                                    },
                                    "paid_on": {
                                      "description": "Valorizzato solo su `paid`.",
                                      "anyOf": [
                                        {
                                          "description": "Giorno del pagamento.",
                                          "format": "date",
                                          "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}$",
                                          "type": "string"
                                        },
                                        {
                                          "type": "null"
                                        }
                                      ]
                                    },
                                    "promised_on": {
                                      "description": "La promessa congelata alla richiesta: «entro il 15 del mese successivo». ⚠️ NON coincide con `next_payout.date`: la bozza del ciclo nasce il 1°, quindi una richiesta del 3 agosto non può entrare nel pagamento del 15 agosto. È una promessa a una PERSONA, mantenuta a mano perché il bonifico è un atto manuale — da qui la parola «entro».",
                                      "format": "date",
                                      "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}$",
                                      "type": "string"
                                    },
                                    "request_id": {
                                      "description": "Id della richiesta del partner stesso.",
                                      "format": "uuid",
                                      "type": "string"
                                    },
                                    "requested_on": {
                                      "description": "Giorno in cui il partner ha chiesto.",
                                      "format": "date",
                                      "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}$",
                                      "type": "string"
                                    },
                                    "status": {
                                      "description": "Insieme CHIUSO: `open` · `processing` · `paid` · `cancelled`. `processing` = presa in carico da un ciclo, e da lì si esce sempre: `paid`, oppure di nuovo `open` se il ciclo muore (rilascio automatico). Nessuno dei quattro è un vicolo cieco.",
                                      "type": "string"
                                    }
                                  }
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "threshold_minor": {
                              "description": "Soglia minima di prelievo (`partner_payout_threshold_eur_minor`). Minor units (centesimi) come stringa decimale.",
                              "pattern": "^-?[0-9]+$",
                              "type": "string"
                            }
                          }
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "payout_ready": {
                      "description": "Documenti fiscali a posto. Ortogonale allo stato delle commissioni (§6.2).",
                      "type": "boolean"
                    },
                    "primary_link": {
                      "description": "Link primario già risolto, `null` finché non esiste un alias attivo.",
                      "anyOf": [
                        {
                          "additionalProperties": false,
                          "type": "object",
                          "required": [
                            "link_id",
                            "qr_url_png",
                            "qr_url_svg",
                            "slug",
                            "url"
                          ],
                          "properties": {
                            "link_id": {
                              "description": "Variante collegata.",
                              "anyOf": [
                                {
                                  "format": "uuid",
                                  "type": "string"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "qr_url_png": {
                              "description": "Endpoint del QR PNG.",
                              "anyOf": [
                                {
                                  "type": "string"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "qr_url_svg": {
                              "description": "Endpoint del QR SVG.",
                              "anyOf": [
                                {
                                  "type": "string"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "slug": {
                              "description": "Slug vanity pubblico.",
                              "type": "string"
                            },
                            "url": {
                              "description": "URL già risolto: il frontend non compone mai un link.",
                              "type": "string"
                            }
                          }
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "public_profile": {
                      "additionalProperties": false,
                      "description": "Profilo pubblico del partner: è il gate dell’identità reciproca.",
                      "type": "object",
                      "required": [
                        "approved",
                        "avatar_url",
                        "display_name",
                        "handle",
                        "tagline"
                      ],
                      "properties": {
                        "approved": {
                          "description": "true solo dopo l’approvazione del backoffice (§4.5).",
                          "type": "boolean"
                        },
                        "avatar_url": {
                          "description": "Avatar pubblico.",
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "display_name": {
                          "description": "Nome mostrato al referito.",
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "handle": {
                          "description": "Handle social pubblico.",
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "tagline": {
                          "description": "Una riga di presentazione.",
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        }
                      }
                    },
                    "reconsent": {
                      "additionalProperties": false,
                      "description": "Stato del ri-consenso ai termini di programma: cosa manca e se è esigibile.",
                      "type": "object",
                      "required": [
                        "accepted_documents",
                        "accepted_program_version",
                        "current_program_version",
                        "outstanding_documents",
                        "reasons",
                        "required"
                      ],
                      "properties": {
                        "accepted_documents": {
                          "additionalProperties": false,
                          "description": "Versione accettata per ciascun documento di programma. Input di `outstandingPartnerDocuments()`.",
                          "type": "object",
                          "properties": {
                            "partnerContentAddendum": {
                              "description": "Versione accettata di partnerContentAddendum. Assente = mai accettato.",
                              "type": "string"
                            },
                            "partnerSelfBilling": {
                              "description": "Versione accettata di partnerSelfBilling. Assente = mai accettato.",
                              "type": "string"
                            },
                            "partnerTerms": {
                              "description": "Versione accettata di partnerTerms. Assente = mai accettato.",
                              "type": "string"
                            },
                            "referralTerms": {
                              "description": "Versione accettata di referralTerms. Assente = mai accettato.",
                              "type": "string"
                            }
                          }
                        },
                        "accepted_program_version": {
                          "description": "Riferimento a una `partner_program_version`, `null` quando non ne esiste una.",
                          "anyOf": [
                            {
                              "additionalProperties": false,
                              "type": "object",
                              "required": [
                                "id",
                                "version"
                              ],
                              "properties": {
                                "id": {
                                  "description": "Id della versione di programma.",
                                  "format": "uuid",
                                  "type": "string"
                                },
                                "version": {
                                  "description": "Etichetta di versione, es. `1.0`.",
                                  "type": "string"
                                }
                              }
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "current_program_version": {
                          "description": "Riferimento a una `partner_program_version`, `null` quando non ne esiste una.",
                          "anyOf": [
                            {
                              "additionalProperties": false,
                              "type": "object",
                              "required": [
                                "id",
                                "version"
                              ],
                              "properties": {
                                "id": {
                                  "description": "Id della versione di programma.",
                                  "format": "uuid",
                                  "type": "string"
                                },
                                "version": {
                                  "description": "Etichetta di versione, es. `1.0`.",
                                  "type": "string"
                                }
                              }
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "outstanding_documents": {
                          "description": "Documenti la cui versione accettata differisce dalla corrente. Rilevamento puro: comprende anche i documenti il cui testo non esiste ancora, perché non accettati lo sono comunque.",
                          "type": "array",
                          "items": {
                            "description": "Id del documento di programma.",
                            "type": "string"
                          }
                        },
                        "reasons": {
                          "description": "Perché il ri-consenso è dovuto. Vuoto quando `required` è false.",
                          "type": "array",
                          "items": {
                            "description": "never_enrolled | program_version_superseded | documents_outdated.",
                            "type": "string"
                          }
                        },
                        "required": {
                          "description": "true solo quando esiste qualcosa che il partner può DAVVERO riaccettare (vedi `reasons`).",
                          "type": "boolean"
                        }
                      }
                    },
                    "redirector_origin": {
                      "description": "Origine pubblica del redirector, così stage e produzione non divergono per un build flag (§12.2).",
                      "type": "string"
                    },
                    "slug_changes_remaining": {
                      "description": "Rinomine di slug residue nella finestra 12 mesi.",
                      "minimum": 0,
                      "type": "integer"
                    },
                    "status": {
                      "description": "Stato del partner: qui è sempre `approved`.",
                      "type": "string"
                    },
                    "tier": {
                      "description": "partner | silver | gold.",
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Errore standard del backend.",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "description": "Errore standard del backend.",
                  "type": "object",
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ],
                  "properties": {
                    "code": {
                      "description": "Codice macchina dell’errore, quando disponibile.",
                      "type": "string"
                    },
                    "error": {
                      "description": "Etichetta breve dell’errore.",
                      "type": "string"
                    },
                    "message": {
                      "description": "Messaggio leggibile.",
                      "type": "string"
                    },
                    "statusCode": {
                      "description": "Codice di stato HTTP ripetuto nel corpo.",
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Errore standard del backend.",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "description": "Errore standard del backend.",
                  "type": "object",
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ],
                  "properties": {
                    "code": {
                      "description": "Codice macchina dell’errore, quando disponibile.",
                      "type": "string"
                    },
                    "error": {
                      "description": "Etichetta breve dell’errore.",
                      "type": "string"
                    },
                    "message": {
                      "description": "Messaggio leggibile.",
                      "type": "string"
                    },
                    "statusCode": {
                      "description": "Codice di stato HTTP ripetuto nel corpo.",
                      "type": "integer"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/partner/pulse": {
      "get": {
        "operationId": "getPartnerPulse",
        "summary": "Badge eventi nuovi e freschezza dei tre layer",
        "tags": [
          "partner"
        ],
        "description": "Contatore per il badge «n nuovi eventi — aggiorna» e i tre timestamp di freschezza. `since` è l’ultimo istante già visto dal client. ★ Senza `since` il contatore NON è più 0: si conta da `partner.pulse_seen_at`, il puntatore del lettore persistito sulla riga — prima il puntatore viveva solo nel client, e un dispositivo nuovo (o una navigazione privata, o i dati del sito svuotati) leggeva sempre «0 eventi nuovi» qualunque cosa fosse successa. Con `since` esplicito il puntatore avanza, e **solo in avanti**: due dispositivi che si alternano non si azzerano il badge a vicenda.",
        "parameters": [
          {
            "schema": {
              "format": "date-time",
              "type": "string"
            },
            "in": "query",
            "name": "since",
            "required": false,
            "description": "Ultimo istante già visto dal client."
          }
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Endpoint volutamente minuscolo: accende un badge, non aggiorna la vista. Il pannello non fa mai auto-refresh — i numeri non si spostano sotto le dita di chi li sta leggendo (§4.3).",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "description": "Endpoint volutamente minuscolo: accende un badge, non aggiorna la vista. Il pannello non fa mai auto-refresh — i numeri non si spostano sotto le dita di chi li sta leggendo (§4.3).",
                  "type": "object",
                  "required": [
                    "activity_as_of",
                    "aggregates_as_of",
                    "money_as_of",
                    "new_events"
                  ],
                  "properties": {
                    "activity_as_of": {
                      "description": "Ultimo click osservato.",
                      "format": "date-time",
                      "type": "string"
                    },
                    "aggregates_as_of": {
                      "description": "Ultimo ricalcolo dei rollup.",
                      "format": "date-time",
                      "type": "string"
                    },
                    "money_as_of": {
                      "description": "Ultima scrittura di denaro.",
                      "format": "date-time",
                      "type": "string"
                    },
                    "new_events": {
                      "description": "Eventi nuovi dopo `since`, o dopo `partner.pulse_seen_at` quando `since` non è passato. 0 solo quando nessuno dei due esiste, cioè quando il partner non ha davvero mai guardato.",
                      "minimum": 0,
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Errore standard del backend.",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "description": "Errore standard del backend.",
                  "type": "object",
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ],
                  "properties": {
                    "code": {
                      "description": "Codice macchina dell’errore, quando disponibile.",
                      "type": "string"
                    },
                    "error": {
                      "description": "Etichetta breve dell’errore.",
                      "type": "string"
                    },
                    "message": {
                      "description": "Messaggio leggibile.",
                      "type": "string"
                    },
                    "statusCode": {
                      "description": "Codice di stato HTTP ripetuto nel corpo.",
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Errore standard del backend.",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "description": "Errore standard del backend.",
                  "type": "object",
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ],
                  "properties": {
                    "code": {
                      "description": "Codice macchina dell’errore, quando disponibile.",
                      "type": "string"
                    },
                    "error": {
                      "description": "Etichetta breve dell’errore.",
                      "type": "string"
                    },
                    "message": {
                      "description": "Messaggio leggibile.",
                      "type": "string"
                    },
                    "statusCode": {
                      "description": "Codice di stato HTTP ripetuto nel corpo.",
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Errore standard del backend.",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "description": "Errore standard del backend.",
                  "type": "object",
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ],
                  "properties": {
                    "code": {
                      "description": "Codice macchina dell’errore, quando disponibile.",
                      "type": "string"
                    },
                    "error": {
                      "description": "Etichetta breve dell’errore.",
                      "type": "string"
                    },
                    "message": {
                      "description": "Messaggio leggibile.",
                      "type": "string"
                    },
                    "statusCode": {
                      "description": "Codice di stato HTTP ripetuto nel corpo.",
                      "type": "integer"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/partner/overview": {
      "get": {
        "operationId": "getPartnerOverview",
        "summary": "Panoramica: funnel, KPI, EPC, churn",
        "tags": [
          "partner"
        ],
        "description": "Funnel e KPI della panoramica sulla finestra richiesta. `clicks_total = 0` è il segnale con cui il frontend mostra la cassetta degli attrezzi invece di un funnel a zero: una dashboard di zeri al primo accesso è la ragione numero uno per cui un partner non torna.",
        "parameters": [
          {
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "enum": [
                    "7d"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "30d"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "90d"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "12m"
                  ]
                }
              ]
            },
            "in": "query",
            "name": "window",
            "required": false,
            "description": "Finestra di osservazione. Default 90d."
          }
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Funnel a 5 numeri e KPI della panoramica.",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "description": "Funnel a 5 numeri e KPI della panoramica.",
                  "type": "object",
                  "required": [
                    "active_customers",
                    "as_of",
                    "clicks_total",
                    "clicks_unique",
                    "clicks_valid",
                    "epc_minor",
                    "lost_customers",
                    "maturing_commission_minor",
                    "reversed_commission_minor",
                    "signups",
                    "trials",
                    "window"
                  ],
                  "properties": {
                    "active_customers": {
                      "description": "Clienti paganti attivi nella finestra.",
                      "minimum": 0,
                      "type": "integer"
                    },
                    "as_of": {
                      "description": "Istante del calcolo.",
                      "format": "date-time",
                      "type": "string"
                    },
                    "clicks_total": {
                      "description": "Click totali, validi e non.",
                      "minimum": 0,
                      "type": "integer"
                    },
                    "clicks_unique": {
                      "description": "Click unici.",
                      "minimum": 0,
                      "type": "integer"
                    },
                    "clicks_valid": {
                      "description": "Click validi: il denominatore dell’EPC.",
                      "minimum": 0,
                      "type": "integer"
                    },
                    "epc_minor": {
                      "description": "`null` con zero click: mai 0,00 €, che direbbe «hai guadagnato zero», non «non c’è nulla da misurare».",
                      "anyOf": [
                        {
                          "description": "Guadagno per click valido. Minor units (centesimi) come stringa decimale.",
                          "pattern": "^-?[0-9]+$",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "lost_customers": {
                      "description": "Clienti persi. Si mostra sempre (§4.3): il churn non si nasconde.",
                      "minimum": 0,
                      "type": "integer"
                    },
                    "maturing_commission_minor": {
                      "description": "Commissione maturata nella finestra. Minor units (centesimi) come stringa decimale.",
                      "pattern": "^-?[0-9]+$",
                      "type": "string"
                    },
                    "reversed_commission_minor": {
                      "description": "Storni e svalutazioni della finestra, come numero negativo. Minor units (centesimi) come stringa decimale.",
                      "pattern": "^-?[0-9]+$",
                      "type": "string"
                    },
                    "signups": {
                      "description": "Iscritti.",
                      "minimum": 0,
                      "type": "integer"
                    },
                    "trials": {
                      "description": "In prova.",
                      "minimum": 0,
                      "type": "integer"
                    },
                    "window": {
                      "description": "Finestra effettivamente applicata.",
                      "anyOf": [
                        {
                          "type": "string",
                          "enum": [
                            "7d"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "30d"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "90d"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "12m"
                          ]
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Errore standard del backend.",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "description": "Errore standard del backend.",
                  "type": "object",
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ],
                  "properties": {
                    "code": {
                      "description": "Codice macchina dell’errore, quando disponibile.",
                      "type": "string"
                    },
                    "error": {
                      "description": "Etichetta breve dell’errore.",
                      "type": "string"
                    },
                    "message": {
                      "description": "Messaggio leggibile.",
                      "type": "string"
                    },
                    "statusCode": {
                      "description": "Codice di stato HTTP ripetuto nel corpo.",
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Errore standard del backend.",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "description": "Errore standard del backend.",
                  "type": "object",
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ],
                  "properties": {
                    "code": {
                      "description": "Codice macchina dell’errore, quando disponibile.",
                      "type": "string"
                    },
                    "error": {
                      "description": "Etichetta breve dell’errore.",
                      "type": "string"
                    },
                    "message": {
                      "description": "Messaggio leggibile.",
                      "type": "string"
                    },
                    "statusCode": {
                      "description": "Codice di stato HTTP ripetuto nel corpo.",
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Errore standard del backend.",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "description": "Errore standard del backend.",
                  "type": "object",
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ],
                  "properties": {
                    "code": {
                      "description": "Codice macchina dell’errore, quando disponibile.",
                      "type": "string"
                    },
                    "error": {
                      "description": "Etichetta breve dell’errore.",
                      "type": "string"
                    },
                    "message": {
                      "description": "Messaggio leggibile.",
                      "type": "string"
                    },
                    "statusCode": {
                      "description": "Codice di stato HTTP ripetuto nel corpo.",
                      "type": "integer"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/partner/calculator": {
      "get": {
        "operationId": "getPartnerCalculator",
        "summary": "Ingredienti del calcolatore guadagni",
        "tags": [
          "partner"
        ],
        "description": "Listino pubblico e aliquota corrente del partner: sono gli ingredienti con cui il pannello mostra «3 clienti Pro = X €/mese». Il calcolo vive nel frontend perché è una stima, e una stima calcolata dal server somiglia troppo a una promessa.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Ingredienti del calcolatore. Il server non calcola la proiezione: manda listino, aliquota e la SCOMPOSIZIONE della finestra, e il frontend mostra la stima con il disclaimer obbligatorio — «non è una previsione di guadagno». La scomposizione esiste perché la promessa a schermo (24 mesi a piena aliquota) valeva il doppio di quanto il motore matura (12): con `full_months`/`tail_months`/`tail_rate_bp` la stessa schermata resta vera in entrambi gli stati del flag della coda.",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "description": "Ingredienti del calcolatore. Il server non calcola la proiezione: manda listino, aliquota e la SCOMPOSIZIONE della finestra, e il frontend mostra la stima con il disclaimer obbligatorio — «non è una previsione di guadagno». La scomposizione esiste perché la promessa a schermo (24 mesi a piena aliquota) valeva il doppio di quanto il motore matura (12): con `full_months`/`tail_months`/`tail_rate_bp` la stessa schermata resta vera in entrambi gli stati del flag della coda.",
                  "type": "object",
                  "required": [
                    "attribution_window_months",
                    "full_months",
                    "plans",
                    "rate_available",
                    "rate_bp",
                    "tail_months",
                    "tail_rate_bp",
                    "window_months"
                  ],
                  "properties": {
                    "attribution_window_months": {
                      "description": "Mesi entro cui un incasso resta riconducibile al referral. NON è l’orizzonte della proiezione: l’attribuzione dura più a lungo di quanto la commissione maturi.",
                      "minimum": 1,
                      "type": "integer"
                    },
                    "full_months": {
                      "description": "Mesi che maturano a piena aliquota.",
                      "minimum": 1,
                      "type": "integer"
                    },
                    "plans": {
                      "description": "Piani attivi del listino pubblico.",
                      "type": "array",
                      "items": {
                        "additionalProperties": false,
                        "type": "object",
                        "required": [
                          "currency",
                          "id",
                          "monthly_price_minor",
                          "name"
                        ],
                        "properties": {
                          "currency": {
                            "description": "Valuta del listino.",
                            "type": "string"
                          },
                          "id": {
                            "description": "Id del piano.",
                            "format": "uuid",
                            "type": "string"
                          },
                          "monthly_price_minor": {
                            "description": "Prezzo mensile di listino. Minor units (centesimi) come stringa decimale.",
                            "pattern": "^-?[0-9]+$",
                            "type": "string"
                          },
                          "name": {
                            "description": "Nome commerciale del piano.",
                            "type": "string"
                          }
                        }
                      }
                    },
                    "rate_available": {
                      "description": "`false` quando nessuna versione di programma è pubblicata: `rate_bp` vale 0 perché non è ancora stata congelata, non perché il partner guadagni zero. Il pannello deve dirlo, non mostrare «0,00 €».",
                      "type": "boolean"
                    },
                    "rate_bp": {
                      "description": "Aliquota corrente del partner in basis point interi.",
                      "minimum": 0,
                      "type": "integer"
                    },
                    "tail_months": {
                      "description": "Mesi che maturano a metà aliquota. `0` con `partner_tail_accrual_enabled` spento.",
                      "minimum": 0,
                      "type": "integer"
                    },
                    "tail_rate_bp": {
                      "description": "Aliquota effettiva nei mesi di coda. `0` quando `tail_months` è `0`.",
                      "minimum": 0,
                      "type": "integer"
                    },
                    "window_months": {
                      "description": "Mesi che maturano DAVVERO: `full_months + tail_months`. È l’orizzonte della proiezione.",
                      "minimum": 1,
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Errore standard del backend.",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "description": "Errore standard del backend.",
                  "type": "object",
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ],
                  "properties": {
                    "code": {
                      "description": "Codice macchina dell’errore, quando disponibile.",
                      "type": "string"
                    },
                    "error": {
                      "description": "Etichetta breve dell’errore.",
                      "type": "string"
                    },
                    "message": {
                      "description": "Messaggio leggibile.",
                      "type": "string"
                    },
                    "statusCode": {
                      "description": "Codice di stato HTTP ripetuto nel corpo.",
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Errore standard del backend.",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "description": "Errore standard del backend.",
                  "type": "object",
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ],
                  "properties": {
                    "code": {
                      "description": "Codice macchina dell’errore, quando disponibile.",
                      "type": "string"
                    },
                    "error": {
                      "description": "Etichetta breve dell’errore.",
                      "type": "string"
                    },
                    "message": {
                      "description": "Messaggio leggibile.",
                      "type": "string"
                    },
                    "statusCode": {
                      "description": "Codice di stato HTTP ripetuto nel corpo.",
                      "type": "integer"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/partner/consent": {
      "post": {
        "operationId": "recordPartnerConsent",
        "summary": "Accetta i documenti di programma alla loro versione corrente",
        "tags": [
          "partner"
        ],
        "description": "Registra l’accettazione dei documenti di programma da parte del partner autenticato: una riga `legal_consent` per documento e, quando esiste una versione di programma pubblicata per il suo binario, una riga `partner_program_enrollment`. L’adesione è APPEND-ONLY (`trg_ppe_append_only`) e unica per versione (`uq_ppe_partner_version`): riaccettare la stessa versione è idempotente e restituisce `enrolled: false`. Una versione di documento diversa da quella corrente è `409`: un client fermo su un testo vecchio si dichiarerebbe in pari senza aver mai visto quello nuovo.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "documents"
                ],
                "properties": {
                  "documents": {
                    "description": "I documenti che il partner dichiara di accettare, ciascuno con la versione che ha letto.",
                    "maxItems": 16,
                    "minItems": 1,
                    "type": "array",
                    "items": {
                      "additionalProperties": false,
                      "type": "object",
                      "required": [
                        "document",
                        "version"
                      ],
                      "properties": {
                        "document": {
                          "description": "Id del documento di programma.",
                          "maxLength": 40,
                          "minLength": 1,
                          "type": "string"
                        },
                        "version": {
                          "description": "Versione accettata. Deve essere quella corrente.",
                          "maxLength": 20,
                          "type": "string"
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Esito dell’accettazione, con lo stato di ri-consenso aggiornato.",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "description": "Esito dell’accettazione, con lo stato di ri-consenso aggiornato.",
                  "type": "object",
                  "required": [
                    "enrolled",
                    "recorded",
                    "reconsent"
                  ],
                  "properties": {
                    "enrolled": {
                      "description": "true se è nata una riga `partner_program_enrollment`. false quando il partner aveva già aderito a quella versione (idempotenza) o quando nessuna versione di programma è pubblicata.",
                      "type": "boolean"
                    },
                    "recorded": {
                      "description": "I documenti per cui è nata una riga `legal_consent`.",
                      "type": "array",
                      "items": {
                        "description": "Id del documento registrato.",
                        "type": "string"
                      }
                    },
                    "reconsent": {
                      "additionalProperties": false,
                      "description": "Stato del ri-consenso ai termini di programma: cosa manca e se è esigibile.",
                      "type": "object",
                      "required": [
                        "accepted_documents",
                        "accepted_program_version",
                        "current_program_version",
                        "outstanding_documents",
                        "reasons",
                        "required"
                      ],
                      "properties": {
                        "accepted_documents": {
                          "additionalProperties": false,
                          "description": "Versione accettata per ciascun documento di programma. Input di `outstandingPartnerDocuments()`.",
                          "type": "object",
                          "properties": {
                            "partnerContentAddendum": {
                              "description": "Versione accettata di partnerContentAddendum. Assente = mai accettato.",
                              "type": "string"
                            },
                            "partnerSelfBilling": {
                              "description": "Versione accettata di partnerSelfBilling. Assente = mai accettato.",
                              "type": "string"
                            },
                            "partnerTerms": {
                              "description": "Versione accettata di partnerTerms. Assente = mai accettato.",
                              "type": "string"
                            },
                            "referralTerms": {
                              "description": "Versione accettata di referralTerms. Assente = mai accettato.",
                              "type": "string"
                            }
                          }
                        },
                        "accepted_program_version": {
                          "description": "Riferimento a una `partner_program_version`, `null` quando non ne esiste una.",
                          "anyOf": [
                            {
                              "additionalProperties": false,
                              "type": "object",
                              "required": [
                                "id",
                                "version"
                              ],
                              "properties": {
                                "id": {
                                  "description": "Id della versione di programma.",
                                  "format": "uuid",
                                  "type": "string"
                                },
                                "version": {
                                  "description": "Etichetta di versione, es. `1.0`.",
                                  "type": "string"
                                }
                              }
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "current_program_version": {
                          "description": "Riferimento a una `partner_program_version`, `null` quando non ne esiste una.",
                          "anyOf": [
                            {
                              "additionalProperties": false,
                              "type": "object",
                              "required": [
                                "id",
                                "version"
                              ],
                              "properties": {
                                "id": {
                                  "description": "Id della versione di programma.",
                                  "format": "uuid",
                                  "type": "string"
                                },
                                "version": {
                                  "description": "Etichetta di versione, es. `1.0`.",
                                  "type": "string"
                                }
                              }
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "outstanding_documents": {
                          "description": "Documenti la cui versione accettata differisce dalla corrente. Rilevamento puro: comprende anche i documenti il cui testo non esiste ancora, perché non accettati lo sono comunque.",
                          "type": "array",
                          "items": {
                            "description": "Id del documento di programma.",
                            "type": "string"
                          }
                        },
                        "reasons": {
                          "description": "Perché il ri-consenso è dovuto. Vuoto quando `required` è false.",
                          "type": "array",
                          "items": {
                            "description": "never_enrolled | program_version_superseded | documents_outdated.",
                            "type": "string"
                          }
                        },
                        "required": {
                          "description": "true solo quando esiste qualcosa che il partner può DAVVERO riaccettare (vedi `reasons`).",
                          "type": "boolean"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Errore standard del backend.",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "description": "Errore standard del backend.",
                  "type": "object",
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ],
                  "properties": {
                    "code": {
                      "description": "Codice macchina dell’errore, quando disponibile.",
                      "type": "string"
                    },
                    "error": {
                      "description": "Etichetta breve dell’errore.",
                      "type": "string"
                    },
                    "message": {
                      "description": "Messaggio leggibile.",
                      "type": "string"
                    },
                    "statusCode": {
                      "description": "Codice di stato HTTP ripetuto nel corpo.",
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Errore standard del backend.",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "description": "Errore standard del backend.",
                  "type": "object",
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ],
                  "properties": {
                    "code": {
                      "description": "Codice macchina dell’errore, quando disponibile.",
                      "type": "string"
                    },
                    "error": {
                      "description": "Etichetta breve dell’errore.",
                      "type": "string"
                    },
                    "message": {
                      "description": "Messaggio leggibile.",
                      "type": "string"
                    },
                    "statusCode": {
                      "description": "Codice di stato HTTP ripetuto nel corpo.",
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Errore standard del backend.",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "description": "Errore standard del backend.",
                  "type": "object",
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ],
                  "properties": {
                    "code": {
                      "description": "Codice macchina dell’errore, quando disponibile.",
                      "type": "string"
                    },
                    "error": {
                      "description": "Etichetta breve dell’errore.",
                      "type": "string"
                    },
                    "message": {
                      "description": "Messaggio leggibile.",
                      "type": "string"
                    },
                    "statusCode": {
                      "description": "Codice di stato HTTP ripetuto nel corpo.",
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "Errore standard del backend.",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "description": "Errore standard del backend.",
                  "type": "object",
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ],
                  "properties": {
                    "code": {
                      "description": "Codice macchina dell’errore, quando disponibile.",
                      "type": "string"
                    },
                    "error": {
                      "description": "Etichetta breve dell’errore.",
                      "type": "string"
                    },
                    "message": {
                      "description": "Messaggio leggibile.",
                      "type": "string"
                    },
                    "statusCode": {
                      "description": "Codice di stato HTTP ripetuto nel corpo.",
                      "type": "integer"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/partner/profile": {
      "patch": {
        "operationId": "updatePartnerPublicProfile",
        "summary": "Aggiorna il profilo pubblico del partner",
        "tags": [
          "partner"
        ],
        "description": "Aggiorna il profilo PUBBLICO del partner. Ogni modifica riporta il profilo in `pending`: senza ri-approvazione un profilo già approvato potrebbe cambiare nome e aggirare il gate umano dell’identità reciproca (§4.5). Finché è `pending` le celle identità restano coperte.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "description": "Profilo PUBBLICO. Non è `partner_profile`, che è la configurazione a 4 valori della dashboard ed è in sola lettura per il partner (§12.5).",
                "type": "object",
                "properties": {
                  "avatar_url": {
                    "description": "URL dell’avatar pubblico.",
                    "anyOf": [
                      {
                        "maxLength": 500,
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "display_name": {
                    "description": "Nome mostrato al referito.",
                    "maxLength": 120,
                    "minLength": 2,
                    "type": "string"
                  },
                  "handle": {
                    "description": "Handle social pubblico.",
                    "anyOf": [
                      {
                        "maxLength": 80,
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "tagline": {
                    "description": "Una riga di presentazione.",
                    "anyOf": [
                      {
                        "maxLength": 160,
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  }
                }
              }
            }
          },
          "description": "Profilo PUBBLICO. Non è `partner_profile`, che è la configurazione a 4 valori della dashboard ed è in sola lettura per il partner (§12.5)."
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Profilo pubblico del partner: è il gate dell’identità reciproca.",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "description": "Profilo pubblico del partner: è il gate dell’identità reciproca.",
                  "type": "object",
                  "required": [
                    "approved",
                    "avatar_url",
                    "display_name",
                    "handle",
                    "tagline"
                  ],
                  "properties": {
                    "approved": {
                      "description": "true solo dopo l’approvazione del backoffice (§4.5).",
                      "type": "boolean"
                    },
                    "avatar_url": {
                      "description": "Avatar pubblico.",
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "display_name": {
                      "description": "Nome mostrato al referito.",
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "handle": {
                      "description": "Handle social pubblico.",
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "tagline": {
                      "description": "Una riga di presentazione.",
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Errore standard del backend.",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "description": "Errore standard del backend.",
                  "type": "object",
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ],
                  "properties": {
                    "code": {
                      "description": "Codice macchina dell’errore, quando disponibile.",
                      "type": "string"
                    },
                    "error": {
                      "description": "Etichetta breve dell’errore.",
                      "type": "string"
                    },
                    "message": {
                      "description": "Messaggio leggibile.",
                      "type": "string"
                    },
                    "statusCode": {
                      "description": "Codice di stato HTTP ripetuto nel corpo.",
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Errore standard del backend.",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "description": "Errore standard del backend.",
                  "type": "object",
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ],
                  "properties": {
                    "code": {
                      "description": "Codice macchina dell’errore, quando disponibile.",
                      "type": "string"
                    },
                    "error": {
                      "description": "Etichetta breve dell’errore.",
                      "type": "string"
                    },
                    "message": {
                      "description": "Messaggio leggibile.",
                      "type": "string"
                    },
                    "statusCode": {
                      "description": "Codice di stato HTTP ripetuto nel corpo.",
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Errore standard del backend.",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "description": "Errore standard del backend.",
                  "type": "object",
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ],
                  "properties": {
                    "code": {
                      "description": "Codice macchina dell’errore, quando disponibile.",
                      "type": "string"
                    },
                    "error": {
                      "description": "Etichetta breve dell’errore.",
                      "type": "string"
                    },
                    "message": {
                      "description": "Messaggio leggibile.",
                      "type": "string"
                    },
                    "statusCode": {
                      "description": "Codice di stato HTTP ripetuto nel corpo.",
                      "type": "integer"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/partner/payout-request": {
      "post": {
        "operationId": "createPartnerPayoutRequest",
        "summary": "Chiedi il pagamento del saldo disponibile",
        "tags": [
          "partner"
        ],
        "description": "Apre una richiesta di prelievo per il partner autenticato. L’importo NON si sceglie: è il saldo disponibile **all’istante della richiesta**, congelato sulla riga come fotografia. ⚠️ Non è un’obbligazione — il ciclo paga ciò che il ledger dice quando gira — ed è questa separazione che rende sicuro rimettere in coda una presa in carico morta senza rischiare un doppio pagamento. Saldo, soglia e blocchi sono **riletti dal server**: la UI non è un controllo, e questa rotta è raggiungibile senza passare da nessun pulsante. `409` = ne esiste già una aperta (l’unicità la impone il database, `uq_ppr_open_partner`, non una SELECT che due schede del browser supererebbero entrambe). `422` = sotto soglia, col numero che manca nel corpo.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "201": {
            "description": "La richiesta appena aperta o appena annullata. Torna lo stato RICALCOLATO, non quello che il client credeva: è ciò che gli permette di mostrare la ricevuta senza una seconda chiamata a `/me`.",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "description": "La richiesta appena aperta o appena annullata. Torna lo stato RICALCOLATO, non quello che il client credeva: è ciò che gli permette di mostrare la ricevuta senza una seconda chiamata a `/me`.",
                  "type": "object",
                  "required": [
                    "amount_minor",
                    "promised_on",
                    "request_id",
                    "requested_on",
                    "status"
                  ],
                  "properties": {
                    "amount_minor": {
                      "description": "Importo chiesto, congelato alla richiesta. Minor units (centesimi) come stringa decimale.",
                      "pattern": "^-?[0-9]+$",
                      "type": "string"
                    },
                    "promised_on": {
                      "description": "Entro quando la pagheremo: il 15 del mese successivo alla richiesta.",
                      "format": "date",
                      "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}$",
                      "type": "string"
                    },
                    "request_id": {
                      "description": "Id della richiesta.",
                      "format": "uuid",
                      "type": "string"
                    },
                    "requested_on": {
                      "description": "Giorno della richiesta.",
                      "format": "date",
                      "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}$",
                      "type": "string"
                    },
                    "status": {
                      "description": "`open` dopo l’apertura, `cancelled` dopo l’annullamento.",
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Errore standard del backend.",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "description": "Errore standard del backend.",
                  "type": "object",
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ],
                  "properties": {
                    "code": {
                      "description": "Codice macchina dell’errore, quando disponibile.",
                      "type": "string"
                    },
                    "error": {
                      "description": "Etichetta breve dell’errore.",
                      "type": "string"
                    },
                    "message": {
                      "description": "Messaggio leggibile.",
                      "type": "string"
                    },
                    "statusCode": {
                      "description": "Codice di stato HTTP ripetuto nel corpo.",
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Errore standard del backend.",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "description": "Errore standard del backend.",
                  "type": "object",
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ],
                  "properties": {
                    "code": {
                      "description": "Codice macchina dell’errore, quando disponibile.",
                      "type": "string"
                    },
                    "error": {
                      "description": "Etichetta breve dell’errore.",
                      "type": "string"
                    },
                    "message": {
                      "description": "Messaggio leggibile.",
                      "type": "string"
                    },
                    "statusCode": {
                      "description": "Codice di stato HTTP ripetuto nel corpo.",
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "Errore standard del backend.",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "description": "Errore standard del backend.",
                  "type": "object",
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ],
                  "properties": {
                    "code": {
                      "description": "Codice macchina dell’errore, quando disponibile.",
                      "type": "string"
                    },
                    "error": {
                      "description": "Etichetta breve dell’errore.",
                      "type": "string"
                    },
                    "message": {
                      "description": "Messaggio leggibile.",
                      "type": "string"
                    },
                    "statusCode": {
                      "description": "Codice di stato HTTP ripetuto nel corpo.",
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "422": {
            "description": "Errore standard del backend.",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "description": "Errore standard del backend.",
                  "type": "object",
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ],
                  "properties": {
                    "code": {
                      "description": "Codice macchina dell’errore, quando disponibile.",
                      "type": "string"
                    },
                    "error": {
                      "description": "Etichetta breve dell’errore.",
                      "type": "string"
                    },
                    "message": {
                      "description": "Messaggio leggibile.",
                      "type": "string"
                    },
                    "statusCode": {
                      "description": "Codice di stato HTTP ripetuto nel corpo.",
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "Errore standard del backend.",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "description": "Errore standard del backend.",
                  "type": "object",
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ],
                  "properties": {
                    "code": {
                      "description": "Codice macchina dell’errore, quando disponibile.",
                      "type": "string"
                    },
                    "error": {
                      "description": "Etichetta breve dell’errore.",
                      "type": "string"
                    },
                    "message": {
                      "description": "Messaggio leggibile.",
                      "type": "string"
                    },
                    "statusCode": {
                      "description": "Codice di stato HTTP ripetuto nel corpo.",
                      "type": "integer"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/partner/payout-request/{request_id}": {
      "delete": {
        "operationId": "cancelPartnerPayoutRequest",
        "summary": "Annulla la richiesta di prelievo",
        "tags": [
          "partner"
        ],
        "description": "★ Annulla una richiesta di prelievo ancora `open`. È la porta d’uscita, e nasce nella stessa consegna dell’ingresso: in questo programma sono stati trovati **sei** stati in cui il sistema entra e non sa uscire, e il settimo non si aggiunge qui. `409` con codice `PARTNER_PAYOUT_REQUEST_IN_RUN` quando la richiesta è già entrata in un ciclo — da lì non si torna indietro, ma il pagamento **arriverà**, ed è una frase diversa da «non si può». Una presa in carico rimasta ferma oltre il tempo massimo viene rimessa in coda **in questo stesso gesto**, così chi annulla non deve aspettare un giro in più per riavere il controllo.",
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "request_id",
            "required": true,
            "description": "Id della richiesta da annullare."
          }
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "La richiesta appena aperta o appena annullata. Torna lo stato RICALCOLATO, non quello che il client credeva: è ciò che gli permette di mostrare la ricevuta senza una seconda chiamata a `/me`.",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "description": "La richiesta appena aperta o appena annullata. Torna lo stato RICALCOLATO, non quello che il client credeva: è ciò che gli permette di mostrare la ricevuta senza una seconda chiamata a `/me`.",
                  "type": "object",
                  "required": [
                    "amount_minor",
                    "promised_on",
                    "request_id",
                    "requested_on",
                    "status"
                  ],
                  "properties": {
                    "amount_minor": {
                      "description": "Importo chiesto, congelato alla richiesta. Minor units (centesimi) come stringa decimale.",
                      "pattern": "^-?[0-9]+$",
                      "type": "string"
                    },
                    "promised_on": {
                      "description": "Entro quando la pagheremo: il 15 del mese successivo alla richiesta.",
                      "format": "date",
                      "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}$",
                      "type": "string"
                    },
                    "request_id": {
                      "description": "Id della richiesta.",
                      "format": "uuid",
                      "type": "string"
                    },
                    "requested_on": {
                      "description": "Giorno della richiesta.",
                      "format": "date",
                      "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}$",
                      "type": "string"
                    },
                    "status": {
                      "description": "`open` dopo l’apertura, `cancelled` dopo l’annullamento.",
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Errore standard del backend.",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "description": "Errore standard del backend.",
                  "type": "object",
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ],
                  "properties": {
                    "code": {
                      "description": "Codice macchina dell’errore, quando disponibile.",
                      "type": "string"
                    },
                    "error": {
                      "description": "Etichetta breve dell’errore.",
                      "type": "string"
                    },
                    "message": {
                      "description": "Messaggio leggibile.",
                      "type": "string"
                    },
                    "statusCode": {
                      "description": "Codice di stato HTTP ripetuto nel corpo.",
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Errore standard del backend.",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "description": "Errore standard del backend.",
                  "type": "object",
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ],
                  "properties": {
                    "code": {
                      "description": "Codice macchina dell’errore, quando disponibile.",
                      "type": "string"
                    },
                    "error": {
                      "description": "Etichetta breve dell’errore.",
                      "type": "string"
                    },
                    "message": {
                      "description": "Messaggio leggibile.",
                      "type": "string"
                    },
                    "statusCode": {
                      "description": "Codice di stato HTTP ripetuto nel corpo.",
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "Errore standard del backend.",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "description": "Errore standard del backend.",
                  "type": "object",
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ],
                  "properties": {
                    "code": {
                      "description": "Codice macchina dell’errore, quando disponibile.",
                      "type": "string"
                    },
                    "error": {
                      "description": "Etichetta breve dell’errore.",
                      "type": "string"
                    },
                    "message": {
                      "description": "Messaggio leggibile.",
                      "type": "string"
                    },
                    "statusCode": {
                      "description": "Codice di stato HTTP ripetuto nel corpo.",
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "Errore standard del backend.",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "description": "Errore standard del backend.",
                  "type": "object",
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ],
                  "properties": {
                    "code": {
                      "description": "Codice macchina dell’errore, quando disponibile.",
                      "type": "string"
                    },
                    "error": {
                      "description": "Etichetta breve dell’errore.",
                      "type": "string"
                    },
                    "message": {
                      "description": "Messaggio leggibile.",
                      "type": "string"
                    },
                    "statusCode": {
                      "description": "Codice di stato HTTP ripetuto nel corpo.",
                      "type": "integer"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/referral/inviter": {
      "get": {
        "operationId": "getReferralInviter",
        "summary": "Chi mi ha invitato",
        "tags": [
          "partner"
        ],
        "description": "Chi ha invitato il richiedente, e quale livello di disvelamento ha scelto. 204 quando il richiedente non è un referito tracciato: non è un errore, è l’assenza di un rapporto.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Chi mi ha invitato e quale disvelamento ho scelto.",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "description": "Chi mi ha invitato e quale disvelamento ho scelto.",
                  "type": "object",
                  "required": [
                    "inviter",
                    "reference",
                    "state",
                    "wording_key"
                  ],
                  "properties": {
                    "inviter": {
                      "description": "Profilo dell’invitante, `null` finché il backoffice non lo ha approvato: è la seconda metà della regola dell’identità reciproca (§4.5). Senza approvazione il referito sa che esiste un invitante, non chi è — esattamente come il partner vede una cella coperta.",
                      "anyOf": [
                        {
                          "additionalProperties": false,
                          "type": "object",
                          "required": [
                            "avatar_url",
                            "display_name",
                            "tagline"
                          ],
                          "properties": {
                            "avatar_url": {
                              "description": "Avatar pubblico dell’invitante.",
                              "anyOf": [
                                {
                                  "type": "string"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "display_name": {
                              "description": "Nome pubblico dell’invitante.",
                              "anyOf": [
                                {
                                  "type": "string"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "tagline": {
                              "description": "Una riga di presentazione.",
                              "anyOf": [
                                {
                                  "type": "string"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            }
                          }
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "reference": {
                      "description": "ID opaco del rapporto, lo stesso che il partner vede nel pannello.",
                      "type": "string"
                    },
                    "state": {
                      "description": "Stato di disvelamento corrente scelto dal referito.",
                      "anyOf": [
                        {
                          "type": "string",
                          "enum": [
                            "anonymous"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "covered"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "identified"
                          ]
                        }
                      ]
                    },
                    "wording_key": {
                      "description": "Chiave i18n del testo di consenso mostrato, versionata.",
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "204": {
            "description": "Il richiedente non è un referito tracciato."
          },
          "401": {
            "description": "Errore standard del backend.",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "description": "Errore standard del backend.",
                  "type": "object",
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ],
                  "properties": {
                    "code": {
                      "description": "Codice macchina dell’errore, quando disponibile.",
                      "type": "string"
                    },
                    "error": {
                      "description": "Etichetta breve dell’errore.",
                      "type": "string"
                    },
                    "message": {
                      "description": "Messaggio leggibile.",
                      "type": "string"
                    },
                    "statusCode": {
                      "description": "Codice di stato HTTP ripetuto nel corpo.",
                      "type": "integer"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/referral/disclosure": {
      "put": {
        "operationId": "setReferralDisclosure",
        "summary": "Imposta il proprio livello di disvelamento",
        "tags": [
          "partner"
        ],
        "description": "Imposta il proprio stato di disvelamento verso il partner che ha invitato. Ogni cambio scrive una RIGA NUOVA in `legal_consent` (`referralIdentityDisclosure` / `referralIdentityDisclosureRevoked`), mai un UPDATE: la prova legale di un consenso è la sua storia. L’effetto sul pannello è immediato. Il ledger, le commissioni e i totali restano invariati. 204 quando il richiedente non è un referito tracciato.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "state"
                ],
                "properties": {
                  "state": {
                    "description": "`identified` acconsente al disvelamento; `covered` è il livello conservativo di default; `anonymous` è l’opposizione dell’art. 21 GDPR e fa sparire anche la classe di contatto.",
                    "anyOf": [
                      {
                        "type": "string",
                        "enum": [
                          "anonymous"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "covered"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "identified"
                        ]
                      }
                    ]
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Stato applicato, con effetto immediato sul pannello del partner: la richiesta successiva del partner vede già il cambiamento. Il ledger e i totali non si toccano — l’opposizione riguarda l’identità, non la contabilità.",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "description": "Stato applicato, con effetto immediato sul pannello del partner: la richiesta successiva del partner vede già il cambiamento. Il ledger e i totali non si toccano — l’opposizione riguarda l’identità, non la contabilità.",
                  "type": "object",
                  "required": [
                    "state"
                  ],
                  "properties": {
                    "state": {
                      "description": "Stato applicato.",
                      "anyOf": [
                        {
                          "type": "string",
                          "enum": [
                            "anonymous"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "covered"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "identified"
                          ]
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "204": {
            "description": "Il richiedente non è un referito tracciato: nulla da impostare."
          },
          "400": {
            "description": "Errore standard del backend.",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "description": "Errore standard del backend.",
                  "type": "object",
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ],
                  "properties": {
                    "code": {
                      "description": "Codice macchina dell’errore, quando disponibile.",
                      "type": "string"
                    },
                    "error": {
                      "description": "Etichetta breve dell’errore.",
                      "type": "string"
                    },
                    "message": {
                      "description": "Messaggio leggibile.",
                      "type": "string"
                    },
                    "statusCode": {
                      "description": "Codice di stato HTTP ripetuto nel corpo.",
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Errore standard del backend.",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "description": "Errore standard del backend.",
                  "type": "object",
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ],
                  "properties": {
                    "code": {
                      "description": "Codice macchina dell’errore, quando disponibile.",
                      "type": "string"
                    },
                    "error": {
                      "description": "Etichetta breve dell’errore.",
                      "type": "string"
                    },
                    "message": {
                      "description": "Messaggio leggibile.",
                      "type": "string"
                    },
                    "statusCode": {
                      "description": "Codice di stato HTTP ripetuto nel corpo.",
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "Errore standard del backend.",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "description": "Errore standard del backend.",
                  "type": "object",
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ],
                  "properties": {
                    "code": {
                      "description": "Codice macchina dell’errore, quando disponibile.",
                      "type": "string"
                    },
                    "error": {
                      "description": "Etichetta breve dell’errore.",
                      "type": "string"
                    },
                    "message": {
                      "description": "Messaggio leggibile.",
                      "type": "string"
                    },
                    "statusCode": {
                      "description": "Codice di stato HTTP ripetuto nel corpo.",
                      "type": "integer"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/public/referral-inviter": {
      "get": {
        "operationId": "getPublicReferralInviter",
        "summary": "Profilo pubblico dell’invitante",
        "tags": [
          "partner"
        ],
        "description": "Profilo pubblico dell’invitante a partire dal codice in query. Rotta PUBBLICA: serve la pagina di registrazione, dove una sessione non esiste ancora. Non conferma mai l’esistenza di un codice — inesistente, sospeso e non approvato rispondono tutti `inviter: null` — e ha un rate limit perché anche una risposta indistinguibile, interrogata abbastanza in fretta, diventa un elenco.",
        "parameters": [
          {
            "schema": {
              "maxLength": 20,
              "minLength": 1,
              "type": "string"
            },
            "in": "query",
            "name": "ref",
            "required": true,
            "description": "Codice invito."
          }
        ],
        "responses": {
          "200": {
            "description": "Profilo pubblico dell’invitante per la pagina di registrazione. `inviter: null` copre indistintamente codice inesistente, partner sospeso e profilo non approvato: la rotta non conferma mai l’esistenza di un codice.",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "description": "Profilo pubblico dell’invitante per la pagina di registrazione. `inviter: null` copre indistintamente codice inesistente, partner sospeso e profilo non approvato: la rotta non conferma mai l’esistenza di un codice.",
                  "type": "object",
                  "required": [
                    "inviter"
                  ],
                  "properties": {
                    "inviter": {
                      "description": "Profilo dell’invitante, `null` finché il backoffice non lo ha approvato: è la seconda metà della regola dell’identità reciproca (§4.5). Senza approvazione il referito sa che esiste un invitante, non chi è — esattamente come il partner vede una cella coperta.",
                      "anyOf": [
                        {
                          "additionalProperties": false,
                          "type": "object",
                          "required": [
                            "avatar_url",
                            "display_name",
                            "tagline"
                          ],
                          "properties": {
                            "avatar_url": {
                              "description": "Avatar pubblico dell’invitante.",
                              "anyOf": [
                                {
                                  "type": "string"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "display_name": {
                              "description": "Nome pubblico dell’invitante.",
                              "anyOf": [
                                {
                                  "type": "string"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "tagline": {
                              "description": "Una riga di presentazione.",
                              "anyOf": [
                                {
                                  "type": "string"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            }
                          }
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Errore standard del backend.",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "description": "Errore standard del backend.",
                  "type": "object",
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ],
                  "properties": {
                    "code": {
                      "description": "Codice macchina dell’errore, quando disponibile.",
                      "type": "string"
                    },
                    "error": {
                      "description": "Etichetta breve dell’errore.",
                      "type": "string"
                    },
                    "message": {
                      "description": "Messaggio leggibile.",
                      "type": "string"
                    },
                    "statusCode": {
                      "description": "Codice di stato HTTP ripetuto nel corpo.",
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "Errore standard del backend.",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "description": "Errore standard del backend.",
                  "type": "object",
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ],
                  "properties": {
                    "code": {
                      "description": "Codice macchina dell’errore, quando disponibile.",
                      "type": "string"
                    },
                    "error": {
                      "description": "Etichetta breve dell’errore.",
                      "type": "string"
                    },
                    "message": {
                      "description": "Messaggio leggibile.",
                      "type": "string"
                    },
                    "statusCode": {
                      "description": "Codice di stato HTTP ripetuto nel corpo.",
                      "type": "integer"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/partner/materials": {
      "get": {
        "operationId": "getPartnerMaterials",
        "summary": "Kit materiali del partner",
        "tags": [
          "partner"
        ],
        "description": "Kit materiali della famiglia del partner: copy, asset, brief e chiave del disclaimer #ADV. `limit` serve alla card di anteprima della panoramica, che ne mostra i primi tre.",
        "parameters": [
          {
            "schema": {
              "maximum": 8,
              "minimum": 1,
              "type": "integer"
            },
            "in": "query",
            "name": "limit",
            "required": false,
            "description": "Quanti copy restituire. Default 5."
          }
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Kit materiali della famiglia del partner. Il server manda CHIAVI i18n, mai testo umano: i copy e il disclaimer sono materiale legale ancora aperto e congelarli in una risposta API li renderebbe un contratto.",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "description": "Kit materiali della famiglia del partner. Il server manda CHIAVI i18n, mai testo umano: i copy e il disclaimer sono materiale legale ancora aperto e congelarli in una risposta API li renderebbe un contratto.",
                  "type": "object",
                  "required": [
                    "assets",
                    "brief_key",
                    "copies",
                    "disclaimer_key",
                    "family"
                  ],
                  "properties": {
                    "assets": {
                      "description": "Asset scaricabili del kit.",
                      "type": "array",
                      "items": {
                        "additionalProperties": false,
                        "type": "object",
                        "required": [
                          "id",
                          "kind",
                          "name",
                          "url",
                          "vector_kind",
                          "vector_url"
                        ],
                        "properties": {
                          "id": {
                            "description": "Id stabile dell’asset.",
                            "type": "string"
                          },
                          "kind": {
                            "description": "Formato del file principale: `png`. È il raster.",
                            "type": "string"
                          },
                          "name": {
                            "description": "Chiave i18n del nome.",
                            "type": "string"
                          },
                          "url": {
                            "description": "Percorso di download del RASTER (PNG). È il formato che Instagram, TikTok e Reels accettano in caricamento: un SVG qui renderebbe il kit inutilizzabile.",
                            "type": "string"
                          },
                          "vector_kind": {
                            "description": "Formato dell’alternativa vettoriale: `svg`.",
                            "type": "string"
                          },
                          "vector_url": {
                            "description": "Percorso dell’SVG, per stampa e ridimensionamento senza perdita.",
                            "type": "string"
                          }
                        }
                      }
                    },
                    "brief_key": {
                      "description": "Chiave i18n del brief di famiglia.",
                      "type": "string"
                    },
                    "copies": {
                      "description": "Copy pronti, con i placeholder risolti al momento della copia.",
                      "type": "array",
                      "items": {
                        "additionalProperties": false,
                        "type": "object",
                        "required": [
                          "id",
                          "template",
                          "title"
                        ],
                        "properties": {
                          "id": {
                            "description": "Id stabile del copy.",
                            "type": "string"
                          },
                          "template": {
                            "description": "Chiave i18n del template, con i placeholder.",
                            "type": "string"
                          },
                          "title": {
                            "description": "Chiave i18n del titolo.",
                            "type": "string"
                          }
                        }
                      }
                    },
                    "disclaimer_key": {
                      "description": "Chiave i18n del disclaimer #ADV, obbligatorio e non chiudibile.",
                      "type": "string"
                    },
                    "family": {
                      "description": "creator | distributor | seller: 3 famiglie, non 6 corsie (§2.3).",
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Errore standard del backend.",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "description": "Errore standard del backend.",
                  "type": "object",
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ],
                  "properties": {
                    "code": {
                      "description": "Codice macchina dell’errore, quando disponibile.",
                      "type": "string"
                    },
                    "error": {
                      "description": "Etichetta breve dell’errore.",
                      "type": "string"
                    },
                    "message": {
                      "description": "Messaggio leggibile.",
                      "type": "string"
                    },
                    "statusCode": {
                      "description": "Codice di stato HTTP ripetuto nel corpo.",
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Errore standard del backend.",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "description": "Errore standard del backend.",
                  "type": "object",
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ],
                  "properties": {
                    "code": {
                      "description": "Codice macchina dell’errore, quando disponibile.",
                      "type": "string"
                    },
                    "error": {
                      "description": "Etichetta breve dell’errore.",
                      "type": "string"
                    },
                    "message": {
                      "description": "Messaggio leggibile.",
                      "type": "string"
                    },
                    "statusCode": {
                      "description": "Codice di stato HTTP ripetuto nel corpo.",
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Errore standard del backend.",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "description": "Errore standard del backend.",
                  "type": "object",
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ],
                  "properties": {
                    "code": {
                      "description": "Codice macchina dell’errore, quando disponibile.",
                      "type": "string"
                    },
                    "error": {
                      "description": "Etichetta breve dell’errore.",
                      "type": "string"
                    },
                    "message": {
                      "description": "Messaggio leggibile.",
                      "type": "string"
                    },
                    "statusCode": {
                      "description": "Codice di stato HTTP ripetuto nel corpo.",
                      "type": "integer"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/partner/destinations": {
      "get": {
        "operationId": "listPartnerDestinations",
        "summary": "Catalogo delle destinazioni",
        "tags": [
          "partner"
        ],
        "description": "Catalogo curato delle destinazioni selezionabili per una variante. È l’unico insieme di valori accettati da `POST /links`: non esiste un campo URL libero, per costruzione.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Destinazioni selezionabili per una variante.",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "description": "Destinazioni selezionabili per una variante.",
                  "type": "object",
                  "required": [
                    "destinations"
                  ],
                  "properties": {
                    "destinations": {
                      "description": "Catalogo CURATO. Mai un URL libero: è la contromisura all’open redirect.",
                      "type": "array",
                      "items": {
                        "additionalProperties": false,
                        "type": "object",
                        "required": [
                          "id",
                          "label",
                          "relative_path",
                          "slug"
                        ],
                        "properties": {
                          "id": {
                            "description": "Id della destinazione.",
                            "format": "uuid",
                            "type": "string"
                          },
                          "label": {
                            "description": "Etichetta leggibile.",
                            "type": "string"
                          },
                          "relative_path": {
                            "description": "Percorso relativo servito dal redirector.",
                            "type": "string"
                          },
                          "slug": {
                            "description": "Slug della destinazione nel catalogo.",
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Errore standard del backend.",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "description": "Errore standard del backend.",
                  "type": "object",
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ],
                  "properties": {
                    "code": {
                      "description": "Codice macchina dell’errore, quando disponibile.",
                      "type": "string"
                    },
                    "error": {
                      "description": "Etichetta breve dell’errore.",
                      "type": "string"
                    },
                    "message": {
                      "description": "Messaggio leggibile.",
                      "type": "string"
                    },
                    "statusCode": {
                      "description": "Codice di stato HTTP ripetuto nel corpo.",
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Errore standard del backend.",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "description": "Errore standard del backend.",
                  "type": "object",
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ],
                  "properties": {
                    "code": {
                      "description": "Codice macchina dell’errore, quando disponibile.",
                      "type": "string"
                    },
                    "error": {
                      "description": "Etichetta breve dell’errore.",
                      "type": "string"
                    },
                    "message": {
                      "description": "Messaggio leggibile.",
                      "type": "string"
                    },
                    "statusCode": {
                      "description": "Codice di stato HTTP ripetuto nel corpo.",
                      "type": "integer"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/partner/links": {
      "get": {
        "operationId": "listPartnerLinks",
        "summary": "Varianti di link del partner",
        "tags": [
          "partner"
        ],
        "description": "Varianti del partner. Le archiviate escono solo con `include_archived=true`.",
        "parameters": [
          {
            "schema": {
              "type": "boolean"
            },
            "in": "query",
            "name": "include_archived",
            "required": false,
            "description": "Includi le varianti archiviate."
          }
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Varianti del partner, massimo 25 attive.",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "description": "Varianti del partner, massimo 25 attive.",
                  "type": "object",
                  "required": [
                    "rows"
                  ],
                  "properties": {
                    "rows": {
                      "description": "Varianti del partner.",
                      "type": "array",
                      "items": {
                        "additionalProperties": false,
                        "description": "Una variante di link del partner.",
                        "type": "object",
                        "required": [
                          "archived",
                          "destination_id",
                          "id",
                          "is_default",
                          "name",
                          "slug",
                          "url",
                          "utm_campaign",
                          "utm_content",
                          "utm_medium",
                          "utm_source"
                        ],
                        "properties": {
                          "archived": {
                            "description": "Archiviata. Le varianti non si cancellano: orfanerebbero i click storici.",
                            "type": "boolean"
                          },
                          "destination_id": {
                            "description": "Destinazione del catalogo curato.",
                            "format": "uuid",
                            "type": "string"
                          },
                          "id": {
                            "description": "Id della variante.",
                            "format": "uuid",
                            "type": "string"
                          },
                          "is_default": {
                            "description": "Variante di default del partner.",
                            "type": "boolean"
                          },
                          "name": {
                            "description": "Nome scelto dal partner.",
                            "type": "string"
                          },
                          "slug": {
                            "description": "Slug pubblico della variante. `null` solo per le varianti create prima di D7.5, che non hanno un alias proprio.",
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "url": {
                            "description": "URL pubblico della variante, già risolto dal server. Il client non lo compone mai (§12.2).",
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "utm_campaign": {
                            "description": "UTM campagna della variante: quello chiesto in creazione, normalizzato, oppure quello derivato dal nome quando non è stato chiesto.",
                            "type": "string"
                          },
                          "utm_content": {
                            "description": "UTM content, quando presente.",
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "utm_medium": {
                            "description": "UTM medium generato da Wevion.",
                            "type": "string"
                          },
                          "utm_source": {
                            "description": "UTM source generato da Wevion.",
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Errore standard del backend.",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "description": "Errore standard del backend.",
                  "type": "object",
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ],
                  "properties": {
                    "code": {
                      "description": "Codice macchina dell’errore, quando disponibile.",
                      "type": "string"
                    },
                    "error": {
                      "description": "Etichetta breve dell’errore.",
                      "type": "string"
                    },
                    "message": {
                      "description": "Messaggio leggibile.",
                      "type": "string"
                    },
                    "statusCode": {
                      "description": "Codice di stato HTTP ripetuto nel corpo.",
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Errore standard del backend.",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "description": "Errore standard del backend.",
                  "type": "object",
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ],
                  "properties": {
                    "code": {
                      "description": "Codice macchina dell’errore, quando disponibile.",
                      "type": "string"
                    },
                    "error": {
                      "description": "Etichetta breve dell’errore.",
                      "type": "string"
                    },
                    "message": {
                      "description": "Messaggio leggibile.",
                      "type": "string"
                    },
                    "statusCode": {
                      "description": "Codice di stato HTTP ripetuto nel corpo.",
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Errore standard del backend.",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "description": "Errore standard del backend.",
                  "type": "object",
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ],
                  "properties": {
                    "code": {
                      "description": "Codice macchina dell’errore, quando disponibile.",
                      "type": "string"
                    },
                    "error": {
                      "description": "Etichetta breve dell’errore.",
                      "type": "string"
                    },
                    "message": {
                      "description": "Messaggio leggibile.",
                      "type": "string"
                    },
                    "statusCode": {
                      "description": "Codice di stato HTTP ripetuto nel corpo.",
                      "type": "integer"
                    }
                  }
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "createPartnerLink",
        "summary": "Crea una variante di link",
        "tags": [
          "partner"
        ],
        "description": "Crea una variante. Il tetto è 25 varianti attive (§4.8) ed è anche un vincolo di database: oltre il tetto la risposta è 409. Un `destination_id` fuori dal catalogo curato risponde 403 con lo stesso corpo di ogni altro diniego — non è «non trovato», è una destinazione che il partner non può scegliere.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "destination_id",
                  "name"
                ],
                "properties": {
                  "destination_id": {
                    "description": "Destinazione del catalogo curato. Un id fuori catalogo è 403, non 404.",
                    "format": "uuid",
                    "type": "string"
                  },
                  "name": {
                    "description": "Nome della variante.",
                    "maxLength": 60,
                    "minLength": 1,
                    "type": "string"
                  },
                  "utm_campaign": {
                    "description": "UTM campagna scelto dal partner. Omesso, il server lo deriva dal nome — che è ciò che faceva SEMPRE, anche quando il campo veniva mandato. Normalizzato con la stessa regola del ripiego (minuscolo, non-alfanumerici a trattino, massimo 120): un UTM è un pezzo di URL, e «Estate 26» e «estate-26» non devono diventare due campagne nei rapporti.",
                    "maxLength": 120,
                    "minLength": 1,
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "201": {
            "description": "Una variante di link del partner.",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "description": "Una variante di link del partner.",
                  "type": "object",
                  "required": [
                    "archived",
                    "destination_id",
                    "id",
                    "is_default",
                    "name",
                    "slug",
                    "url",
                    "utm_campaign",
                    "utm_content",
                    "utm_medium",
                    "utm_source"
                  ],
                  "properties": {
                    "archived": {
                      "description": "Archiviata. Le varianti non si cancellano: orfanerebbero i click storici.",
                      "type": "boolean"
                    },
                    "destination_id": {
                      "description": "Destinazione del catalogo curato.",
                      "format": "uuid",
                      "type": "string"
                    },
                    "id": {
                      "description": "Id della variante.",
                      "format": "uuid",
                      "type": "string"
                    },
                    "is_default": {
                      "description": "Variante di default del partner.",
                      "type": "boolean"
                    },
                    "name": {
                      "description": "Nome scelto dal partner.",
                      "type": "string"
                    },
                    "slug": {
                      "description": "Slug pubblico della variante. `null` solo per le varianti create prima di D7.5, che non hanno un alias proprio.",
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "url": {
                      "description": "URL pubblico della variante, già risolto dal server. Il client non lo compone mai (§12.2).",
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "utm_campaign": {
                      "description": "UTM campagna della variante: quello chiesto in creazione, normalizzato, oppure quello derivato dal nome quando non è stato chiesto.",
                      "type": "string"
                    },
                    "utm_content": {
                      "description": "UTM content, quando presente.",
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "utm_medium": {
                      "description": "UTM medium generato da Wevion.",
                      "type": "string"
                    },
                    "utm_source": {
                      "description": "UTM source generato da Wevion.",
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Errore standard del backend.",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "description": "Errore standard del backend.",
                  "type": "object",
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ],
                  "properties": {
                    "code": {
                      "description": "Codice macchina dell’errore, quando disponibile.",
                      "type": "string"
                    },
                    "error": {
                      "description": "Etichetta breve dell’errore.",
                      "type": "string"
                    },
                    "message": {
                      "description": "Messaggio leggibile.",
                      "type": "string"
                    },
                    "statusCode": {
                      "description": "Codice di stato HTTP ripetuto nel corpo.",
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Errore standard del backend.",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "description": "Errore standard del backend.",
                  "type": "object",
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ],
                  "properties": {
                    "code": {
                      "description": "Codice macchina dell’errore, quando disponibile.",
                      "type": "string"
                    },
                    "error": {
                      "description": "Etichetta breve dell’errore.",
                      "type": "string"
                    },
                    "message": {
                      "description": "Messaggio leggibile.",
                      "type": "string"
                    },
                    "statusCode": {
                      "description": "Codice di stato HTTP ripetuto nel corpo.",
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Errore standard del backend.",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "description": "Errore standard del backend.",
                  "type": "object",
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ],
                  "properties": {
                    "code": {
                      "description": "Codice macchina dell’errore, quando disponibile.",
                      "type": "string"
                    },
                    "error": {
                      "description": "Etichetta breve dell’errore.",
                      "type": "string"
                    },
                    "message": {
                      "description": "Messaggio leggibile.",
                      "type": "string"
                    },
                    "statusCode": {
                      "description": "Codice di stato HTTP ripetuto nel corpo.",
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "Errore standard del backend.",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "description": "Errore standard del backend.",
                  "type": "object",
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ],
                  "properties": {
                    "code": {
                      "description": "Codice macchina dell’errore, quando disponibile.",
                      "type": "string"
                    },
                    "error": {
                      "description": "Etichetta breve dell’errore.",
                      "type": "string"
                    },
                    "message": {
                      "description": "Messaggio leggibile.",
                      "type": "string"
                    },
                    "statusCode": {
                      "description": "Codice di stato HTTP ripetuto nel corpo.",
                      "type": "integer"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/partner/links/{id}": {
      "patch": {
        "operationId": "updatePartnerLink",
        "summary": "Rinomina o archivia una variante",
        "tags": [
          "partner"
        ],
        "description": "Rinomina o archivia una variante. Una variante di un altro partner risponde 403 con lo stesso corpo di una inesistente: un 404 sarebbe già la risposta «quell’id esiste/non esiste».",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "properties": {
                  "archived": {
                    "description": "Archivia o ripristina. Non esiste una cancellazione.",
                    "type": "boolean"
                  },
                  "name": {
                    "description": "Nuovo nome.",
                    "maxLength": 60,
                    "minLength": 1,
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true,
            "description": "Id della variante del partner."
          }
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Una variante di link del partner.",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "description": "Una variante di link del partner.",
                  "type": "object",
                  "required": [
                    "archived",
                    "destination_id",
                    "id",
                    "is_default",
                    "name",
                    "slug",
                    "url",
                    "utm_campaign",
                    "utm_content",
                    "utm_medium",
                    "utm_source"
                  ],
                  "properties": {
                    "archived": {
                      "description": "Archiviata. Le varianti non si cancellano: orfanerebbero i click storici.",
                      "type": "boolean"
                    },
                    "destination_id": {
                      "description": "Destinazione del catalogo curato.",
                      "format": "uuid",
                      "type": "string"
                    },
                    "id": {
                      "description": "Id della variante.",
                      "format": "uuid",
                      "type": "string"
                    },
                    "is_default": {
                      "description": "Variante di default del partner.",
                      "type": "boolean"
                    },
                    "name": {
                      "description": "Nome scelto dal partner.",
                      "type": "string"
                    },
                    "slug": {
                      "description": "Slug pubblico della variante. `null` solo per le varianti create prima di D7.5, che non hanno un alias proprio.",
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "url": {
                      "description": "URL pubblico della variante, già risolto dal server. Il client non lo compone mai (§12.2).",
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "utm_campaign": {
                      "description": "UTM campagna della variante: quello chiesto in creazione, normalizzato, oppure quello derivato dal nome quando non è stato chiesto.",
                      "type": "string"
                    },
                    "utm_content": {
                      "description": "UTM content, quando presente.",
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "utm_medium": {
                      "description": "UTM medium generato da Wevion.",
                      "type": "string"
                    },
                    "utm_source": {
                      "description": "UTM source generato da Wevion.",
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Errore standard del backend.",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "description": "Errore standard del backend.",
                  "type": "object",
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ],
                  "properties": {
                    "code": {
                      "description": "Codice macchina dell’errore, quando disponibile.",
                      "type": "string"
                    },
                    "error": {
                      "description": "Etichetta breve dell’errore.",
                      "type": "string"
                    },
                    "message": {
                      "description": "Messaggio leggibile.",
                      "type": "string"
                    },
                    "statusCode": {
                      "description": "Codice di stato HTTP ripetuto nel corpo.",
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Errore standard del backend.",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "description": "Errore standard del backend.",
                  "type": "object",
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ],
                  "properties": {
                    "code": {
                      "description": "Codice macchina dell’errore, quando disponibile.",
                      "type": "string"
                    },
                    "error": {
                      "description": "Etichetta breve dell’errore.",
                      "type": "string"
                    },
                    "message": {
                      "description": "Messaggio leggibile.",
                      "type": "string"
                    },
                    "statusCode": {
                      "description": "Codice di stato HTTP ripetuto nel corpo.",
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Errore standard del backend.",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "description": "Errore standard del backend.",
                  "type": "object",
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ],
                  "properties": {
                    "code": {
                      "description": "Codice macchina dell’errore, quando disponibile.",
                      "type": "string"
                    },
                    "error": {
                      "description": "Etichetta breve dell’errore.",
                      "type": "string"
                    },
                    "message": {
                      "description": "Messaggio leggibile.",
                      "type": "string"
                    },
                    "statusCode": {
                      "description": "Codice di stato HTTP ripetuto nel corpo.",
                      "type": "integer"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/partner/links/{id}/qr.svg": {
      "get": {
        "operationId": "getPartnerLinkQrSVG",
        "summary": "QR della variante (svg)",
        "tags": [
          "partner"
        ],
        "description": "QR della variante in SVG, generato dal server. L’URL codificato porta sempre `?src=qr`: senza, il canale fiera è indistinguibile da qualunque altro click e il partner non può sapere se il QR ha funzionato. Il QR non viene mai generato dal client — in fiera il telefono può essere vecchio e la pagina servita in HTTP.",
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true,
            "description": "Id della variante del partner."
          }
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "QR code della variante, in formato svg.",
            "content": {
              "image/svg+xml": {
                "schema": {
                  "description": "QR code in formato svg.",
                  "type": "string"
                }
              }
            }
          },
          "401": {
            "description": "Sessione assente o scaduta.",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "description": "Errore standard del backend.",
                  "type": "object",
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ],
                  "properties": {
                    "code": {
                      "description": "Codice macchina dell’errore, quando disponibile.",
                      "type": "string"
                    },
                    "error": {
                      "description": "Etichetta breve dell’errore.",
                      "type": "string"
                    },
                    "message": {
                      "description": "Messaggio leggibile.",
                      "type": "string"
                    },
                    "statusCode": {
                      "description": "Codice di stato HTTP ripetuto nel corpo.",
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "La variante non appartiene al partner autenticato, oppure non esiste: stesso corpo.",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "description": "Errore standard del backend.",
                  "type": "object",
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ],
                  "properties": {
                    "code": {
                      "description": "Codice macchina dell’errore, quando disponibile.",
                      "type": "string"
                    },
                    "error": {
                      "description": "Etichetta breve dell’errore.",
                      "type": "string"
                    },
                    "message": {
                      "description": "Messaggio leggibile.",
                      "type": "string"
                    },
                    "statusCode": {
                      "description": "Codice di stato HTTP ripetuto nel corpo.",
                      "type": "integer"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/partner/links/{id}/qr.png": {
      "get": {
        "operationId": "getPartnerLinkQrPNG",
        "summary": "QR della variante (png)",
        "tags": [
          "partner"
        ],
        "description": "QR della variante in PNG, generato dal server. L’URL codificato porta sempre `?src=qr`: senza, il canale fiera è indistinguibile da qualunque altro click e il partner non può sapere se il QR ha funzionato. Il QR non viene mai generato dal client — in fiera il telefono può essere vecchio e la pagina servita in HTTP.",
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true,
            "description": "Id della variante del partner."
          }
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "QR code della variante, in formato png.",
            "content": {
              "image/png": {
                "schema": {
                  "description": "QR code in formato png.",
                  "type": "string"
                }
              }
            }
          },
          "401": {
            "description": "Sessione assente o scaduta.",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "description": "Errore standard del backend.",
                  "type": "object",
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ],
                  "properties": {
                    "code": {
                      "description": "Codice macchina dell’errore, quando disponibile.",
                      "type": "string"
                    },
                    "error": {
                      "description": "Etichetta breve dell’errore.",
                      "type": "string"
                    },
                    "message": {
                      "description": "Messaggio leggibile.",
                      "type": "string"
                    },
                    "statusCode": {
                      "description": "Codice di stato HTTP ripetuto nel corpo.",
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "La variante non appartiene al partner autenticato, oppure non esiste: stesso corpo.",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "description": "Errore standard del backend.",
                  "type": "object",
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ],
                  "properties": {
                    "code": {
                      "description": "Codice macchina dell’errore, quando disponibile.",
                      "type": "string"
                    },
                    "error": {
                      "description": "Etichetta breve dell’errore.",
                      "type": "string"
                    },
                    "message": {
                      "description": "Messaggio leggibile.",
                      "type": "string"
                    },
                    "statusCode": {
                      "description": "Codice di stato HTTP ripetuto nel corpo.",
                      "type": "integer"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/partner/slug/availability": {
      "get": {
        "operationId": "checkPartnerSlugAvailability",
        "summary": "Disponibilità di uno slug vanity",
        "tags": [
          "partner"
        ],
        "description": "Verifica se uno slug vanity è assegnabile. La risposta negativa non distingue MAI il motivo, e il frontend ha una sola copy per `available: false`. Il rate limit esiste perché anche una risposta indistinguibile, interrogata abbastanza in fretta, diventa un elenco.",
        "parameters": [
          {
            "schema": {
              "maxLength": 30,
              "minLength": 1,
              "type": "string"
            },
            "in": "query",
            "name": "slug",
            "required": true,
            "description": "Slug da verificare."
          }
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Disponibilità di uno slug vanity. La risposta negativa è UNA sola e non dice mai perché: distinguere «preso» da «riservato» trasformerebbe la rotta in un enumeratore di slug e di brand protetti (§4.6).",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "description": "Disponibilità di uno slug vanity. La risposta negativa è UNA sola e non dice mai perché: distinguere «preso» da «riservato» trasformerebbe la rotta in un enumeratore di slug e di brand protetti (§4.6).",
                  "type": "object",
                  "required": [
                    "available",
                    "suggestions"
                  ],
                  "properties": {
                    "available": {
                      "description": "false per QUALUNQUE motivo: preso, riservato, bloccato o malformato.",
                      "type": "boolean"
                    },
                    "suggestions": {
                      "description": "Sempre tre alternative, anche quando lo slug è disponibile.",
                      "type": "array",
                      "items": {
                        "description": "Alternativa disponibile.",
                        "type": "string"
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Errore standard del backend.",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "description": "Errore standard del backend.",
                  "type": "object",
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ],
                  "properties": {
                    "code": {
                      "description": "Codice macchina dell’errore, quando disponibile.",
                      "type": "string"
                    },
                    "error": {
                      "description": "Etichetta breve dell’errore.",
                      "type": "string"
                    },
                    "message": {
                      "description": "Messaggio leggibile.",
                      "type": "string"
                    },
                    "statusCode": {
                      "description": "Codice di stato HTTP ripetuto nel corpo.",
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Errore standard del backend.",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "description": "Errore standard del backend.",
                  "type": "object",
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ],
                  "properties": {
                    "code": {
                      "description": "Codice macchina dell’errore, quando disponibile.",
                      "type": "string"
                    },
                    "error": {
                      "description": "Etichetta breve dell’errore.",
                      "type": "string"
                    },
                    "message": {
                      "description": "Messaggio leggibile.",
                      "type": "string"
                    },
                    "statusCode": {
                      "description": "Codice di stato HTTP ripetuto nel corpo.",
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Errore standard del backend.",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "description": "Errore standard del backend.",
                  "type": "object",
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ],
                  "properties": {
                    "code": {
                      "description": "Codice macchina dell’errore, quando disponibile.",
                      "type": "string"
                    },
                    "error": {
                      "description": "Etichetta breve dell’errore.",
                      "type": "string"
                    },
                    "message": {
                      "description": "Messaggio leggibile.",
                      "type": "string"
                    },
                    "statusCode": {
                      "description": "Codice di stato HTTP ripetuto nel corpo.",
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "Errore standard del backend.",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "description": "Errore standard del backend.",
                  "type": "object",
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ],
                  "properties": {
                    "code": {
                      "description": "Codice macchina dell’errore, quando disponibile.",
                      "type": "string"
                    },
                    "error": {
                      "description": "Etichetta breve dell’errore.",
                      "type": "string"
                    },
                    "message": {
                      "description": "Messaggio leggibile.",
                      "type": "string"
                    },
                    "statusCode": {
                      "description": "Codice di stato HTTP ripetuto nel corpo.",
                      "type": "integer"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/partner/slug": {
      "post": {
        "operationId": "claimPartnerSlug",
        "summary": "Assegna uno slug vanity",
        "tags": [
          "partner"
        ],
        "description": "Assegna uno slug vanity nuovo e ritira il precedente. Gli alias sono STORICIZZATI e mai riassegnati: i link già pubblicati continuano a funzionare e la loro attribuzione non cambia. 409 quando lo slug non è assegnabile o quando le rinomine concesse nella finestra di 12 mesi sono esaurite.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "slug"
                ],
                "properties": {
                  "slug": {
                    "description": "Slug richiesto.",
                    "maxLength": 30,
                    "minLength": 3,
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Slug assegnato. Il precedente viene RITIRATO e mai riassegnato: i link già stampati continuano a funzionare per sempre, che è la promessa scritta nel dialog di rinomina.",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "description": "Slug assegnato. Il precedente viene RITIRATO e mai riassegnato: i link già stampati continuano a funzionare per sempre, che è la promessa scritta nel dialog di rinomina.",
                  "type": "object",
                  "required": [
                    "slug",
                    "url"
                  ],
                  "properties": {
                    "slug": {
                      "description": "Slug assegnato.",
                      "type": "string"
                    },
                    "url": {
                      "description": "URL pubblico già risolto.",
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Errore standard del backend.",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "description": "Errore standard del backend.",
                  "type": "object",
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ],
                  "properties": {
                    "code": {
                      "description": "Codice macchina dell’errore, quando disponibile.",
                      "type": "string"
                    },
                    "error": {
                      "description": "Etichetta breve dell’errore.",
                      "type": "string"
                    },
                    "message": {
                      "description": "Messaggio leggibile.",
                      "type": "string"
                    },
                    "statusCode": {
                      "description": "Codice di stato HTTP ripetuto nel corpo.",
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Errore standard del backend.",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "description": "Errore standard del backend.",
                  "type": "object",
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ],
                  "properties": {
                    "code": {
                      "description": "Codice macchina dell’errore, quando disponibile.",
                      "type": "string"
                    },
                    "error": {
                      "description": "Etichetta breve dell’errore.",
                      "type": "string"
                    },
                    "message": {
                      "description": "Messaggio leggibile.",
                      "type": "string"
                    },
                    "statusCode": {
                      "description": "Codice di stato HTTP ripetuto nel corpo.",
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Errore standard del backend.",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "description": "Errore standard del backend.",
                  "type": "object",
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ],
                  "properties": {
                    "code": {
                      "description": "Codice macchina dell’errore, quando disponibile.",
                      "type": "string"
                    },
                    "error": {
                      "description": "Etichetta breve dell’errore.",
                      "type": "string"
                    },
                    "message": {
                      "description": "Messaggio leggibile.",
                      "type": "string"
                    },
                    "statusCode": {
                      "description": "Codice di stato HTTP ripetuto nel corpo.",
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "Errore standard del backend.",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "description": "Errore standard del backend.",
                  "type": "object",
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ],
                  "properties": {
                    "code": {
                      "description": "Codice macchina dell’errore, quando disponibile.",
                      "type": "string"
                    },
                    "error": {
                      "description": "Etichetta breve dell’errore.",
                      "type": "string"
                    },
                    "message": {
                      "description": "Messaggio leggibile.",
                      "type": "string"
                    },
                    "statusCode": {
                      "description": "Codice di stato HTTP ripetuto nel corpo.",
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "Errore standard del backend.",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "description": "Errore standard del backend.",
                  "type": "object",
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ],
                  "properties": {
                    "code": {
                      "description": "Codice macchina dell’errore, quando disponibile.",
                      "type": "string"
                    },
                    "error": {
                      "description": "Etichetta breve dell’errore.",
                      "type": "string"
                    },
                    "message": {
                      "description": "Messaggio leggibile.",
                      "type": "string"
                    },
                    "statusCode": {
                      "description": "Codice di stato HTTP ripetuto nel corpo.",
                      "type": "integer"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/partner/traffic/links": {
      "get": {
        "operationId": "getPartnerTrafficByLink",
        "summary": "Traffico per variante di link",
        "tags": [
          "partner"
        ],
        "description": "Aggregato per variante sulla finestra richiesta. Il giorno corrente è sempre parziale e va etichettato come tale: un numero che cresce durante il giorno senza dirlo sembra un bug del conteggio.",
        "parameters": [
          {
            "schema": {
              "format": "date",
              "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}$",
              "type": "string"
            },
            "in": "query",
            "name": "from",
            "required": false,
            "description": "Inizio della finestra, incluso. Default: 90 giorni fa."
          },
          {
            "schema": {
              "format": "date",
              "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}$",
              "type": "string"
            },
            "in": "query",
            "name": "to",
            "required": false,
            "description": "Fine della finestra, inclusa. Default: oggi."
          },
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "query",
            "name": "link_id",
            "required": false,
            "description": "Filtra su una variante."
          }
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Asse Traffico per variante. È la dimensione GARANTITA in MVP: se qualcosa slitta, slitta il `sub_id`, mai questo tab.",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "description": "Asse Traffico per variante. È la dimensione GARANTITA in MVP: se qualcosa slitta, slitta il `sub_id`, mai questo tab.",
                  "type": "object",
                  "required": [
                    "as_of",
                    "partial_today",
                    "rows"
                  ],
                  "properties": {
                    "as_of": {
                      "description": "Istante del calcolo.",
                      "format": "date-time",
                      "type": "string"
                    },
                    "partial_today": {
                      "description": "Il giorno corrente è parziale: va etichettato come tale.",
                      "type": "boolean"
                    },
                    "rows": {
                      "description": "Righe aggregate per variante.",
                      "type": "array",
                      "items": {
                        "additionalProperties": false,
                        "description": "Una riga dell’asse Traffico: link o variante.",
                        "type": "object",
                        "required": [
                          "active_customers",
                          "clicks_valid",
                          "commission_minor",
                          "epc_minor",
                          "link_id",
                          "name",
                          "signups"
                        ],
                        "properties": {
                          "active_customers": {
                            "description": "Clienti paganti attribuiti a questa variante.",
                            "minimum": 0,
                            "type": "integer"
                          },
                          "clicks_valid": {
                            "description": "Click validi.",
                            "minimum": 0,
                            "type": "integer"
                          },
                          "commission_minor": {
                            "description": "Commissione maturata dalla variante. Minor units (centesimi) come stringa decimale.",
                            "pattern": "^-?[0-9]+$",
                            "type": "string"
                          },
                          "epc_minor": {
                            "description": "`null` con zero click.",
                            "anyOf": [
                              {
                                "description": "Guadagno per click valido. Minor units (centesimi) come stringa decimale.",
                                "pattern": "^-?[0-9]+$",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "link_id": {
                            "description": "Id della variante.",
                            "format": "uuid",
                            "type": "string"
                          },
                          "name": {
                            "description": "Nome della variante.",
                            "type": "string"
                          },
                          "signups": {
                            "description": "Iscritti.",
                            "minimum": 0,
                            "type": "integer"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Errore standard del backend.",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "description": "Errore standard del backend.",
                  "type": "object",
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ],
                  "properties": {
                    "code": {
                      "description": "Codice macchina dell’errore, quando disponibile.",
                      "type": "string"
                    },
                    "error": {
                      "description": "Etichetta breve dell’errore.",
                      "type": "string"
                    },
                    "message": {
                      "description": "Messaggio leggibile.",
                      "type": "string"
                    },
                    "statusCode": {
                      "description": "Codice di stato HTTP ripetuto nel corpo.",
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Errore standard del backend.",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "description": "Errore standard del backend.",
                  "type": "object",
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ],
                  "properties": {
                    "code": {
                      "description": "Codice macchina dell’errore, quando disponibile.",
                      "type": "string"
                    },
                    "error": {
                      "description": "Etichetta breve dell’errore.",
                      "type": "string"
                    },
                    "message": {
                      "description": "Messaggio leggibile.",
                      "type": "string"
                    },
                    "statusCode": {
                      "description": "Codice di stato HTTP ripetuto nel corpo.",
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Errore standard del backend.",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "description": "Errore standard del backend.",
                  "type": "object",
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ],
                  "properties": {
                    "code": {
                      "description": "Codice macchina dell’errore, quando disponibile.",
                      "type": "string"
                    },
                    "error": {
                      "description": "Etichetta breve dell’errore.",
                      "type": "string"
                    },
                    "message": {
                      "description": "Messaggio leggibile.",
                      "type": "string"
                    },
                    "statusCode": {
                      "description": "Codice di stato HTTP ripetuto nel corpo.",
                      "type": "integer"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/partner/traffic/sub-ids": {
      "get": {
        "operationId": "getPartnerTrafficBySubId",
        "summary": "Traffico per sub_id",
        "tags": [
          "partner"
        ],
        "description": "Ripartizione per `sub_id` sullo slot richiesto. Il raggruppamento avviene sulla chiave NORMALIZZATA (trim, casefold, separatori collassati): `Reel07`, `reel07` e `reel07 ` sono una riga sola. Oltre 200 valori distinti il server bucketizza il residuo e lo marca `bucketed`. Il k=5 non si applica: sono contenuti del partner, non demografia del referito.",
        "parameters": [
          {
            "schema": {
              "format": "date",
              "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}$",
              "type": "string"
            },
            "in": "query",
            "name": "from",
            "required": false,
            "description": "Inizio della finestra, incluso. Default: 90 giorni fa."
          },
          {
            "schema": {
              "format": "date",
              "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}$",
              "type": "string"
            },
            "in": "query",
            "name": "to",
            "required": false,
            "description": "Fine della finestra, inclusa. Default: oggi."
          },
          {
            "schema": {
              "maximum": 5,
              "minimum": 1,
              "type": "integer"
            },
            "in": "query",
            "name": "slot",
            "required": true,
            "description": "Slot 1..5."
          }
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Asse Contenuti. ⚠️ Il k=5 di §4.4 NON si applica qui: i `sub_id` sono tassonomia del partner sui propri contenuti, non demografia del referito — un `sub_id` con un solo click compare comunque.",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "description": "Asse Contenuti. ⚠️ Il k=5 di §4.4 NON si applica qui: i `sub_id` sono tassonomia del partner sui propri contenuti, non demografia del referito — un `sub_id` con un solo click compare comunque.",
                  "type": "object",
                  "required": [
                    "as_of",
                    "cardinality_threshold",
                    "distinct_count",
                    "rows",
                    "slot",
                    "truncated"
                  ],
                  "properties": {
                    "as_of": {
                      "description": "Istante del calcolo.",
                      "format": "date-time",
                      "type": "string"
                    },
                    "cardinality_threshold": {
                      "description": "Soglia di cardinalità per slot oltre la quale il server bucketizza.",
                      "minimum": 1,
                      "type": "integer"
                    },
                    "distinct_count": {
                      "description": "Valori distinti nello slot e nella finestra.",
                      "minimum": 0,
                      "type": "integer"
                    },
                    "rows": {
                      "description": "Righe per valore normalizzato di sub_id.",
                      "type": "array",
                      "items": {
                        "additionalProperties": false,
                        "type": "object",
                        "required": [
                          "active_customers",
                          "bucketed",
                          "clicks_valid",
                          "commission_minor",
                          "epc_minor",
                          "signups",
                          "sub_id"
                        ],
                        "properties": {
                          "active_customers": {
                            "description": "Clienti paganti.",
                            "minimum": 0,
                            "type": "integer"
                          },
                          "bucketed": {
                            "description": "La riga è il bucket residuo oltre la soglia di cardinalità.",
                            "type": "boolean"
                          },
                          "clicks_valid": {
                            "description": "Click validi.",
                            "minimum": 0,
                            "type": "integer"
                          },
                          "commission_minor": {
                            "description": "Commissione maturata. Minor units (centesimi) come stringa decimale.",
                            "pattern": "^-?[0-9]+$",
                            "type": "string"
                          },
                          "epc_minor": {
                            "description": "`null` con zero click.",
                            "anyOf": [
                              {
                                "description": "Guadagno per click valido. Minor units (centesimi) come stringa decimale.",
                                "pattern": "^-?[0-9]+$",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "signups": {
                            "description": "Iscritti.",
                            "minimum": 0,
                            "type": "integer"
                          },
                          "sub_id": {
                            "description": "Chiave NORMALIZZATA: trim, casefold, separatori collassati.",
                            "type": "string"
                          }
                        }
                      }
                    },
                    "slot": {
                      "description": "Slot richiesto, 1..5.",
                      "maximum": 5,
                      "minimum": 1,
                      "type": "integer"
                    },
                    "truncated": {
                      "description": "Almeno una riga è bucketizzata.",
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Errore standard del backend.",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "description": "Errore standard del backend.",
                  "type": "object",
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ],
                  "properties": {
                    "code": {
                      "description": "Codice macchina dell’errore, quando disponibile.",
                      "type": "string"
                    },
                    "error": {
                      "description": "Etichetta breve dell’errore.",
                      "type": "string"
                    },
                    "message": {
                      "description": "Messaggio leggibile.",
                      "type": "string"
                    },
                    "statusCode": {
                      "description": "Codice di stato HTTP ripetuto nel corpo.",
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Errore standard del backend.",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "description": "Errore standard del backend.",
                  "type": "object",
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ],
                  "properties": {
                    "code": {
                      "description": "Codice macchina dell’errore, quando disponibile.",
                      "type": "string"
                    },
                    "error": {
                      "description": "Etichetta breve dell’errore.",
                      "type": "string"
                    },
                    "message": {
                      "description": "Messaggio leggibile.",
                      "type": "string"
                    },
                    "statusCode": {
                      "description": "Codice di stato HTTP ripetuto nel corpo.",
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Errore standard del backend.",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "description": "Errore standard del backend.",
                  "type": "object",
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ],
                  "properties": {
                    "code": {
                      "description": "Codice macchina dell’errore, quando disponibile.",
                      "type": "string"
                    },
                    "error": {
                      "description": "Etichetta breve dell’errore.",
                      "type": "string"
                    },
                    "message": {
                      "description": "Messaggio leggibile.",
                      "type": "string"
                    },
                    "statusCode": {
                      "description": "Codice di stato HTTP ripetuto nel corpo.",
                      "type": "integer"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/partner/referrals": {
      "get": {
        "operationId": "listPartnerReferrals",
        "summary": "Tabella Persone del partner",
        "tags": [
          "partner"
        ],
        "description": "Tabella Persone, paginata a cursore. I campi identitari escono SOLO con consenso attivo del referito E profilo pubblico del partner approvato (regola dell’identità reciproca, §4.5); altrimenti sono assenti dal JSON e i loro nomi compaiono in `covered_fields`. L’email mascherata esiste solo sul Binario A.",
        "parameters": [
          {
            "schema": {
              "format": "date",
              "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}$",
              "type": "string"
            },
            "in": "query",
            "name": "from",
            "required": false,
            "description": "Inizio della finestra, incluso. Default: 90 giorni fa."
          },
          {
            "schema": {
              "format": "date",
              "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}$",
              "type": "string"
            },
            "in": "query",
            "name": "to",
            "required": false,
            "description": "Fine della finestra, inclusa. Default: oggi."
          },
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "query",
            "name": "cursor",
            "required": false,
            "description": "Cursore restituito dalla pagina precedente."
          },
          {
            "schema": {
              "maximum": 200,
              "minimum": 1,
              "type": "integer"
            },
            "in": "query",
            "name": "limit",
            "required": false,
            "description": "Righe per pagina, massimo 200."
          },
          {
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "enum": [
                    "signed_up"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "trialing"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "customer"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "lost"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "void"
                  ]
                }
              ]
            },
            "in": "query",
            "name": "status",
            "required": false,
            "description": "Filtro di stato."
          }
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Pagina della tabella Persone, ordinata per data di iscrizione decrescente.",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "description": "Pagina della tabella Persone, ordinata per data di iscrizione decrescente.",
                  "type": "object",
                  "required": [
                    "has_more",
                    "next_cursor",
                    "rows"
                  ],
                  "properties": {
                    "has_more": {
                      "description": "Esiste almeno un’altra pagina.",
                      "type": "boolean"
                    },
                    "next_cursor": {
                      "description": "Cursore della pagina successiva.",
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "rows": {
                      "description": "Righe della pagina.",
                      "type": "array",
                      "items": {
                        "additionalProperties": false,
                        "description": "Una riga della tabella Persone (§4.4). I campi identitari sono ASSENTI quando non sono visibili, mai `null`.",
                        "type": "object",
                        "required": [
                          "can_request_intro",
                          "consent_state",
                          "covered_fields",
                          "customer_since",
                          "origin_link_name",
                          "origin_sub_id",
                          "reference",
                          "signed_up_on",
                          "status"
                        ],
                        "properties": {
                          "can_request_intro": {
                            "description": "La richiesta di presentazione è proponibile su questa riga.",
                            "type": "boolean"
                          },
                          "capped_by_monthly_cap": {
                            "description": "Il cap mensile ha morso su questa base.",
                            "type": "boolean"
                          },
                          "city": {
                            "description": "Città. Presente SOLO a identità disvelata.",
                            "type": "string"
                          },
                          "commission_book": {
                            "description": "commission | acquisition.",
                            "type": "string"
                          },
                          "commission_rate_bp": {
                            "description": "Aliquota CONGELATA sulla riga, in basis point.",
                            "type": "integer"
                          },
                          "commission_status": {
                            "description": "Stato della commissione più recente.",
                            "type": "string"
                          },
                          "commission_unlock_on": {
                            "description": "`null` se non in hold.",
                            "anyOf": [
                              {
                                "description": "Data di sblocco prevista.",
                                "format": "date",
                                "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}$",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "commissionable_base_cumulative_minor": {
                            "description": "Base commissionabile cumulata sul rapporto. Minor units (centesimi) come stringa decimale.",
                            "pattern": "^-?[0-9]+$",
                            "type": "string"
                          },
                          "commissionable_base_minor": {
                            "description": "Base commissionabile del mese, già cappata. Minor units (centesimi) come stringa decimale.",
                            "pattern": "^-?[0-9]+$",
                            "type": "string"
                          },
                          "company": {
                            "description": "Azienda. Presente SOLO a identità disvelata.",
                            "type": "string"
                          },
                          "consent_state": {
                            "description": "anonymous | covered | identified.",
                            "type": "string"
                          },
                          "contact_class": {
                            "description": "Classe di contatto. Assente quando il referito si è opposto.",
                            "anyOf": [
                              {
                                "type": "string",
                                "enum": [
                                  "azienda"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "freelance"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "privato"
                                ]
                              }
                            ]
                          },
                          "contact_masked": {
                            "description": "Email mascherata `x•••@•••.tld`. SOLO Binario A: sul B non esiste (§4.4).",
                            "type": "string"
                          },
                          "covered_fields": {
                            "description": "Campi che esistono ma sono coperti: è ciò che permette la copy «visibile se il cliente acconsente».",
                            "type": "array",
                            "items": {
                              "description": "Nome del campo coperto.",
                              "type": "string"
                            }
                          },
                          "currency": {
                            "description": "Valuta degli importi della riga.",
                            "type": "string"
                          },
                          "customer_since": {
                            "description": "Giorno, mai l’ora.",
                            "anyOf": [
                              {
                                "description": "Cliente dal.",
                                "format": "date",
                                "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}$",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "gross_invoice_minor": {
                            "description": "Imponibile della fattura, prima del cap. Minor units (centesimi) come stringa decimale.",
                            "pattern": "^-?[0-9]+$",
                            "type": "string"
                          },
                          "name": {
                            "description": "Nome e cognome. Presente SOLO a identità disvelata.",
                            "type": "string"
                          },
                          "origin_link_name": {
                            "description": "Variante di provenienza.",
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "origin_sub_id": {
                            "description": "Sub_id che ha vinto l’attribuzione. Esce sempre, anche a riga coperta: è tassonomia del partner sui propri contenuti, non un dato del referito.",
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "plan": {
                            "description": "Piano del referito. Presente SOLO su una riga con almeno un accrual (§4.4 riga 10).",
                            "type": "string"
                          },
                          "reference": {
                            "description": "ID OPACO del referito. Sopravvive alla cancellazione dell’identity map.",
                            "type": "string"
                          },
                          "signed_up_on": {
                            "description": "Iscritto il. Giorno, mai l’ora: l’ora è un dato comportamentale.",
                            "format": "date",
                            "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}$",
                            "type": "string"
                          },
                          "status": {
                            "description": "signed_up | trialing | customer | lost | void.",
                            "type": "string"
                          },
                          "unattributed_reason": {
                            "description": "L’UNICO motivo esposto sulla riga persona, qualunque sia la causa interna (§4.4).",
                            "type": "string",
                            "enum": [
                              "non_attribuibile"
                            ]
                          },
                          "accrual_closed": {
                            "description": "La MATURAZIONE è finita, anche se la finestra di attribuzione è ancora aperta. `true` quando `window_month > accrual_months`: è il campo che rende leggibile un countdown che scorre mentre il saldo non si muove più.",
                            "type": "boolean"
                          },
                          "accrual_months": {
                            "description": "I mesi che maturano DAVVERO (`full_months + tail_months` di `GET /partner/calculator`): 12 a coda spenta, `attribution_window_months` a coda accesa. Sempre ≤ `window_total`.",
                            "minimum": 1,
                            "type": "integer"
                          },
                          "window_closed": {
                            "description": "Finestra di attribuzione chiusa.",
                            "type": "boolean"
                          },
                          "window_month": {
                            "description": "Mese corrente della finestra, a partire da 1.",
                            "minimum": 1,
                            "type": "integer"
                          },
                          "window_total": {
                            "description": "Durata totale della finestra di ATTRIBUZIONE, in mesi. Non è ciò che matura.",
                            "minimum": 1,
                            "type": "integer"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Errore standard del backend.",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "description": "Errore standard del backend.",
                  "type": "object",
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ],
                  "properties": {
                    "code": {
                      "description": "Codice macchina dell’errore, quando disponibile.",
                      "type": "string"
                    },
                    "error": {
                      "description": "Etichetta breve dell’errore.",
                      "type": "string"
                    },
                    "message": {
                      "description": "Messaggio leggibile.",
                      "type": "string"
                    },
                    "statusCode": {
                      "description": "Codice di stato HTTP ripetuto nel corpo.",
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Errore standard del backend.",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "description": "Errore standard del backend.",
                  "type": "object",
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ],
                  "properties": {
                    "code": {
                      "description": "Codice macchina dell’errore, quando disponibile.",
                      "type": "string"
                    },
                    "error": {
                      "description": "Etichetta breve dell’errore.",
                      "type": "string"
                    },
                    "message": {
                      "description": "Messaggio leggibile.",
                      "type": "string"
                    },
                    "statusCode": {
                      "description": "Codice di stato HTTP ripetuto nel corpo.",
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Errore standard del backend.",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "description": "Errore standard del backend.",
                  "type": "object",
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ],
                  "properties": {
                    "code": {
                      "description": "Codice macchina dell’errore, quando disponibile.",
                      "type": "string"
                    },
                    "error": {
                      "description": "Etichetta breve dell’errore.",
                      "type": "string"
                    },
                    "message": {
                      "description": "Messaggio leggibile.",
                      "type": "string"
                    },
                    "statusCode": {
                      "description": "Codice di stato HTTP ripetuto nel corpo.",
                      "type": "integer"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/partner/referrals/{ref}/timeline": {
      "get": {
        "operationId": "getPartnerReferralTimeline",
        "summary": "Timeline di un referral",
        "tags": [
          "partner"
        ],
        "description": "Timeline di un singolo referral: stati e movimenti, con il solo giorno. Un `ref` di un altro partner risponde 403 con lo stesso corpo di uno inesistente.",
        "parameters": [
          {
            "schema": {
              "maxLength": 12,
              "minLength": 8,
              "type": "string"
            },
            "in": "path",
            "name": "ref",
            "required": true,
            "description": "ID opaco del referito (`public_ref`)."
          }
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Timeline di un singolo referral.",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "description": "Timeline di un singolo referral.",
                  "type": "object",
                  "required": [
                    "events",
                    "reference"
                  ],
                  "properties": {
                    "events": {
                      "description": "Eventi in ordine cronologico. Solo il giorno: l’ora è concessa solo a T1 e qui mai.",
                      "type": "array",
                      "items": {
                        "additionalProperties": false,
                        "type": "object",
                        "required": [
                          "amount_minor",
                          "date",
                          "kind"
                        ],
                        "properties": {
                          "amount_minor": {
                            "description": "`null` sugli eventi di stato.",
                            "anyOf": [
                              {
                                "description": "Importo dell’evento. Minor units (centesimi) come stringa decimale.",
                                "pattern": "^-?[0-9]+$",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "date": {
                            "description": "Giorno dell’evento.",
                            "format": "date",
                            "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}$",
                            "type": "string"
                          },
                          "kind": {
                            "description": "signed_up | trial_started | became_customer | first_payment | churned | commission_*.",
                            "type": "string"
                          }
                        }
                      }
                    },
                    "reference": {
                      "description": "ID opaco del referito.",
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Errore standard del backend.",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "description": "Errore standard del backend.",
                  "type": "object",
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ],
                  "properties": {
                    "code": {
                      "description": "Codice macchina dell’errore, quando disponibile.",
                      "type": "string"
                    },
                    "error": {
                      "description": "Etichetta breve dell’errore.",
                      "type": "string"
                    },
                    "message": {
                      "description": "Messaggio leggibile.",
                      "type": "string"
                    },
                    "statusCode": {
                      "description": "Codice di stato HTTP ripetuto nel corpo.",
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Errore standard del backend.",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "description": "Errore standard del backend.",
                  "type": "object",
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ],
                  "properties": {
                    "code": {
                      "description": "Codice macchina dell’errore, quando disponibile.",
                      "type": "string"
                    },
                    "error": {
                      "description": "Etichetta breve dell’errore.",
                      "type": "string"
                    },
                    "message": {
                      "description": "Messaggio leggibile.",
                      "type": "string"
                    },
                    "statusCode": {
                      "description": "Codice di stato HTTP ripetuto nel corpo.",
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Errore standard del backend.",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "description": "Errore standard del backend.",
                  "type": "object",
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ],
                  "properties": {
                    "code": {
                      "description": "Codice macchina dell’errore, quando disponibile.",
                      "type": "string"
                    },
                    "error": {
                      "description": "Etichetta breve dell’errore.",
                      "type": "string"
                    },
                    "message": {
                      "description": "Messaggio leggibile.",
                      "type": "string"
                    },
                    "statusCode": {
                      "description": "Codice di stato HTTP ripetuto nel corpo.",
                      "type": "integer"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/partner/referrals/{ref}/request-introduction": {
      "post": {
        "operationId": "requestPartnerIntroduction",
        "summary": "Chiedi di essere presentato al referito",
        "tags": [
          "partner"
        ],
        "description": "Chiede al referito il permesso di essere presentato. Risponde 202 senza corpo informativo e NON restituisce mai lo stato della risposta: «rifiutato» e «non ancora risposto» producono lo stesso JSON, perché una differenza osservabile sarebbe un oracolo sul rifiuto di una persona. La seconda richiesta sulla stessa riga risponde 409: eseguibile una volta sola, per sempre. Solo notifica in-app, mai email.",
        "parameters": [
          {
            "schema": {
              "maxLength": 12,
              "minLength": 8,
              "type": "string"
            },
            "in": "path",
            "name": "ref",
            "required": true,
            "description": "ID opaco del referito (`public_ref`)."
          }
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "202": {
            "description": "Richiesta presa in carico. Nessun corpo informativo.",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "description": "Richiesta presa in carico. Nessun corpo informativo.",
                  "type": "object",
                  "properties": {}
                }
              }
            }
          },
          "400": {
            "description": "Errore standard del backend.",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "description": "Errore standard del backend.",
                  "type": "object",
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ],
                  "properties": {
                    "code": {
                      "description": "Codice macchina dell’errore, quando disponibile.",
                      "type": "string"
                    },
                    "error": {
                      "description": "Etichetta breve dell’errore.",
                      "type": "string"
                    },
                    "message": {
                      "description": "Messaggio leggibile.",
                      "type": "string"
                    },
                    "statusCode": {
                      "description": "Codice di stato HTTP ripetuto nel corpo.",
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Errore standard del backend.",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "description": "Errore standard del backend.",
                  "type": "object",
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ],
                  "properties": {
                    "code": {
                      "description": "Codice macchina dell’errore, quando disponibile.",
                      "type": "string"
                    },
                    "error": {
                      "description": "Etichetta breve dell’errore.",
                      "type": "string"
                    },
                    "message": {
                      "description": "Messaggio leggibile.",
                      "type": "string"
                    },
                    "statusCode": {
                      "description": "Codice di stato HTTP ripetuto nel corpo.",
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Errore standard del backend.",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "description": "Errore standard del backend.",
                  "type": "object",
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ],
                  "properties": {
                    "code": {
                      "description": "Codice macchina dell’errore, quando disponibile.",
                      "type": "string"
                    },
                    "error": {
                      "description": "Etichetta breve dell’errore.",
                      "type": "string"
                    },
                    "message": {
                      "description": "Messaggio leggibile.",
                      "type": "string"
                    },
                    "statusCode": {
                      "description": "Codice di stato HTTP ripetuto nel corpo.",
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "Errore standard del backend.",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "description": "Errore standard del backend.",
                  "type": "object",
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ],
                  "properties": {
                    "code": {
                      "description": "Codice macchina dell’errore, quando disponibile.",
                      "type": "string"
                    },
                    "error": {
                      "description": "Etichetta breve dell’errore.",
                      "type": "string"
                    },
                    "message": {
                      "description": "Messaggio leggibile.",
                      "type": "string"
                    },
                    "statusCode": {
                      "description": "Codice di stato HTTP ripetuto nel corpo.",
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "Errore standard del backend.",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "description": "Errore standard del backend.",
                  "type": "object",
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ],
                  "properties": {
                    "code": {
                      "description": "Codice macchina dell’errore, quando disponibile.",
                      "type": "string"
                    },
                    "error": {
                      "description": "Etichetta breve dell’errore.",
                      "type": "string"
                    },
                    "message": {
                      "description": "Messaggio leggibile.",
                      "type": "string"
                    },
                    "statusCode": {
                      "description": "Codice di stato HTTP ripetuto nel corpo.",
                      "type": "integer"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/partner/unattributed": {
      "get": {
        "operationId": "getPartnerUnattributedClicks",
        "summary": "Click non attribuiti, aggregati",
        "tags": [
          "partner"
        ],
        "description": "Click non attribuiti nella finestra: totale sempre visibile, classi di motivo solo con k≥5. Serve al partner per capire se sta perdendo traffico per bot, prefetch o duplicati — senza che quel dettaglio diventi un profilo delle persone che hanno cliccato.",
        "parameters": [
          {
            "schema": {
              "format": "date",
              "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}$",
              "type": "string"
            },
            "in": "query",
            "name": "from",
            "required": false,
            "description": "Inizio della finestra, incluso. Default: 90 giorni fa."
          },
          {
            "schema": {
              "format": "date",
              "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}$",
              "type": "string"
            },
            "in": "query",
            "name": "to",
            "required": false,
            "description": "Fine della finestra, inclusa. Default: oggi."
          }
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Click non attribuiti, aggregati. `total` NON coincide con la somma di `reasons`, ed è corretto: sotto la soglia di k-anonimato il conteggio per classe identificherebbe la singola persona dietro il click.",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "description": "Click non attribuiti, aggregati. `total` NON coincide con la somma di `reasons`, ed è corretto: sotto la soglia di k-anonimato il conteggio per classe identificherebbe la singola persona dietro il click.",
                  "type": "object",
                  "required": [
                    "reasons",
                    "total"
                  ],
                  "properties": {
                    "reasons": {
                      "description": "Classi con k≥5. Il residuo confluisce in `altro`, che esce solo se raggiunge k a sua volta.",
                      "type": "array",
                      "items": {
                        "additionalProperties": false,
                        "type": "object",
                        "required": [
                          "class",
                          "count"
                        ],
                        "properties": {
                          "class": {
                            "description": "Classe di motivo, oppure `altro` per il residuo aggregato.",
                            "type": "string"
                          },
                          "count": {
                            "description": "Numerosità della classe, sempre ≥ 5.",
                            "minimum": 0,
                            "type": "integer"
                          }
                        }
                      }
                    },
                    "total": {
                      "description": "Totale dei click non attribuiti nella finestra. Si mostra sempre.",
                      "minimum": 0,
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Errore standard del backend.",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "description": "Errore standard del backend.",
                  "type": "object",
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ],
                  "properties": {
                    "code": {
                      "description": "Codice macchina dell’errore, quando disponibile.",
                      "type": "string"
                    },
                    "error": {
                      "description": "Etichetta breve dell’errore.",
                      "type": "string"
                    },
                    "message": {
                      "description": "Messaggio leggibile.",
                      "type": "string"
                    },
                    "statusCode": {
                      "description": "Codice di stato HTTP ripetuto nel corpo.",
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Errore standard del backend.",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "description": "Errore standard del backend.",
                  "type": "object",
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ],
                  "properties": {
                    "code": {
                      "description": "Codice macchina dell’errore, quando disponibile.",
                      "type": "string"
                    },
                    "error": {
                      "description": "Etichetta breve dell’errore.",
                      "type": "string"
                    },
                    "message": {
                      "description": "Messaggio leggibile.",
                      "type": "string"
                    },
                    "statusCode": {
                      "description": "Codice di stato HTTP ripetuto nel corpo.",
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Errore standard del backend.",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "description": "Errore standard del backend.",
                  "type": "object",
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ],
                  "properties": {
                    "code": {
                      "description": "Codice macchina dell’errore, quando disponibile.",
                      "type": "string"
                    },
                    "error": {
                      "description": "Etichetta breve dell’errore.",
                      "type": "string"
                    },
                    "message": {
                      "description": "Messaggio leggibile.",
                      "type": "string"
                    },
                    "statusCode": {
                      "description": "Codice di stato HTTP ripetuto nel corpo.",
                      "type": "integer"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/pixels/{pixelId}/toggle": {
      "post": {
        "operationId": "postApiV1PixelsByPixelIdToggle",
        "summary": "Toggle pixel connected flag",
        "tags": [
          "pixels"
        ],
        "description": "Marks the pixel as connected/disconnected for the given business. Does not touch Meta API. The write is scoped to the active workspace (team rows + legacy NULL-team rows owned by an accessible session): pixels outside the active scope are not affected.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "business_id",
                  "connected"
                ],
                "properties": {
                  "business_id": {
                    "type": "string"
                  },
                  "connected": {
                    "type": "boolean"
                  },
                  "platform": {
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "in": "path",
            "name": "pixelId",
            "required": true
          },
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "header",
            "name": "x-team-id",
            "required": false,
            "description": "Explicit team (workspace) scope: a team.id the caller belongs to."
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "header",
            "name": "x-active-scope",
            "required": false,
            "description": "Active scope selector in `<scopeType>:<uuid>` form, e.g. `organization:<organization_id>` or `team:<team_id>`. Omit the header for the all-workspaces view."
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "connected"
                  ],
                  "properties": {
                    "connected": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/pixels/{pixelId}/accounts": {
      "get": {
        "operationId": "getApiV1PixelsByPixelIdAccounts",
        "summary": "List pixel-to-ad-account links",
        "tags": [
          "pixels"
        ],
        "description": "Returns configured ad-account links for the given pixel within the specified business. The pixel is resolved within the active workspace scope (team rows + legacy NULL-team rows owned by an accessible session).",
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "business_id",
            "required": true
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "path",
            "name": "pixelId",
            "required": true
          },
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "header",
            "name": "x-team-id",
            "required": false,
            "description": "Explicit team (workspace) scope: a team.id the caller belongs to."
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "header",
            "name": "x-active-scope",
            "required": false,
            "description": "Active scope selector in `<scopeType>:<uuid>` form, e.g. `organization:<organization_id>` or `team:<team_id>`. Omit the header for the all-workspaces view."
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "accounts"
                  ],
                  "properties": {
                    "accounts": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "ad_account_id",
                          "ad_account_name",
                          "status",
                          "error_message"
                        ],
                        "properties": {
                          "ad_account_id": {
                            "type": "string"
                          },
                          "ad_account_name": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "status": {
                            "description": "Link state: pending | validated | failed.",
                            "type": "string"
                          },
                          "error_message": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      },
      "patch": {
        "operationId": "patchApiV1PixelsByPixelIdAccounts",
        "summary": "Configure pixel-to-ad-account links",
        "tags": [
          "pixels"
        ],
        "description": "Persists the desired list of ad_account_ids linked to a pixel. Same-business-manager links are marked validated directly; cross-BM links start as pending and trigger Meta API reconciliation when the pixel is already connected. The target pixel is resolved within the active workspace scope (team rows + legacy NULL-team rows owned by an accessible session): pixels outside the active scope cannot be configured.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "business_id",
                  "account_ids"
                ],
                "properties": {
                  "business_id": {
                    "type": "string"
                  },
                  "account_ids": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "in": "path",
            "name": "pixelId",
            "required": true
          },
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "header",
            "name": "x-team-id",
            "required": false,
            "description": "Explicit team (workspace) scope: a team.id the caller belongs to."
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "header",
            "name": "x-active-scope",
            "required": false,
            "description": "Active scope selector in `<scopeType>:<uuid>` form, e.g. `organization:<organization_id>` or `team:<team_id>`. Omit the header for the all-workspaces view."
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "configured",
                    "will_reconcile"
                  ],
                  "properties": {
                    "configured": {
                      "minimum": 0,
                      "type": "integer"
                    },
                    "will_reconcile": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/pixels": {
      "get": {
        "operationId": "listPixels",
        "summary": "Get pixels for the active workspace (server-side paginated)",
        "tags": [
          "pixels"
        ],
        "description": "Returns a server-side paginated, filtered, sorted list of pixels/conversion actions (Meta, Google, TikTok) scoped to the active workspace: rows whose `team_id` belongs to the accessible team set (narrowed by `x-team-id` / `x-active-scope`), plus legacy rows without `team_id` owned by an accessible session. Supports offset pagination, free-text search, business filter, assigned/unassigned filter, and creation date range. Response items embed ad-account counts from `pixel_ad_account_link` and optional member/team info for admin roles.",
        "parameters": [
          {
            "schema": {
              "minimum": 1,
              "maximum": 200,
              "default": 50,
              "type": "integer"
            },
            "in": "query",
            "name": "limit",
            "required": false
          },
          {
            "schema": {
              "minimum": 0,
              "default": 0,
              "type": "integer"
            },
            "in": "query",
            "name": "offset",
            "required": false
          },
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "query",
            "name": "member_id",
            "required": false
          },
          {
            "schema": {
              "type": "boolean"
            },
            "in": "query",
            "name": "connected",
            "required": false
          },
          {
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "enum": [
                    "pixel_name"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "business_name"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "connected"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "created_at"
                  ]
                }
              ]
            },
            "in": "query",
            "name": "sort_by",
            "required": false
          },
          {
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "enum": [
                    "asc"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "desc"
                  ]
                }
              ]
            },
            "in": "query",
            "name": "sort_order",
            "required": false
          },
          {
            "schema": {
              "minLength": 2,
              "maxLength": 500,
              "type": "string"
            },
            "in": "query",
            "name": "search",
            "required": false
          },
          {
            "schema": {
              "maxLength": 100,
              "type": "string"
            },
            "in": "query",
            "name": "business_id",
            "required": false
          },
          {
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "enum": [
                    "assigned"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "unassigned"
                  ]
                }
              ]
            },
            "in": "query",
            "name": "assigned",
            "required": false
          },
          {
            "schema": {
              "format": "date-time",
              "type": "string"
            },
            "in": "query",
            "name": "created_from",
            "required": false
          },
          {
            "schema": {
              "format": "date-time",
              "type": "string"
            },
            "in": "query",
            "name": "created_to",
            "required": false
          },
          {
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "enum": [
                    "meta"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "google"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "tiktok"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "all"
                  ]
                }
              ]
            },
            "in": "query",
            "name": "platform",
            "required": false
          },
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "header",
            "name": "x-team-id",
            "required": false,
            "description": "Explicit team (workspace) scope: a team.id the caller belongs to."
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "header",
            "name": "x-active-scope",
            "required": false,
            "description": "Active scope selector in `<scopeType>:<uuid>` form, e.g. `organization:<organization_id>` or `team:<team_id>`. Omit the header for the all-workspaces view."
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "items",
                    "total",
                    "counts"
                  ],
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "id",
                          "pixel_id",
                          "pixel_name",
                          "business_id",
                          "business_name",
                          "connected",
                          "meta_ad_accounts",
                          "validated_ad_accounts",
                          "ad_account_count",
                          "validated_count",
                          "pending_count",
                          "created_at",
                          "updated_at"
                        ],
                        "properties": {
                          "id": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "pixel_id": {
                            "description": "Meta Pixel numeric id (as string).",
                            "type": "string"
                          },
                          "pixel_name": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "business_id": {
                            "description": "Meta Business Manager id that owns the pixel.",
                            "type": "string"
                          },
                          "business_name": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "connected": {
                            "description": "True when at least one ad account is validated (linked and usable) for this pixel.",
                            "type": "boolean"
                          },
                          "meta_ad_accounts": {
                            "description": "All ad accounts associated with the pixel (validated + pending). Denormalized from `pixel_ad_account_link`. Meta Graph v25.0 pass-through.",
                            "anyOf": [
                              {
                                "type": "array",
                                "items": {
                                  "description": "Meta Graph v25.0 pass-through: ad-account descriptor stored on the pixel. Canonical fields: `id` (Meta ad account id, e.g. \"act_1234\") and `name` (display name). Additional fields may be present.",
                                  "type": "object",
                                  "additionalProperties": {
                                    "$comment": "json-value",
                                    "description": "Arbitrary JSON value with nested arrays and objects."
                                  }
                                }
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "validated_ad_accounts": {
                            "description": "Subset of `meta_ad_accounts` that successfully validated against Meta. Meta Graph v25.0 pass-through.",
                            "anyOf": [
                              {
                                "type": "array",
                                "items": {
                                  "description": "Meta Graph v25.0 pass-through: ad-account descriptor stored on the pixel. Canonical fields: `id` (Meta ad account id, e.g. \"act_1234\") and `name` (display name). Additional fields may be present.",
                                  "type": "object",
                                  "additionalProperties": {
                                    "$comment": "json-value",
                                    "description": "Arbitrary JSON value with nested arrays and objects."
                                  }
                                }
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "ad_account_count": {
                            "description": "Total linked ad accounts (validated + pending).",
                            "type": "integer"
                          },
                          "validated_count": {
                            "description": "Ad accounts with validation status = validated.",
                            "type": "integer"
                          },
                          "pending_count": {
                            "description": "Ad accounts still awaiting validation.",
                            "type": "integer"
                          },
                          "created_at": {
                            "format": "date-time",
                            "type": "string"
                          },
                          "updated_at": {
                            "anyOf": [
                              {
                                "format": "date-time",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "sheet_id": {
                            "type": "string"
                          },
                          "member_name": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "member_email": {
                            "type": "string"
                          },
                          "team_name": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "platform": {
                            "type": "string"
                          }
                        }
                      }
                    },
                    "total": {
                      "type": "integer"
                    },
                    "counts": {
                      "type": "object",
                      "required": [
                        "total",
                        "connected",
                        "disconnected",
                        "assigned"
                      ],
                      "properties": {
                        "total": {
                          "type": "integer"
                        },
                        "connected": {
                          "type": "integer"
                        },
                        "disconnected": {
                          "type": "integer"
                        },
                        "assigned": {
                          "type": "integer"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/pixels/businesses": {
      "get": {
        "operationId": "listPixelBusinesses",
        "summary": "List businesses available for pixel filters",
        "tags": [
          "pixels"
        ],
        "description": "Returns the distinct list of Meta Business Managers that own at least one pixel visible in the active workspace (team-scoped via `x-team-id` / `x-active-scope`, with legacy NULL-team rows visible to their owning session), used to populate the `business_id` filter dropdown on `GET /api/v1/pixels`.",
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "header",
            "name": "x-team-id",
            "required": false,
            "description": "Explicit team (workspace) scope: a team.id the caller belongs to."
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "header",
            "name": "x-active-scope",
            "required": false,
            "description": "Active scope selector in `<scopeType>:<uuid>` form, e.g. `organization:<organization_id>` or `team:<team_id>`. Omit the header for the all-workspaces view."
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "items"
                  ],
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "id",
                          "name"
                        ],
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "name": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/platforms/connections/stats": {
      "get": {
        "operationId": "getPlatformConnectionsStats",
        "summary": "Aggregated connection stats per platform",
        "tags": [
          "platforms"
        ],
        "description": "Returns the count of total / connected ad accounts grouped by platform for the caller active workspace scope. Combines `platform_connection` rows (Google / TikTok / Taboola) with the legacy `meta_ad_account` table.",
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Map of platform → { total, connected }. Keys observed in production: `meta`, `google`, `tiktok`, `taboola`. Additional platforms may appear over time.",
            "content": {
              "application/json": {
                "schema": {
                  "description": "Map of platform → { total, connected }. Keys observed in production: `meta`, `google`, `tiktok`, `taboola`. Additional platforms may appear over time.",
                  "type": "object",
                  "additionalProperties": {
                    "additionalProperties": false,
                    "type": "object",
                    "required": [
                      "total",
                      "connected"
                    ],
                    "properties": {
                      "total": {
                        "minimum": 0,
                        "type": "integer"
                      },
                      "connected": {
                        "minimum": 0,
                        "type": "integer"
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/platform-knowledge": {
      "get": {
        "operationId": "listPlatformKnowledge",
        "summary": "List platform knowledge entries",
        "tags": [
          "platform-knowledge"
        ],
        "description": "Admin-only list of active platform knowledge entries (features, changelog, FAQ, limitations) used to augment the Claude chat system prompt. Results are filtered to `is_active = true` and ordered by `category` then `priority` descending. The optional `category` query narrows to a single bucket. Restricted to roles `admin` and `super_admin`.",
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "category",
            "required": false
          }
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "items"
                  ],
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "id",
                          "category",
                          "slug",
                          "title",
                          "content",
                          "tags",
                          "priority",
                          "is_active",
                          "valid_from",
                          "valid_until",
                          "created_at",
                          "updated_at"
                        ],
                        "properties": {
                          "id": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "category": {
                            "type": "string"
                          },
                          "slug": {
                            "type": "string"
                          },
                          "title": {
                            "type": "string"
                          },
                          "content": {
                            "type": "string"
                          },
                          "tags": {
                            "type": "array",
                            "items": {
                              "type": "string"
                            }
                          },
                          "priority": {
                            "type": "integer"
                          },
                          "is_active": {
                            "type": "boolean"
                          },
                          "valid_from": {
                            "anyOf": [
                              {
                                "format": "date-time",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "valid_until": {
                            "anyOf": [
                              {
                                "format": "date-time",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "created_at": {
                            "format": "date-time",
                            "type": "string"
                          },
                          "updated_at": {
                            "format": "date-time",
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "createPlatformKnowledge",
        "summary": "Create platform knowledge entry",
        "tags": [
          "platform-knowledge"
        ],
        "description": "Create a new platform knowledge entry. The `category` must be one of `feature`, `changelog`, `faq`, `limitation`. `slug` is globally unique - a collision returns 409. `priority` defaults to 50. `valid_from`/`valid_until` gate visibility in the Claude chat prompt. Creating a new entry invalidates the in-memory prompt-section cache so the change is reflected on the next chat request. Restricted to roles `admin` and `super_admin`.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "category",
                  "slug",
                  "title",
                  "content"
                ],
                "properties": {
                  "category": {
                    "anyOf": [
                      {
                        "type": "string",
                        "enum": [
                          "feature"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "changelog"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "faq"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "limitation"
                        ]
                      }
                    ]
                  },
                  "slug": {
                    "minLength": 1,
                    "maxLength": 100,
                    "type": "string"
                  },
                  "title": {
                    "minLength": 1,
                    "maxLength": 200,
                    "type": "string"
                  },
                  "content": {
                    "minLength": 1,
                    "type": "string"
                  },
                  "tags": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  },
                  "priority": {
                    "minimum": 0,
                    "maximum": 100,
                    "type": "integer"
                  },
                  "valid_from": {
                    "format": "date-time",
                    "type": "string"
                  },
                  "valid_until": {
                    "format": "date-time",
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "201": {
            "description": "Resource created",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "id",
                    "category",
                    "slug",
                    "title",
                    "content",
                    "tags",
                    "priority",
                    "is_active",
                    "valid_from",
                    "valid_until",
                    "created_at",
                    "updated_at"
                  ],
                  "properties": {
                    "id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "category": {
                      "type": "string"
                    },
                    "slug": {
                      "type": "string"
                    },
                    "title": {
                      "type": "string"
                    },
                    "content": {
                      "type": "string"
                    },
                    "tags": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "priority": {
                      "type": "integer"
                    },
                    "is_active": {
                      "type": "boolean"
                    },
                    "valid_from": {
                      "anyOf": [
                        {
                          "format": "date-time",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "valid_until": {
                      "anyOf": [
                        {
                          "format": "date-time",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "created_at": {
                      "format": "date-time",
                      "type": "string"
                    },
                    "updated_at": {
                      "format": "date-time",
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "409": {
            "description": "Conflict - resource state prevents the operation",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/platform-knowledge/{id}": {
      "put": {
        "operationId": "updatePlatformKnowledge",
        "summary": "Update platform knowledge entry",
        "tags": [
          "platform-knowledge"
        ],
        "description": "Partial update of a platform knowledge entry identified by UUID. Only the provided fields are updated. Use `is_active=false` to hard-disable an entry without deleting it. `valid_from`/`valid_until` accept `null` to clear the validity bound. Unique-constraint violation on `slug` returns 409; missing entry returns 404. Any mutation invalidates the in-memory prompt-section cache. Restricted to roles `admin` and `super_admin`.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "properties": {
                  "category": {
                    "anyOf": [
                      {
                        "type": "string",
                        "enum": [
                          "feature"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "changelog"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "faq"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "limitation"
                        ]
                      }
                    ]
                  },
                  "slug": {
                    "minLength": 1,
                    "maxLength": 100,
                    "type": "string"
                  },
                  "title": {
                    "minLength": 1,
                    "maxLength": 200,
                    "type": "string"
                  },
                  "content": {
                    "minLength": 1,
                    "type": "string"
                  },
                  "tags": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  },
                  "priority": {
                    "minimum": 0,
                    "maximum": 100,
                    "type": "integer"
                  },
                  "is_active": {
                    "type": "boolean"
                  },
                  "valid_from": {
                    "anyOf": [
                      {
                        "format": "date-time",
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "valid_until": {
                    "anyOf": [
                      {
                        "format": "date-time",
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "id",
                    "category",
                    "slug",
                    "title",
                    "content",
                    "tags",
                    "priority",
                    "is_active",
                    "valid_from",
                    "valid_until",
                    "created_at",
                    "updated_at"
                  ],
                  "properties": {
                    "id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "category": {
                      "type": "string"
                    },
                    "slug": {
                      "type": "string"
                    },
                    "title": {
                      "type": "string"
                    },
                    "content": {
                      "type": "string"
                    },
                    "tags": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "priority": {
                      "type": "integer"
                    },
                    "is_active": {
                      "type": "boolean"
                    },
                    "valid_from": {
                      "anyOf": [
                        {
                          "format": "date-time",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "valid_until": {
                      "anyOf": [
                        {
                          "format": "date-time",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "created_at": {
                      "format": "date-time",
                      "type": "string"
                    },
                    "updated_at": {
                      "format": "date-time",
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "Conflict - resource state prevents the operation",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      },
      "delete": {
        "operationId": "deletePlatformKnowledge",
        "summary": "Delete platform knowledge entry (soft delete)",
        "tags": [
          "platform-knowledge"
        ],
        "description": "Soft-deletes a platform knowledge entry by setting `is_active = false`. The row is retained in the database so historical chat transcripts that referenced it remain resolvable. Invalidates the in-memory prompt-section cache. Returns 204 No Content on success, 404 if the entry does not exist. Restricted to roles `admin` and `super_admin`.",
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "204": {
            "description": "No content"
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/platforms/users": {
      "get": {
        "operationId": "listPlatformUsers",
        "summary": "List non-Meta platform users",
        "tags": [
          "platforms"
        ],
        "description": "Returns one token/user row per connected Google, TikTok, Snapchat or Outbrain platform session. Used by the Users page instead of sampling ad-account pages. Results are scoped to the active workspace: tokens stamped with a team of the active scope plus legacy rows owned by accessible sessions.",
        "parameters": [
          {
            "schema": {
              "minimum": 1,
              "maximum": 100,
              "default": 50,
              "type": "integer"
            },
            "in": "query",
            "name": "limit",
            "required": false
          },
          {
            "schema": {
              "minimum": 0,
              "default": 0,
              "type": "integer"
            },
            "in": "query",
            "name": "offset",
            "required": false
          },
          {
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "enum": [
                    "all"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "google"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "tiktok"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "snapchat"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "outbrain"
                  ]
                }
              ]
            },
            "in": "query",
            "name": "platform",
            "required": false
          },
          {
            "schema": {
              "minLength": 2,
              "maxLength": 200,
              "type": "string"
            },
            "in": "query",
            "name": "search",
            "required": false
          },
          {
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "enum": [
                    "name"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "email"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "token_status"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "created_at"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "updated_at"
                  ]
                }
              ]
            },
            "in": "query",
            "name": "sort_by",
            "required": false
          },
          {
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "enum": [
                    "asc"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "desc"
                  ]
                }
              ]
            },
            "in": "query",
            "name": "sort_order",
            "required": false
          },
          {
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "enum": [
                    "ACTIVE"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "INACTIVE"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "EXPIRED"
                  ]
                }
              ]
            },
            "in": "query",
            "name": "status",
            "required": false
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "items",
                    "total",
                    "counts"
                  ],
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "additionalProperties": true,
                        "type": "object",
                        "required": [
                          "id",
                          "user_id",
                          "owner_session_id",
                          "email",
                          "name",
                          "_accountName",
                          "token_status",
                          "business_user_ids",
                          "platform",
                          "created_at",
                          "updated_at"
                        ],
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "user_id": {
                            "type": "string"
                          },
                          "owner_session_id": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "email": {
                            "type": "string"
                          },
                          "name": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "_accountName": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "token_status": {
                            "anyOf": [
                              {
                                "type": "string",
                                "enum": [
                                  "ACTIVE"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "INACTIVE"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "EXPIRED"
                                ]
                              }
                            ]
                          },
                          "business_user_ids": {
                            "anyOf": [
                              {
                                "type": "object",
                                "additionalProperties": {
                                  "type": "object",
                                  "required": [
                                    "business_name"
                                  ],
                                  "properties": {
                                    "business_name": {
                                      "type": "string"
                                    }
                                  }
                                }
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "member_name": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "member_email": {
                            "type": "string"
                          },
                          "team_name": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "platform": {
                            "anyOf": [
                              {
                                "type": "string",
                                "enum": [
                                  "google"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "tiktok"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "snapchat"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "outbrain"
                                ]
                              }
                            ]
                          },
                          "created_at": {
                            "format": "date-time",
                            "type": "string"
                          },
                          "updated_at": {
                            "anyOf": [
                              {
                                "format": "date-time",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          }
                        }
                      }
                    },
                    "total": {
                      "type": "integer"
                    },
                    "counts": {
                      "additionalProperties": false,
                      "type": "object",
                      "required": [
                        "ACTIVE",
                        "INACTIVE",
                        "EXPIRED"
                      ],
                      "properties": {
                        "ACTIVE": {
                          "type": "integer"
                        },
                        "INACTIVE": {
                          "type": "integer"
                        },
                        "EXPIRED": {
                          "type": "integer"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/postback/config": {
      "get": {
        "operationId": "getApiV1PostbackConfig",
        "summary": "Get postback configuration",
        "tags": [
          "postback"
        ],
        "description": "Returns the postback URL template and conversion stats for the authenticated user.",
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "postback_url",
                    "user_id",
                    "total_conversions",
                    "total_revenue"
                  ],
                  "properties": {
                    "postback_url": {
                      "type": "string"
                    },
                    "user_id": {
                      "type": "string"
                    },
                    "total_conversions": {
                      "type": "integer"
                    },
                    "total_revenue": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/postback/conversions": {
      "get": {
        "operationId": "getApiV1PostbackConversions",
        "summary": "List conversions (server-side paginated)",
        "tags": [
          "postback"
        ],
        "description": "Returns a server-side paginated, filtered, sorted list of postback conversions. Supports offset pagination, search, and filters.",
        "parameters": [
          {
            "schema": {
              "minimum": 1,
              "maximum": 200,
              "default": 50,
              "type": "integer"
            },
            "in": "query",
            "name": "limit",
            "required": false
          },
          {
            "schema": {
              "minimum": 0,
              "default": 0,
              "type": "integer"
            },
            "in": "query",
            "name": "offset",
            "required": false
          },
          {
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "enum": [
                    "received_at"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "payout"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "currency"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "transaction_id"
                  ]
                }
              ]
            },
            "in": "query",
            "name": "sort_by",
            "required": false
          },
          {
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "enum": [
                    "asc"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "desc"
                  ]
                }
              ]
            },
            "in": "query",
            "name": "sort_order",
            "required": false
          },
          {
            "schema": {
              "minLength": 2,
              "maxLength": 200,
              "type": "string"
            },
            "in": "query",
            "name": "search",
            "required": false
          },
          {
            "schema": {
              "maxLength": 10,
              "type": "string"
            },
            "in": "query",
            "name": "currency",
            "required": false
          },
          {
            "schema": {
              "type": "boolean"
            },
            "in": "query",
            "name": "unattributed",
            "required": false
          },
          {
            "schema": {
              "format": "date",
              "type": "string"
            },
            "in": "query",
            "name": "from_date",
            "required": false,
            "description": "Filter from date (YYYY-MM-DD)"
          },
          {
            "schema": {
              "format": "date",
              "type": "string"
            },
            "in": "query",
            "name": "to_date",
            "required": false,
            "description": "Filter to date (YYYY-MM-DD)"
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "items",
                    "total",
                    "counts"
                  ],
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "id",
                          "transaction_id",
                          "payout",
                          "currency",
                          "campaign_id",
                          "adset_id",
                          "ad_id",
                          "received_at"
                        ],
                        "properties": {
                          "id": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "transaction_id": {
                            "type": "string"
                          },
                          "payout": {
                            "anyOf": [
                              {
                                "type": "number"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "currency": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "campaign_id": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "adset_id": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "ad_id": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "received_at": {
                            "format": "date-time",
                            "type": "string"
                          }
                        }
                      }
                    },
                    "total": {
                      "type": "integer"
                    },
                    "counts": {
                      "type": "object",
                      "required": [
                        "total_conversions",
                        "total_revenue"
                      ],
                      "properties": {
                        "total_conversions": {
                          "type": "integer"
                        },
                        "total_revenue": {
                          "type": "number"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/postback/conversions/currencies": {
      "get": {
        "operationId": "getApiV1PostbackConversionsCurrencies",
        "summary": "List currencies available for conversion filters",
        "tags": [
          "postback"
        ],
        "description": "Returns distinct conversion currency codes from postback conversion logs visible to the caller so clients can populate conversion filters.",
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "items"
                  ],
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/ad-accounts/{adAccountId}/product-audiences": {
      "post": {
        "operationId": "postApiV1AdAccountsByAdAccountIdProductAudiences",
        "summary": "Create a dynamic product audience",
        "tags": [
          "product-audiences"
        ],
        "description": "Creates a dynamic product audience (DPA) based on a product set with inclusion/exclusion rules.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "product_set_id",
                  "name",
                  "inclusions"
                ],
                "properties": {
                  "product_set_id": {
                    "type": "string"
                  },
                  "name": {
                    "minLength": 1,
                    "maxLength": 200,
                    "type": "string"
                  },
                  "inclusions": {
                    "minItems": 1,
                    "type": "array",
                    "items": {
                      "additionalProperties": false,
                      "type": "object",
                      "required": [
                        "event",
                        "retention"
                      ],
                      "properties": {
                        "event": {
                          "anyOf": [
                            {
                              "type": "string",
                              "enum": [
                                "ViewContent"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "AddToCart"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "Purchase"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "Search"
                              ]
                            }
                          ]
                        },
                        "retention": {
                          "minimum": 1,
                          "maximum": 180,
                          "type": "integer"
                        }
                      }
                    }
                  },
                  "exclusions": {
                    "type": "array",
                    "items": {
                      "additionalProperties": false,
                      "type": "object",
                      "required": [
                        "event",
                        "retention"
                      ],
                      "properties": {
                        "event": {
                          "anyOf": [
                            {
                              "type": "string",
                              "enum": [
                                "ViewContent"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "AddToCart"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "Purchase"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "Search"
                              ]
                            }
                          ]
                        },
                        "retention": {
                          "minimum": 1,
                          "maximum": 180,
                          "type": "integer"
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "in": "path",
            "name": "adAccountId",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "id",
                    "message"
                  ],
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/catalogs/{catalogId}/audiences": {
      "get": {
        "operationId": "getApiV1CatalogsByCatalogIdAudiences",
        "summary": "List product audiences for a catalog",
        "tags": [
          "product-audiences"
        ],
        "description": "Aggregates product audiences across all ad accounts of the team, filtered to those whose product_set_id belongs to this catalog.",
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "in": "path",
            "name": "catalogId",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "items"
                  ],
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "id",
                          "name",
                          "ad_account_id"
                        ],
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "name": {
                            "type": "string"
                          },
                          "product_set_id": {
                            "type": "string"
                          },
                          "product_set_name": {
                            "type": "string"
                          },
                          "ad_account_id": {
                            "type": "string"
                          },
                          "ad_account_name": {
                            "type": "string"
                          },
                          "approximate_count": {
                            "type": "number"
                          },
                          "retention_days": {
                            "type": "number"
                          },
                          "time_created": {
                            "type": "string"
                          },
                          "status": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/ad-accounts/{adAccountId}/product-audiences/{audienceId}": {
      "delete": {
        "operationId": "deleteApiV1AdAccountsByAdAccountIdProductAudiencesByAudienceId",
        "summary": "Delete a product audience",
        "tags": [
          "product-audiences"
        ],
        "description": "Deletes a Meta dynamic product audience from the specified ad account using a team-scoped token and returns a success acknowledgement.",
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "in": "path",
            "name": "adAccountId",
            "required": true
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "path",
            "name": "audienceId",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "success"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/profitability/active-alerts": {
      "get": {
        "operationId": "getProfitabilityActiveAlerts",
        "summary": "Active margin-erosion alerts per campaign for the team's accessible sessions.",
        "tags": [
          "profitability"
        ],
        "description": "Scans enabled profitability configurations and returns campaign-level margin alerts below each configured threshold.",
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "rows"
                  ],
                  "properties": {
                    "rows": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "avg_margin",
                          "currency",
                          "external_campaign_id",
                          "lookback_days",
                          "platform",
                          "severity",
                          "threshold"
                        ],
                        "properties": {
                          "avg_margin": {
                            "type": "number"
                          },
                          "currency": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "external_campaign_id": {
                            "type": "string"
                          },
                          "lookback_days": {
                            "type": "number"
                          },
                          "platform": {
                            "type": "string"
                          },
                          "severity": {
                            "anyOf": [
                              {
                                "type": "string",
                                "enum": [
                                  "warning"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "critical"
                                ]
                              }
                            ]
                          },
                          "threshold": {
                            "type": "number"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/analytics/profit": {
      "get": {
        "operationId": "getAnalyticsProfit",
        "summary": "Get profitability P&L through the legacy analytics alias.",
        "tags": [
          "analytics",
          "profitability"
        ],
        "description": "Compatibility endpoint for PRD 8.3 clients. Returns campaign/adset/ad profitability rows, aggregate totals, currency, and requested period using the same source data as /api/v1/profitability/pnl.",
        "parameters": [
          {
            "schema": {
              "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
              "type": "string"
            },
            "in": "query",
            "name": "from_date",
            "required": true
          },
          {
            "schema": {
              "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
              "type": "string"
            },
            "in": "query",
            "name": "to_date",
            "required": true
          },
          {
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "enum": [
                    "campaign"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "adset"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "ad"
                  ]
                }
              ]
            },
            "in": "query",
            "name": "entity_level",
            "required": false
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "platform",
            "required": false
          },
          {
            "schema": {
              "type": "array",
              "items": {
                "type": "string"
              }
            },
            "in": "query",
            "name": "external_campaign_ids",
            "required": false
          },
          {
            "schema": {
              "type": "array",
              "items": {
                "type": "string"
              }
            },
            "in": "query",
            "name": "external_entity_ids",
            "required": false
          },
          {
            "schema": {
              "minimum": 1,
              "maximum": 1000,
              "default": 500,
              "type": "integer"
            },
            "in": "query",
            "name": "limit",
            "required": false
          },
          {
            "schema": {
              "minimum": 0,
              "default": 0,
              "type": "integer"
            },
            "in": "query",
            "name": "offset",
            "required": false
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "search",
            "required": false
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "sort_by",
            "required": false
          },
          {
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "enum": [
                    "asc"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "desc"
                  ]
                }
              ]
            },
            "in": "query",
            "name": "sort_order",
            "required": false
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "items",
                    "totals",
                    "currency",
                    "period"
                  ],
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "campaign_id",
                          "campaign_name",
                          "entity_level",
                          "entity_id",
                          "entity_name",
                          "account_id",
                          "spend",
                          "revenue_gross",
                          "refunds",
                          "revenue_net",
                          "cogs_total",
                          "shipping_cost",
                          "processing_fees",
                          "contribution_profit",
                          "contribution_margin_pct",
                          "true_roas",
                          "break_even_roas",
                          "data_source",
                          "platform",
                          "date"
                        ],
                        "properties": {
                          "campaign_id": {
                            "type": "string"
                          },
                          "campaign_name": {
                            "type": "string"
                          },
                          "entity_level": {
                            "anyOf": [
                              {
                                "type": "string",
                                "enum": [
                                  "campaign"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "adset"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "ad"
                                ]
                              }
                            ]
                          },
                          "entity_id": {
                            "type": "string"
                          },
                          "entity_name": {
                            "type": "string"
                          },
                          "account_id": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "spend": {
                            "type": "number"
                          },
                          "revenue_gross": {
                            "type": "number"
                          },
                          "refunds": {
                            "type": "number"
                          },
                          "revenue_net": {
                            "type": "number"
                          },
                          "cogs_total": {
                            "type": "number"
                          },
                          "shipping_cost": {
                            "type": "number"
                          },
                          "processing_fees": {
                            "type": "number"
                          },
                          "contribution_profit": {
                            "type": "number"
                          },
                          "contribution_margin_pct": {
                            "anyOf": [
                              {
                                "type": "number"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "true_roas": {
                            "anyOf": [
                              {
                                "type": "number"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "break_even_roas": {
                            "anyOf": [
                              {
                                "type": "number"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "data_source": {
                            "type": "string"
                          },
                          "platform": {
                            "type": "string"
                          },
                          "date": {
                            "type": "string"
                          }
                        }
                      }
                    },
                    "totals": {
                      "type": "object",
                      "required": [
                        "spend",
                        "revenue_gross",
                        "refunds",
                        "revenue_net",
                        "cogs_total",
                        "shipping_cost",
                        "processing_fees",
                        "contribution_profit"
                      ],
                      "properties": {
                        "spend": {
                          "type": "number"
                        },
                        "revenue_gross": {
                          "type": "number"
                        },
                        "refunds": {
                          "type": "number"
                        },
                        "revenue_net": {
                          "type": "number"
                        },
                        "cogs_total": {
                          "type": "number"
                        },
                        "shipping_cost": {
                          "type": "number"
                        },
                        "processing_fees": {
                          "type": "number"
                        },
                        "contribution_profit": {
                          "type": "number"
                        }
                      }
                    },
                    "currency": {
                      "type": "string"
                    },
                    "period": {
                      "type": "object",
                      "required": [
                        "from_date",
                        "to_date"
                      ],
                      "properties": {
                        "from_date": {
                          "type": "string"
                        },
                        "to_date": {
                          "type": "string"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/analytics/profit/timeline": {
      "get": {
        "operationId": "getAnalyticsProfitTimeline",
        "summary": "Get profitability timeline through the legacy analytics alias.",
        "tags": [
          "analytics",
          "profitability"
        ],
        "description": "Compatibility endpoint that returns daily spend, net revenue, and contribution profit points for the caller team in the requested date range, optionally filtered by platform.",
        "parameters": [
          {
            "schema": {
              "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
              "type": "string"
            },
            "in": "query",
            "name": "from_date",
            "required": true
          },
          {
            "schema": {
              "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
              "type": "string"
            },
            "in": "query",
            "name": "to_date",
            "required": true
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "platform",
            "required": false
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "points"
                  ],
                  "properties": {
                    "points": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "date",
                          "spend",
                          "revenue",
                          "profit"
                        ],
                        "properties": {
                          "date": {
                            "type": "string"
                          },
                          "spend": {
                            "type": "number"
                          },
                          "revenue": {
                            "type": "number"
                          },
                          "profit": {
                            "type": "number"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/analytics/profit/skus": {
      "get": {
        "operationId": "getAnalyticsProfitSkus",
        "summary": "Get SKU margin breakdown through the legacy analytics alias.",
        "tags": [
          "analytics",
          "profitability"
        ],
        "description": "Compatibility endpoint that returns SKU-level units, revenue, COGS, margin, and margin percentage for attributed Shopify and WooCommerce order lines.",
        "parameters": [
          {
            "schema": {
              "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
              "type": "string"
            },
            "in": "query",
            "name": "from_date",
            "required": true
          },
          {
            "schema": {
              "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
              "type": "string"
            },
            "in": "query",
            "name": "to_date",
            "required": true
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "platform",
            "required": false
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "external_campaign_id",
            "required": false
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "rows"
                  ],
                  "properties": {
                    "rows": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "sku",
                          "external_campaign_id",
                          "platform",
                          "units",
                          "revenue",
                          "cogs",
                          "margin",
                          "margin_pct"
                        ],
                        "properties": {
                          "sku": {
                            "type": "string"
                          },
                          "external_campaign_id": {
                            "type": "string"
                          },
                          "platform": {
                            "type": "string"
                          },
                          "units": {
                            "type": "number"
                          },
                          "revenue": {
                            "type": "number"
                          },
                          "cogs": {
                            "type": "number"
                          },
                          "margin": {
                            "type": "number"
                          },
                          "margin_pct": {
                            "anyOf": [
                              {
                                "type": "number"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/analytics/break-even": {
      "post": {
        "operationId": "calculateAnalyticsBreakEvenRoas",
        "summary": "Calculate break-even ROAS from order economics.",
        "tags": [
          "analytics",
          "profitability"
        ],
        "description": "Computes margin per order, net margin percentage, and break-even ROAS from average order value, COGS percentage, fixed shipping, and payment processing fee assumptions.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "avg_order_value",
                  "cogs_pct",
                  "shipping_fixed",
                  "processing_fee_pct"
                ],
                "properties": {
                  "avg_order_value": {
                    "exclusiveMinimum": 0,
                    "type": "number"
                  },
                  "cogs_pct": {
                    "minimum": 0,
                    "maximum": 1,
                    "type": "number"
                  },
                  "shipping_fixed": {
                    "minimum": 0,
                    "type": "number"
                  },
                  "processing_fee_pct": {
                    "minimum": 0,
                    "maximum": 1,
                    "type": "number"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "break_even_roas",
                    "margin_per_order",
                    "net_margin_pct"
                  ],
                  "properties": {
                    "break_even_roas": {
                      "anyOf": [
                        {
                          "type": "number"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "margin_per_order": {
                      "type": "number"
                    },
                    "net_margin_pct": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/profitability/cogs-overrides": {
      "post": {
        "operationId": "upsertProfitabilityCogsOverride",
        "summary": "Create a profitability COGS override through the compatibility alias.",
        "tags": [
          "profitability"
        ],
        "description": "Compatibility endpoint that closes the active override for the same campaign key and creates a new percentage or fixed COGS override.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "platform",
                  "external_campaign_id"
                ],
                "properties": {
                  "platform": {
                    "type": "string"
                  },
                  "external_campaign_id": {
                    "type": "string"
                  },
                  "cogs_pct": {
                    "minimum": 0,
                    "maximum": 1,
                    "type": "number"
                  },
                  "cogs_fixed": {
                    "minimum": 0,
                    "type": "number"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "id",
                    "session_id",
                    "platform",
                    "external_campaign_id",
                    "cogs_pct",
                    "cogs_fixed",
                    "valid_from",
                    "valid_to"
                  ],
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "session_id": {
                      "type": "string"
                    },
                    "platform": {
                      "type": "string"
                    },
                    "external_campaign_id": {
                      "type": "string"
                    },
                    "cogs_pct": {
                      "anyOf": [
                        {
                          "type": "number"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "cogs_fixed": {
                      "anyOf": [
                        {
                          "type": "number"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "valid_from": {
                      "type": "string"
                    },
                    "valid_to": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/profitability/import-cogs": {
      "post": {
        "operationId": "importProfitabilityCogsCsv",
        "summary": "Import profitability COGS overrides through the compatibility alias.",
        "tags": [
          "profitability"
        ],
        "description": "Compatibility endpoint that parses CSV COGS overrides and applies valid rows to the first accessible session.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "csv"
                ],
                "properties": {
                  "csv": {
                    "minLength": 1,
                    "maxLength": 1000000,
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "total",
                    "ok",
                    "errors",
                    "details"
                  ],
                  "properties": {
                    "total": {
                      "type": "number"
                    },
                    "ok": {
                      "type": "number"
                    },
                    "errors": {
                      "type": "number"
                    },
                    "details": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "row",
                          "status"
                        ],
                        "properties": {
                          "row": {
                            "type": "number"
                          },
                          "status": {
                            "type": "string"
                          },
                          "message": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/profitability/config": {
      "get": {
        "operationId": "getProfitabilityConfig",
        "summary": "Get profitability configuration",
        "tags": [
          "profitability"
        ],
        "description": "Returns the profitability defaults and alert settings for the first accessible session, creating defaults when needed.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "default_cogs_pct",
                    "default_shipping_fixed",
                    "processing_fee_pct",
                    "currency",
                    "attribution_window_days",
                    "margin_alert_threshold",
                    "margin_alert_enabled",
                    "margin_alert_lookback_days",
                    "keitaro_sku_field"
                  ],
                  "properties": {
                    "default_cogs_pct": {
                      "minimum": 0,
                      "maximum": 1,
                      "type": "number"
                    },
                    "default_shipping_fixed": {
                      "minimum": 0,
                      "type": "number"
                    },
                    "processing_fee_pct": {
                      "minimum": 0,
                      "maximum": 1,
                      "type": "number"
                    },
                    "currency": {
                      "minLength": 3,
                      "maxLength": 10,
                      "type": "string"
                    },
                    "attribution_window_days": {
                      "minimum": 1,
                      "maximum": 90,
                      "type": "integer"
                    },
                    "margin_alert_threshold": {
                      "minimum": 0,
                      "maximum": 1,
                      "type": "number"
                    },
                    "margin_alert_enabled": {
                      "type": "boolean"
                    },
                    "margin_alert_lookback_days": {
                      "minimum": 1,
                      "maximum": 90,
                      "type": "integer"
                    },
                    "keitaro_sku_field": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      },
      "put": {
        "operationId": "updateProfitabilityConfig",
        "summary": "Update profitability configuration",
        "tags": [
          "profitability"
        ],
        "description": "Updates profitability defaults and alert settings for the first accessible session, then schedules recent rematerialization.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "default_cogs_pct": {
                    "minimum": 0,
                    "maximum": 1,
                    "type": "number"
                  },
                  "default_shipping_fixed": {
                    "minimum": 0,
                    "type": "number"
                  },
                  "processing_fee_pct": {
                    "minimum": 0,
                    "maximum": 1,
                    "type": "number"
                  },
                  "currency": {
                    "minLength": 3,
                    "maxLength": 10,
                    "type": "string"
                  },
                  "attribution_window_days": {
                    "minimum": 1,
                    "maximum": 90,
                    "type": "integer"
                  },
                  "margin_alert_threshold": {
                    "minimum": 0,
                    "maximum": 1,
                    "type": "number"
                  },
                  "margin_alert_enabled": {
                    "type": "boolean"
                  },
                  "margin_alert_lookback_days": {
                    "minimum": 1,
                    "maximum": 90,
                    "type": "integer"
                  },
                  "keitaro_sku_field": {
                    "anyOf": [
                      {
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "default_cogs_pct",
                    "default_shipping_fixed",
                    "processing_fee_pct",
                    "currency",
                    "attribution_window_days",
                    "margin_alert_threshold",
                    "margin_alert_enabled",
                    "margin_alert_lookback_days",
                    "keitaro_sku_field"
                  ],
                  "properties": {
                    "default_cogs_pct": {
                      "minimum": 0,
                      "maximum": 1,
                      "type": "number"
                    },
                    "default_shipping_fixed": {
                      "minimum": 0,
                      "type": "number"
                    },
                    "processing_fee_pct": {
                      "minimum": 0,
                      "maximum": 1,
                      "type": "number"
                    },
                    "currency": {
                      "minLength": 3,
                      "maxLength": 10,
                      "type": "string"
                    },
                    "attribution_window_days": {
                      "minimum": 1,
                      "maximum": 90,
                      "type": "integer"
                    },
                    "margin_alert_threshold": {
                      "minimum": 0,
                      "maximum": 1,
                      "type": "number"
                    },
                    "margin_alert_enabled": {
                      "type": "boolean"
                    },
                    "margin_alert_lookback_days": {
                      "minimum": 1,
                      "maximum": 90,
                      "type": "integer"
                    },
                    "keitaro_sku_field": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/profitability/import": {
      "post": {
        "operationId": "importProfitabilityCsv",
        "summary": "Import profitability COGS overrides from CSV",
        "tags": [
          "profitability"
        ],
        "description": "Parses up to 1000 CSV rows and creates percentage or fixed COGS overrides for the first accessible session.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "csv"
                ],
                "properties": {
                  "csv": {
                    "minLength": 1,
                    "maxLength": 1000000,
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "total",
                    "ok",
                    "errors",
                    "details"
                  ],
                  "properties": {
                    "total": {
                      "type": "number"
                    },
                    "ok": {
                      "type": "number"
                    },
                    "errors": {
                      "type": "number"
                    },
                    "details": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "row",
                          "status"
                        ],
                        "properties": {
                          "row": {
                            "type": "number"
                          },
                          "status": {
                            "type": "string"
                          },
                          "message": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/profitability/overrides": {
      "get": {
        "operationId": "listProfitabilityOverrides",
        "summary": "List profitability COGS overrides",
        "tags": [
          "profitability"
        ],
        "description": "Returns active per-campaign COGS overrides for the caller accessible sessions, newest first.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "rows"
                  ],
                  "properties": {
                    "rows": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "id",
                          "session_id",
                          "platform",
                          "external_campaign_id",
                          "cogs_pct",
                          "cogs_fixed",
                          "valid_from",
                          "valid_to"
                        ],
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "session_id": {
                            "type": "string"
                          },
                          "platform": {
                            "type": "string"
                          },
                          "external_campaign_id": {
                            "type": "string"
                          },
                          "cogs_pct": {
                            "anyOf": [
                              {
                                "type": "number"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "cogs_fixed": {
                            "anyOf": [
                              {
                                "type": "number"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "valid_from": {
                            "type": "string"
                          },
                          "valid_to": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "upsertProfitabilityOverride",
        "summary": "Create a profitability COGS override",
        "tags": [
          "profitability"
        ],
        "description": "Closes any active override for the same campaign key and creates a new percentage or fixed COGS override.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "platform",
                  "external_campaign_id"
                ],
                "properties": {
                  "platform": {
                    "type": "string"
                  },
                  "external_campaign_id": {
                    "type": "string"
                  },
                  "cogs_pct": {
                    "minimum": 0,
                    "maximum": 1,
                    "type": "number"
                  },
                  "cogs_fixed": {
                    "minimum": 0,
                    "type": "number"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "id",
                    "session_id",
                    "platform",
                    "external_campaign_id",
                    "cogs_pct",
                    "cogs_fixed",
                    "valid_from",
                    "valid_to"
                  ],
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "session_id": {
                      "type": "string"
                    },
                    "platform": {
                      "type": "string"
                    },
                    "external_campaign_id": {
                      "type": "string"
                    },
                    "cogs_pct": {
                      "anyOf": [
                        {
                          "type": "number"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "cogs_fixed": {
                      "anyOf": [
                        {
                          "type": "number"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "valid_from": {
                      "type": "string"
                    },
                    "valid_to": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/profitability/overrides/{id}": {
      "delete": {
        "operationId": "deleteProfitabilityOverride",
        "summary": "Delete a profitability COGS override",
        "tags": [
          "profitability"
        ],
        "description": "Soft-closes the selected campaign COGS override for the caller accessible sessions and schedules rematerialization.",
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "ok"
                  ],
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/profitability/pnl": {
      "get": {
        "operationId": "getProfitabilityPnl",
        "summary": "Get P&L rows for the team in a date range.",
        "tags": [
          "profitability"
        ],
        "description": "Returns paginated profitability rows from profitability snapshots for the caller team, including spend, gross/net revenue, COGS, shipping, fees, contribution profit, margin, true ROAS, and totals.",
        "parameters": [
          {
            "schema": {
              "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
              "type": "string"
            },
            "in": "query",
            "name": "from_date",
            "required": true
          },
          {
            "schema": {
              "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
              "type": "string"
            },
            "in": "query",
            "name": "to_date",
            "required": true
          },
          {
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "enum": [
                    "campaign"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "adset"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "ad"
                  ]
                }
              ]
            },
            "in": "query",
            "name": "entity_level",
            "required": false
          },
          {
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "enum": [
                    "campaign"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "account"
                  ]
                }
              ]
            },
            "in": "query",
            "name": "group_by",
            "required": false
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "platform",
            "required": false
          },
          {
            "schema": {
              "type": "array",
              "items": {
                "type": "string"
              }
            },
            "in": "query",
            "name": "external_campaign_ids",
            "required": false
          },
          {
            "schema": {
              "type": "array",
              "items": {
                "type": "string"
              }
            },
            "in": "query",
            "name": "external_entity_ids",
            "required": false
          },
          {
            "schema": {
              "type": "array",
              "items": {
                "type": "string"
              }
            },
            "in": "query",
            "name": "ad_account_ids",
            "required": false
          },
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "query",
            "name": "catalog_source_id",
            "required": false
          },
          {
            "schema": {
              "minimum": 1,
              "maximum": 1000,
              "default": 500,
              "type": "integer"
            },
            "in": "query",
            "name": "limit",
            "required": false
          },
          {
            "schema": {
              "minimum": 0,
              "default": 0,
              "type": "integer"
            },
            "in": "query",
            "name": "offset",
            "required": false
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "search",
            "required": false
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "sort_by",
            "required": false
          },
          {
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "enum": [
                    "asc"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "desc"
                  ]
                }
              ]
            },
            "in": "query",
            "name": "sort_order",
            "required": false
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "rows",
                    "total",
                    "limit",
                    "offset",
                    "totals",
                    "updated_at"
                  ],
                  "properties": {
                    "rows": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "session_id",
                          "date",
                          "platform",
                          "entity_level",
                          "external_entity_id",
                          "external_campaign_id",
                          "ad_account_id",
                          "account_name",
                          "campaign_name",
                          "adset_name",
                          "ad_name",
                          "spend",
                          "revenue_gross",
                          "revenue_net",
                          "refunds",
                          "cogs_total",
                          "shipping_cost",
                          "processing_fees",
                          "contribution_profit",
                          "contribution_margin",
                          "true_roas",
                          "break_even_roas",
                          "data_source",
                          "data_quality",
                          "currency"
                        ],
                        "properties": {
                          "session_id": {
                            "type": "string"
                          },
                          "date": {
                            "pattern": "^\\d{4}-\\d{2}-\\d{2}(\\/\\d{4}-\\d{2}-\\d{2})?$",
                            "type": "string"
                          },
                          "platform": {
                            "type": "string"
                          },
                          "entity_level": {
                            "anyOf": [
                              {
                                "type": "string",
                                "enum": [
                                  "campaign"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "adset"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "ad"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "account"
                                ]
                              }
                            ]
                          },
                          "external_entity_id": {
                            "type": "string"
                          },
                          "external_campaign_id": {
                            "type": "string"
                          },
                          "ad_account_id": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "account_name": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "campaign_name": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "adset_name": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "ad_name": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "spend": {
                            "type": "number"
                          },
                          "revenue_gross": {
                            "type": "number"
                          },
                          "revenue_net": {
                            "type": "number"
                          },
                          "refunds": {
                            "type": "number"
                          },
                          "cogs_total": {
                            "type": "number"
                          },
                          "shipping_cost": {
                            "type": "number"
                          },
                          "processing_fees": {
                            "type": "number"
                          },
                          "contribution_profit": {
                            "type": "number"
                          },
                          "contribution_margin": {
                            "anyOf": [
                              {
                                "type": "number"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "true_roas": {
                            "anyOf": [
                              {
                                "type": "number"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "break_even_roas": {
                            "anyOf": [
                              {
                                "type": "number"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "data_source": {
                            "type": "string"
                          },
                          "data_quality": {
                            "type": "string"
                          },
                          "currency": {
                            "type": "string"
                          }
                        }
                      }
                    },
                    "total": {
                      "type": "number"
                    },
                    "limit": {
                      "type": "number"
                    },
                    "offset": {
                      "type": "number"
                    },
                    "totals": {
                      "type": "object",
                      "required": [
                        "spend",
                        "revenue_gross",
                        "refunds",
                        "revenue_net",
                        "cogs_total",
                        "shipping_cost",
                        "processing_fees",
                        "contribution_profit",
                        "contribution_margin",
                        "true_roas"
                      ],
                      "properties": {
                        "spend": {
                          "type": "number"
                        },
                        "revenue_gross": {
                          "type": "number"
                        },
                        "refunds": {
                          "type": "number"
                        },
                        "revenue_net": {
                          "type": "number"
                        },
                        "cogs_total": {
                          "type": "number"
                        },
                        "shipping_cost": {
                          "type": "number"
                        },
                        "processing_fees": {
                          "type": "number"
                        },
                        "contribution_profit": {
                          "type": "number"
                        },
                        "contribution_margin": {
                          "anyOf": [
                            {
                              "type": "number"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "true_roas": {
                          "anyOf": [
                            {
                              "type": "number"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        }
                      }
                    },
                    "updated_at": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/profitability/refresh": {
      "post": {
        "operationId": "refreshProfitability",
        "summary": "Trigger on-demand snapshot materialization for the team.",
        "tags": [
          "profitability"
        ],
        "description": "Refreshes today profitability snapshots for each accessible session and returns processed snapshot counts.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "processed",
                    "sessions"
                  ],
                  "properties": {
                    "processed": {
                      "type": "number"
                    },
                    "sessions": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/profitability/skus": {
      "get": {
        "operationId": "getProfitabilitySkus",
        "summary": "SKU margin breakdown.",
        "tags": [
          "profitability"
        ],
        "description": "Returns SKU-level units, revenue, COGS, margin, margin percentage, and related campaign totals for attributed Shopify and WooCommerce order lines in the selected date range.",
        "parameters": [
          {
            "schema": {
              "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
              "type": "string"
            },
            "in": "query",
            "name": "from_date",
            "required": true
          },
          {
            "schema": {
              "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
              "type": "string"
            },
            "in": "query",
            "name": "to_date",
            "required": true
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "platform",
            "required": false
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "external_campaign_id",
            "required": false
          },
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "query",
            "name": "catalog_source_id",
            "required": false
          },
          {
            "schema": {
              "maxLength": 200,
              "type": "string"
            },
            "in": "query",
            "name": "search",
            "required": false
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "sort_by",
            "required": false
          },
          {
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "enum": [
                    "asc"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "desc"
                  ]
                }
              ]
            },
            "in": "query",
            "name": "sort_order",
            "required": false
          },
          {
            "schema": {
              "minimum": 1,
              "maximum": 500,
              "type": "integer"
            },
            "in": "query",
            "name": "limit",
            "required": false
          },
          {
            "schema": {
              "minimum": 0,
              "type": "integer"
            },
            "in": "query",
            "name": "offset",
            "required": false
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "rows",
                    "total",
                    "limit",
                    "offset"
                  ],
                  "properties": {
                    "rows": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "sku",
                          "external_campaign_id",
                          "platform",
                          "units",
                          "revenue",
                          "cogs",
                          "margin",
                          "margin_pct",
                          "campaign_spend",
                          "campaign_revenue"
                        ],
                        "properties": {
                          "sku": {
                            "type": "string"
                          },
                          "external_campaign_id": {
                            "type": "string"
                          },
                          "platform": {
                            "type": "string"
                          },
                          "units": {
                            "type": "number"
                          },
                          "revenue": {
                            "type": "number"
                          },
                          "cogs": {
                            "type": "number"
                          },
                          "margin": {
                            "type": "number"
                          },
                          "margin_pct": {
                            "anyOf": [
                              {
                                "type": "number"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "campaign_spend": {
                            "type": "number"
                          },
                          "campaign_revenue": {
                            "type": "number"
                          }
                        }
                      }
                    },
                    "total": {
                      "type": "number"
                    },
                    "limit": {
                      "type": "number"
                    },
                    "offset": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/profitability/timeline": {
      "get": {
        "operationId": "getProfitabilityTimeline",
        "summary": "Daily aggregated spend/revenue/profit for charting.",
        "tags": [
          "profitability"
        ],
        "description": "Returns one point per day with aggregated spend, net revenue, and contribution profit for the caller team, optionally filtered by platform or commerce store.",
        "parameters": [
          {
            "schema": {
              "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
              "type": "string"
            },
            "in": "query",
            "name": "from_date",
            "required": true
          },
          {
            "schema": {
              "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
              "type": "string"
            },
            "in": "query",
            "name": "to_date",
            "required": true
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "platform",
            "required": false
          },
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "query",
            "name": "catalog_source_id",
            "required": false
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "points"
                  ],
                  "properties": {
                    "points": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "date",
                          "spend",
                          "revenue",
                          "profit"
                        ],
                        "properties": {
                          "date": {
                            "type": "string"
                          },
                          "spend": {
                            "type": "number"
                          },
                          "revenue": {
                            "type": "number"
                          },
                          "profit": {
                            "type": "number"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/rbac/access-groups": {
      "get": {
        "operationId": "getApiV1RbacAccessGroups",
        "summary": "List access groups",
        "tags": [
          "rbac"
        ],
        "description": "Lists product Teams (access groups) visible to the caller. Organization owners/admins see all groups in their organization; members see groups they belong to.",
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "query",
            "name": "organization_id",
            "required": false
          }
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "items"
                  ],
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "additionalProperties": false,
                        "type": "object",
                        "required": [
                          "id",
                          "organization_id",
                          "name",
                          "slug",
                          "member_count",
                          "team_count",
                          "created_at",
                          "updated_at"
                        ],
                        "properties": {
                          "id": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "organization_id": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "name": {
                            "type": "string"
                          },
                          "slug": {
                            "type": "string"
                          },
                          "member_count": {
                            "type": "number"
                          },
                          "team_count": {
                            "type": "number"
                          },
                          "created_at": {
                            "format": "date-time",
                            "type": "string"
                          },
                          "updated_at": {
                            "format": "date-time",
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "postApiV1RbacAccessGroups",
        "summary": "Create an access group",
        "tags": [
          "rbac"
        ],
        "description": "Creates a product Team under an organization. The caller must hold owner/admin-level access on the organization.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "organization_id",
                  "name"
                ],
                "properties": {
                  "organization_id": {
                    "format": "uuid",
                    "type": "string"
                  },
                  "name": {
                    "minLength": 1,
                    "maxLength": 255,
                    "type": "string"
                  },
                  "slug": {
                    "minLength": 1,
                    "maxLength": 100,
                    "pattern": "^[a-z0-9-]+$",
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "201": {
            "description": "Resource created",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "id",
                    "organization_id",
                    "name",
                    "slug",
                    "member_count",
                    "team_count",
                    "created_at",
                    "updated_at"
                  ],
                  "properties": {
                    "id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "organization_id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "name": {
                      "type": "string"
                    },
                    "slug": {
                      "type": "string"
                    },
                    "member_count": {
                      "type": "number"
                    },
                    "team_count": {
                      "type": "number"
                    },
                    "created_at": {
                      "format": "date-time",
                      "type": "string"
                    },
                    "updated_at": {
                      "format": "date-time",
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "Conflict - resource state prevents the operation",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/rbac/access-groups/{id}": {
      "patch": {
        "operationId": "patchApiV1RbacAccessGroupsById",
        "summary": "Update an access group",
        "tags": [
          "rbac"
        ],
        "description": "Updates a product Team name or slug. The caller must hold owner/admin-level access on the organization.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "properties": {
                  "name": {
                    "minLength": 1,
                    "maxLength": 255,
                    "type": "string"
                  },
                  "slug": {
                    "minLength": 1,
                    "maxLength": 100,
                    "pattern": "^[a-z0-9-]+$",
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "id",
                    "organization_id",
                    "name",
                    "slug",
                    "member_count",
                    "team_count",
                    "created_at",
                    "updated_at"
                  ],
                  "properties": {
                    "id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "organization_id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "name": {
                      "type": "string"
                    },
                    "slug": {
                      "type": "string"
                    },
                    "member_count": {
                      "type": "number"
                    },
                    "team_count": {
                      "type": "number"
                    },
                    "created_at": {
                      "format": "date-time",
                      "type": "string"
                    },
                    "updated_at": {
                      "format": "date-time",
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "Conflict - resource state prevents the operation",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      },
      "delete": {
        "operationId": "deleteApiV1RbacAccessGroupsById",
        "summary": "Soft-delete an access group",
        "tags": [
          "rbac"
        ],
        "description": "Soft-deletes a product Team and its active memberships/Workspace (team) grants. The caller must hold owner/admin-level access on the organization.",
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "message"
                  ],
                  "properties": {
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/rbac/access-groups/{id}/members": {
      "get": {
        "operationId": "getApiV1RbacAccessGroupsByIdMembers",
        "summary": "List access group members",
        "tags": [
          "rbac"
        ],
        "description": "Lists members of a product Team. Organization owners/admins and members of the group can read this list.",
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "items"
                  ],
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "additionalProperties": false,
                        "type": "object",
                        "required": [
                          "id",
                          "access_group_id",
                          "user_id",
                          "role",
                          "user_email",
                          "user_name",
                          "created_at"
                        ],
                        "properties": {
                          "id": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "access_group_id": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "user_id": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "role": {
                            "anyOf": [
                              {
                                "type": "string",
                                "enum": [
                                  "manager"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "mediabuyer"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "finance"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "viewer"
                                ]
                              }
                            ]
                          },
                          "user_email": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "user_name": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "created_at": {
                            "format": "date-time",
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "postApiV1RbacAccessGroupsByIdMembers",
        "summary": "Add an access group member",
        "tags": [
          "rbac"
        ],
        "description": "Adds an existing organization member to a product Team. Organization owners/admins can add leads or members; team leads can add regular members only.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "user_id"
                ],
                "properties": {
                  "user_id": {
                    "format": "uuid",
                    "type": "string"
                  },
                  "role": {
                    "anyOf": [
                      {
                        "type": "string",
                        "enum": [
                          "manager"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "mediabuyer"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "finance"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "viewer"
                        ]
                      }
                    ]
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "201": {
            "description": "Resource created",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "id",
                    "access_group_id",
                    "user_id",
                    "role",
                    "user_email",
                    "user_name",
                    "created_at"
                  ],
                  "properties": {
                    "id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "access_group_id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "user_id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "role": {
                      "anyOf": [
                        {
                          "type": "string",
                          "enum": [
                            "manager"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "mediabuyer"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "finance"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "viewer"
                          ]
                        }
                      ]
                    },
                    "user_email": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "user_name": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "created_at": {
                      "format": "date-time",
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "Conflict - resource state prevents the operation",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/rbac/access-groups/{id}/members/{membership_id}": {
      "patch": {
        "operationId": "patchApiV1RbacAccessGroupsByIdMembersByMembershipId",
        "summary": "Update an access group member role",
        "tags": [
          "rbac"
        ],
        "description": "Changes a product Team member between lead and member. Only organization owners/admins can appoint or demote team leads.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "role"
                ],
                "properties": {
                  "role": {
                    "anyOf": [
                      {
                        "type": "string",
                        "enum": [
                          "manager"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "mediabuyer"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "finance"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "viewer"
                        ]
                      }
                    ]
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          },
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "membership_id",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "id",
                    "access_group_id",
                    "user_id",
                    "role",
                    "user_email",
                    "user_name",
                    "created_at"
                  ],
                  "properties": {
                    "id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "access_group_id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "user_id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "role": {
                      "anyOf": [
                        {
                          "type": "string",
                          "enum": [
                            "manager"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "mediabuyer"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "finance"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "viewer"
                          ]
                        }
                      ]
                    },
                    "user_email": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "user_name": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "created_at": {
                      "format": "date-time",
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      },
      "delete": {
        "operationId": "deleteApiV1RbacAccessGroupsByIdMembersByMembershipId",
        "summary": "Remove an access group member",
        "tags": [
          "rbac"
        ],
        "description": "Removes a member from a product Team. Organization owners/admins can remove any member; team leads can remove regular members only.",
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          },
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "membership_id",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "message"
                  ],
                  "properties": {
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/rbac/access-groups/{id}/teams": {
      "get": {
        "operationId": "getApiV1RbacAccessGroupsByIdTeams",
        "summary": "List access group workspace (team) grants",
        "tags": [
          "rbac"
        ],
        "description": "Lists Workspace (team) grants assigned to a product Team. Organization owners/admins and members of the group can read this list.",
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "items"
                  ],
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "additionalProperties": false,
                        "type": "object",
                        "required": [
                          "id",
                          "access_group_id",
                          "team_id",
                          "team_name",
                          "created_at"
                        ],
                        "properties": {
                          "id": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "access_group_id": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "team_id": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "team_name": {
                            "type": "string"
                          },
                          "created_at": {
                            "format": "date-time",
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/rbac/access-groups/{id}/teams/{team_id}": {
      "put": {
        "operationId": "putApiV1RbacAccessGroupsByIdTeamsByTeamId",
        "summary": "Grant a workspace (team) to an access group",
        "tags": [
          "rbac"
        ],
        "description": "Links a product Team to a Workspace (team). Members inherit their access-group role on it. Only organization owners/admins can manage workspace grants.",
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          },
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "team_id",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "id",
                    "access_group_id",
                    "team_id",
                    "team_name",
                    "created_at"
                  ],
                  "properties": {
                    "id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "access_group_id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "team_id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "team_name": {
                      "type": "string"
                    },
                    "created_at": {
                      "format": "date-time",
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      },
      "delete": {
        "operationId": "deleteApiV1RbacAccessGroupsByIdTeamsByTeamId",
        "summary": "Revoke an access group workspace (team) grant",
        "tags": [
          "rbac"
        ],
        "description": "Revokes a product Team grant from a Workspace (team). Only organization owners/admins can manage workspace grants.",
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          },
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "team_id",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "message"
                  ],
                  "properties": {
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/rbac/organizations": {
      "get": {
        "operationId": "getApiV1RbacOrganizations",
        "summary": "List organizations accessible to the current user",
        "tags": [
          "rbac"
        ],
        "description": "Returns organizations visible to the authenticated user according to global role and scoped RBAC permissions.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "items"
                  ],
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "id",
                          "name",
                          "slug",
                          "created_at",
                          "updated_at"
                        ],
                        "properties": {
                          "id": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "name": {
                            "type": "string"
                          },
                          "slug": {
                            "type": "string"
                          },
                          "created_at": {
                            "format": "date-time",
                            "type": "string"
                          },
                          "updated_at": {
                            "format": "date-time",
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "postApiV1RbacOrganizations",
        "summary": "Create a new organization (super_admin only)",
        "tags": [
          "rbac"
        ],
        "description": "Creates a top-level organization with a unique slug. Restricted to super_admin callers.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "name",
                  "slug"
                ],
                "properties": {
                  "name": {
                    "minLength": 1,
                    "maxLength": 255,
                    "type": "string"
                  },
                  "slug": {
                    "minLength": 1,
                    "maxLength": 100,
                    "pattern": "^[a-z0-9-]+$",
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "201": {
            "description": "Resource created",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "id",
                    "name",
                    "slug",
                    "created_at",
                    "updated_at"
                  ],
                  "properties": {
                    "id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "name": {
                      "type": "string"
                    },
                    "slug": {
                      "type": "string"
                    },
                    "created_at": {
                      "format": "date-time",
                      "type": "string"
                    },
                    "updated_at": {
                      "format": "date-time",
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "Conflict - resource state prevents the operation",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/rbac/organizations/{id}": {
      "patch": {
        "operationId": "patchApiV1RbacOrganizationsById",
        "summary": "Update an organization",
        "tags": [
          "rbac"
        ],
        "description": "Updates organization name or slug after checking global admin access or owner-level scoped organization access.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "properties": {
                  "name": {
                    "minLength": 1,
                    "maxLength": 255,
                    "type": "string"
                  },
                  "slug": {
                    "minLength": 1,
                    "maxLength": 100,
                    "pattern": "^[a-z0-9-]+$",
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "id",
                    "name",
                    "slug",
                    "created_at",
                    "updated_at"
                  ],
                  "properties": {
                    "id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "name": {
                      "type": "string"
                    },
                    "slug": {
                      "type": "string"
                    },
                    "created_at": {
                      "format": "date-time",
                      "type": "string"
                    },
                    "updated_at": {
                      "format": "date-time",
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "Conflict - resource state prevents the operation",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      },
      "delete": {
        "operationId": "deleteApiV1RbacOrganizationsById",
        "summary": "Soft-delete an organization (super_admin only)",
        "tags": [
          "rbac"
        ],
        "description": "Soft-deletes an organization by id. This administrative operation is restricted to super_admin callers.",
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "message"
                  ],
                  "properties": {
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/rbac/permissions": {
      "get": {
        "operationId": "getApiV1RbacPermissions",
        "summary": "List explicit permission grants (admin+ at scope, super_admin globally)",
        "tags": [
          "rbac"
        ],
        "description": "Returns explicit RBAC permission grants filtered by scope or user, visible only to callers with admin-level access at the requested scope.",
        "parameters": [
          {
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "enum": [
                    "organization"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "team"
                  ]
                }
              ]
            },
            "in": "query",
            "name": "scope_type",
            "required": false
          },
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "query",
            "name": "scope_id",
            "required": false
          },
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "query",
            "name": "user_id",
            "required": false
          }
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "items"
                  ],
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "id",
                          "user_id",
                          "role",
                          "scope_type",
                          "scope_id",
                          "user_email",
                          "user_name",
                          "created_at",
                          "updated_at"
                        ],
                        "properties": {
                          "id": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "user_id": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "role": {
                            "type": "string"
                          },
                          "scope_type": {
                            "type": "string"
                          },
                          "scope_id": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "user_email": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "user_name": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "created_at": {
                            "format": "date-time",
                            "type": "string"
                          },
                          "updated_at": {
                            "format": "date-time",
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "postApiV1RbacPermissions",
        "summary": "Grant an explicit permission (caller must hold admin+ at the target scope)",
        "tags": [
          "rbac"
        ],
        "description": "Creates an explicit role grant for a user at an organization or team (product \"Workspace\") scope.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "user_id",
                  "role",
                  "scope_type",
                  "scope_id"
                ],
                "properties": {
                  "user_id": {
                    "format": "uuid",
                    "type": "string"
                  },
                  "role": {
                    "anyOf": [
                      {
                        "type": "string",
                        "enum": [
                          "owner"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "admin"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "member"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "manager"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "mediabuyer"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "finance"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "viewer"
                        ]
                      }
                    ]
                  },
                  "scope_type": {
                    "anyOf": [
                      {
                        "type": "string",
                        "enum": [
                          "organization"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "team"
                        ]
                      }
                    ]
                  },
                  "scope_id": {
                    "format": "uuid",
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "201": {
            "description": "Resource created",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "id",
                    "user_id",
                    "role",
                    "scope_type",
                    "scope_id",
                    "user_email",
                    "user_name",
                    "created_at",
                    "updated_at"
                  ],
                  "properties": {
                    "id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "user_id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "role": {
                      "type": "string"
                    },
                    "scope_type": {
                      "type": "string"
                    },
                    "scope_id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "user_email": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "user_name": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "created_at": {
                      "format": "date-time",
                      "type": "string"
                    },
                    "updated_at": {
                      "format": "date-time",
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/rbac/permissions/{id}": {
      "delete": {
        "operationId": "deleteApiV1RbacPermissionsById",
        "summary": "Revoke an explicit permission (soft delete)",
        "tags": [
          "rbac"
        ],
        "description": "Soft-deletes an explicit RBAC permission grant after verifying the caller can administer the grant scope.",
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "message"
                  ],
                  "properties": {
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/rbac/scope": {
      "get": {
        "operationId": "getApiV1RbacScope",
        "summary": "Return current active scope (from x-active-scope header) and the list of accessible scopes",
        "tags": [
          "rbac"
        ],
        "description": "Returns the caller current active RBAC scope from the request header together with every organization and team (product \"Workspace\") scope they can access. Each accessible scope maps to a valid `x-active-scope` header value in `<scopeType>:<uuid>` form (omit the header for the all-workspaces view). The active scope drives workspace tenancy: reads are narrowed to the teams reachable from the scope, and write routes that create workspace-owned resources require an explicit destination team (`x-team-id` header or an active `team:<uuid>` scope) — without one they fail with 400 and code `SCOPE_TEAM_REQUIRED`.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "current",
                    "accessible"
                  ],
                  "properties": {
                    "current": {
                      "anyOf": [
                        {
                          "type": "object",
                          "required": [
                            "type",
                            "id",
                            "role"
                          ],
                          "properties": {
                            "type": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "enum": [
                                    "organization"
                                  ]
                                },
                                {
                                  "type": "string",
                                  "enum": [
                                    "team"
                                  ]
                                }
                              ]
                            },
                            "id": {
                              "format": "uuid",
                              "type": "string"
                            },
                            "role": {
                              "type": "string"
                            }
                          }
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "accessible": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "type",
                          "id",
                          "label",
                          "role"
                        ],
                        "properties": {
                          "type": {
                            "anyOf": [
                              {
                                "type": "string",
                                "enum": [
                                  "organization"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "team"
                                ]
                              }
                            ]
                          },
                          "id": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "label": {
                            "type": "string"
                          },
                          "role": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/rbac/scope/switch": {
      "post": {
        "operationId": "postApiV1RbacScopeSwitch",
        "summary": "Validate that a scope is accessible to the caller (server-side guard for the client switcher)",
        "tags": [
          "rbac"
        ],
        "description": "The client persists the selected scope locally and sends it back via x-active-scope on subsequent requests. This endpoint exists so the client can verify (and audit) the scope is reachable before storing it. Once stored, the scope becomes the workspace-tenancy context of every subsequent request: it narrows the accessible team set on reads and, for `team` scopes, selects the destination workspace for writes.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "scope_type",
                  "scope_id"
                ],
                "properties": {
                  "scope_type": {
                    "anyOf": [
                      {
                        "type": "string",
                        "enum": [
                          "organization"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "team"
                        ]
                      }
                    ]
                  },
                  "scope_id": {
                    "format": "uuid",
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "scope"
                  ],
                  "properties": {
                    "scope": {
                      "type": "object",
                      "required": [
                        "type",
                        "id",
                        "role"
                      ],
                      "properties": {
                        "type": {
                          "anyOf": [
                            {
                              "type": "string",
                              "enum": [
                                "organization"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "team"
                              ]
                            }
                          ]
                        },
                        "id": {
                          "format": "uuid",
                          "type": "string"
                        },
                        "role": {
                          "type": "string"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/rbac/team-memberships": {
      "get": {
        "operationId": "getApiV1RbacTeamMemberships",
        "summary": "List team memberships scoped to caller-accessible teams",
        "tags": [
          "rbac"
        ],
        "description": "Returns workspace (team) memberships visible to the caller, optionally filtered by team or organization within accessible RBAC scopes.",
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "query",
            "name": "team_id",
            "required": false
          },
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "query",
            "name": "organization_id",
            "required": false
          }
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "items"
                  ],
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "id",
                          "team_id",
                          "user_id",
                          "role",
                          "team_name",
                          "organization_id",
                          "user_email",
                          "user_name",
                          "created_at",
                          "updated_at"
                        ],
                        "properties": {
                          "id": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "team_id": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "user_id": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "role": {
                            "type": "string"
                          },
                          "team_name": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "organization_id": {
                            "anyOf": [
                              {
                                "format": "uuid",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "user_email": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "user_name": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "created_at": {
                            "format": "date-time",
                            "type": "string"
                          },
                          "updated_at": {
                            "format": "date-time",
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/rbac/teams/{id}/access-groups": {
      "get": {
        "operationId": "getApiV1RbacTeamsByIdAccessGroups",
        "summary": "List product Teams (access groups) attached to a workspace",
        "tags": [
          "rbac"
        ],
        "description": "Lists the product Teams (access groups) linked to a Workspace (team). Only organization owners/admins can read this list.",
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "items"
                  ],
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "additionalProperties": false,
                        "type": "object",
                        "required": [
                          "id",
                          "access_group_id",
                          "access_group_name",
                          "access_group_slug",
                          "team_id",
                          "created_at"
                        ],
                        "properties": {
                          "id": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "access_group_id": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "access_group_name": {
                            "type": "string"
                          },
                          "access_group_slug": {
                            "type": "string"
                          },
                          "team_id": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "created_at": {
                            "format": "date-time",
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/rbac/teams": {
      "get": {
        "operationId": "getApiV1RbacTeams",
        "summary": "List teams accessible to the current user",
        "tags": [
          "rbac"
        ],
        "description": "Returns workspaces (teams) visible to the authenticated user, optionally filtered by organization within the caller RBAC scope.",
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "query",
            "name": "organization_id",
            "required": false
          }
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "items"
                  ],
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "id",
                          "organization_id",
                          "name",
                          "slug",
                          "created_at",
                          "updated_at"
                        ],
                        "properties": {
                          "id": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "organization_id": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "name": {
                            "type": "string"
                          },
                          "slug": {
                            "type": "string"
                          },
                          "created_at": {
                            "format": "date-time",
                            "type": "string"
                          },
                          "updated_at": {
                            "format": "date-time",
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "postApiV1RbacTeams",
        "summary": "Create a workspace (organization owner+)",
        "tags": [
          "rbac"
        ],
        "description": "Creates a workspace (team) in an organization the caller can administer, enforcing the plan workspace quota and slug uniqueness.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "organization_id",
                  "name",
                  "slug"
                ],
                "properties": {
                  "organization_id": {
                    "format": "uuid",
                    "type": "string"
                  },
                  "name": {
                    "minLength": 1,
                    "maxLength": 255,
                    "type": "string"
                  },
                  "slug": {
                    "minLength": 1,
                    "maxLength": 100,
                    "pattern": "^[a-z0-9-]+$",
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "201": {
            "description": "Resource created",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "id",
                    "organization_id",
                    "name",
                    "slug",
                    "created_at",
                    "updated_at"
                  ],
                  "properties": {
                    "id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "organization_id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "name": {
                      "type": "string"
                    },
                    "slug": {
                      "type": "string"
                    },
                    "created_at": {
                      "format": "date-time",
                      "type": "string"
                    },
                    "updated_at": {
                      "format": "date-time",
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "402": {
            "description": "Response 402",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message",
                    "code",
                    "resource",
                    "current",
                    "max"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "resource": {
                      "type": "string"
                    },
                    "current": {
                      "type": "number"
                    },
                    "max": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "Conflict - resource state prevents the operation",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/rbac/teams/{id}": {
      "patch": {
        "operationId": "patchApiV1RbacTeamsById",
        "summary": "Update a team",
        "tags": [
          "rbac"
        ],
        "description": "Updates a workspace (team) name or slug after verifying owner-level or higher access at the parent organization scope.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "properties": {
                  "name": {
                    "minLength": 1,
                    "maxLength": 255,
                    "type": "string"
                  },
                  "slug": {
                    "minLength": 1,
                    "maxLength": 100,
                    "pattern": "^[a-z0-9-]+$",
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "id",
                    "organization_id",
                    "name",
                    "slug",
                    "created_at",
                    "updated_at"
                  ],
                  "properties": {
                    "id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "organization_id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "name": {
                      "type": "string"
                    },
                    "slug": {
                      "type": "string"
                    },
                    "created_at": {
                      "format": "date-time",
                      "type": "string"
                    },
                    "updated_at": {
                      "format": "date-time",
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "Conflict - resource state prevents the operation",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      },
      "delete": {
        "operationId": "deleteApiV1RbacTeamsById",
        "summary": "Soft-delete a team",
        "tags": [
          "rbac"
        ],
        "description": "Soft-deletes a workspace (team) after validating the caller has owner-level or higher access at the parent organization scope.",
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "message"
                  ],
                  "properties": {
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/release-candidates/{id}/trace": {
      "get": {
        "operationId": "getReleaseCandidateTrace",
        "summary": "Get full cross-system trace for a release candidate",
        "tags": [
          "release-candidates"
        ],
        "description": "Returns a release candidate together with its cluster, artifact links, ClickUp sync events and the latest 20 candidate state-change events. Useful for debugging the editorial pipeline end to end.",
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "candidate",
                    "cluster",
                    "artifact_links",
                    "clickup_syncs",
                    "events"
                  ],
                  "properties": {
                    "candidate": {
                      "type": "object",
                      "required": [
                        "id",
                        "title_raw",
                        "title_public_draft",
                        "status",
                        "github_pr_id",
                        "clickup_task_id",
                        "created_at"
                      ],
                      "properties": {
                        "id": {
                          "format": "uuid",
                          "type": "string"
                        },
                        "title_raw": {
                          "type": "string"
                        },
                        "title_public_draft": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "status": {
                          "description": "Lifecycle state of a release_candidate row.",
                          "anyOf": [
                            {
                              "type": "string",
                              "enum": [
                                "technical_event_received"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "candidate_generated"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "draft_ready"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "needs_review"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "approved_for_publish"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "published"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "rejected"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "merged_into_cluster"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "archived_internal"
                              ]
                            }
                          ]
                        },
                        "github_pr_id": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "clickup_task_id": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "created_at": {
                          "format": "date-time",
                          "type": "string"
                        }
                      }
                    },
                    "cluster": {
                      "anyOf": [
                        {
                          "additionalProperties": false,
                          "type": "object",
                          "required": [
                            "id",
                            "cluster_key",
                            "editorial_title",
                            "editorial_summary",
                            "visibility_target",
                            "publish_status",
                            "created_at",
                            "updated_at"
                          ],
                          "properties": {
                            "id": {
                              "format": "uuid",
                              "type": "string"
                            },
                            "cluster_key": {
                              "type": "string"
                            },
                            "editorial_title": {
                              "anyOf": [
                                {
                                  "type": "string"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "editorial_summary": {
                              "anyOf": [
                                {
                                  "type": "string"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "visibility_target": {
                              "type": "string"
                            },
                            "publish_status": {
                              "type": "string"
                            },
                            "created_at": {
                              "format": "date-time",
                              "type": "string"
                            },
                            "updated_at": {
                              "format": "date-time",
                              "type": "string"
                            }
                          }
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "artifact_links": {
                      "type": "array",
                      "items": {
                        "additionalProperties": false,
                        "type": "object",
                        "required": [
                          "id",
                          "github_pr_id",
                          "featurebase_post_id",
                          "clickup_task_id",
                          "release_candidate_id",
                          "release_cluster_id",
                          "link_type",
                          "last_status",
                          "created_at",
                          "updated_at"
                        ],
                        "properties": {
                          "id": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "github_pr_id": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "featurebase_post_id": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "clickup_task_id": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "release_candidate_id": {
                            "anyOf": [
                              {
                                "format": "uuid",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "release_cluster_id": {
                            "anyOf": [
                              {
                                "format": "uuid",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "link_type": {
                            "type": "string"
                          },
                          "last_status": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "created_at": {
                            "format": "date-time",
                            "type": "string"
                          },
                          "updated_at": {
                            "format": "date-time",
                            "type": "string"
                          }
                        }
                      }
                    },
                    "clickup_syncs": {
                      "type": "array",
                      "items": {
                        "additionalProperties": false,
                        "type": "object",
                        "required": [
                          "id",
                          "clickup_task_id",
                          "source_release_candidate_id",
                          "source_featurebase_post_id",
                          "event_type",
                          "delivery_status",
                          "delivered_at",
                          "error_code",
                          "created_at"
                        ],
                        "properties": {
                          "id": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "clickup_task_id": {
                            "type": "string"
                          },
                          "source_release_candidate_id": {
                            "anyOf": [
                              {
                                "format": "uuid",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "source_featurebase_post_id": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "event_type": {
                            "type": "string"
                          },
                          "delivery_status": {
                            "type": "string"
                          },
                          "delivered_at": {
                            "anyOf": [
                              {
                                "format": "date-time",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "error_code": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "created_at": {
                            "format": "date-time",
                            "type": "string"
                          }
                        }
                      }
                    },
                    "events": {
                      "type": "array",
                      "items": {
                        "additionalProperties": false,
                        "type": "object",
                        "required": [
                          "id",
                          "release_candidate_id",
                          "from_status",
                          "to_status",
                          "actor_type",
                          "actor_id",
                          "note",
                          "created_at"
                        ],
                        "properties": {
                          "id": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "release_candidate_id": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "from_status": {
                            "anyOf": [
                              {
                                "description": "Lifecycle state of a release_candidate row.",
                                "anyOf": [
                                  {
                                    "type": "string",
                                    "enum": [
                                      "technical_event_received"
                                    ]
                                  },
                                  {
                                    "type": "string",
                                    "enum": [
                                      "candidate_generated"
                                    ]
                                  },
                                  {
                                    "type": "string",
                                    "enum": [
                                      "draft_ready"
                                    ]
                                  },
                                  {
                                    "type": "string",
                                    "enum": [
                                      "needs_review"
                                    ]
                                  },
                                  {
                                    "type": "string",
                                    "enum": [
                                      "approved_for_publish"
                                    ]
                                  },
                                  {
                                    "type": "string",
                                    "enum": [
                                      "published"
                                    ]
                                  },
                                  {
                                    "type": "string",
                                    "enum": [
                                      "rejected"
                                    ]
                                  },
                                  {
                                    "type": "string",
                                    "enum": [
                                      "merged_into_cluster"
                                    ]
                                  },
                                  {
                                    "type": "string",
                                    "enum": [
                                      "archived_internal"
                                    ]
                                  }
                                ]
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "to_status": {
                            "description": "Lifecycle state of a release_candidate row.",
                            "anyOf": [
                              {
                                "type": "string",
                                "enum": [
                                  "technical_event_received"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "candidate_generated"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "draft_ready"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "needs_review"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "approved_for_publish"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "published"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "rejected"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "merged_into_cluster"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "archived_internal"
                                ]
                              }
                            ]
                          },
                          "actor_type": {
                            "type": "string"
                          },
                          "actor_id": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "note": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "created_at": {
                            "format": "date-time",
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/reports/pdf": {
      "post": {
        "operationId": "enqueuePdfReport",
        "summary": "Enqueue a PDF report generation job",
        "tags": [
          "reports"
        ],
        "description": "Creates a worker_run and enqueues a GENERATE_PDF_REPORT job for the authenticated session. Returns the canonical async-job envelope (worker_run_id mirrored as job_id, recommended polling cadence). Clients poll GET /api/v1/reports/:id/pdf-url for the signed URL once status is COMPLETED.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "from_date",
                  "to_date"
                ],
                "properties": {
                  "from_date": {
                    "format": "date",
                    "type": "string"
                  },
                  "to_date": {
                    "format": "date",
                    "type": "string"
                  },
                  "ad_account_ids": {
                    "type": "array",
                    "items": {
                      "minLength": 1,
                      "type": "string"
                    }
                  },
                  "campaign_ids": {
                    "type": "array",
                    "items": {
                      "minLength": 1,
                      "type": "string"
                    }
                  },
                  "campaign_statuses": {
                    "type": "array",
                    "items": {
                      "minLength": 1,
                      "type": "string"
                    }
                  },
                  "conversion_source": {
                    "description": "Revenue/conversion data source. \"postback\" (default) uses postback conversions; \"all\" aggregates platform-native purchase data across every platform; a platform value (e.g. \"meta\", \"google\") scopes platform-native revenue to that platform.",
                    "anyOf": [
                      {
                        "type": "string",
                        "enum": [
                          "postback"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "all"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "meta"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "google"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "tiktok"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "taboola"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "snapchat"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "outbrain"
                        ]
                      }
                    ]
                  },
                  "team_scope": {
                    "anyOf": [
                      {
                        "type": "string",
                        "enum": [
                          "all"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "self"
                        ]
                      }
                    ]
                  },
                  "platforms": {
                    "type": "array",
                    "items": {
                      "minLength": 1,
                      "maxLength": 20,
                      "type": "string"
                    }
                  },
                  "template_id": {
                    "format": "uuid",
                    "type": "string"
                  },
                  "group_by": {
                    "description": "Aggregation level of the exported rows. Defaults to campaign.",
                    "anyOf": [
                      {
                        "type": "string",
                        "enum": [
                          "campaign"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "adset"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "ad"
                        ]
                      }
                    ]
                  },
                  "format": {
                    "anyOf": [
                      {
                        "type": "string",
                        "enum": [
                          "pdf"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "csv"
                        ]
                      }
                    ]
                  },
                  "labels": {
                    "additionalProperties": false,
                    "type": "object",
                    "properties": {
                      "title": {
                        "maxLength": 120,
                        "type": "string"
                      },
                      "agency": {
                        "maxLength": 120,
                        "type": "string"
                      },
                      "period": {
                        "maxLength": 120,
                        "type": "string"
                      },
                      "currency": {
                        "maxLength": 120,
                        "type": "string"
                      },
                      "generated": {
                        "maxLength": 120,
                        "type": "string"
                      },
                      "filenameBase": {
                        "maxLength": 120,
                        "type": "string"
                      },
                      "platformColumn": {
                        "maxLength": 60,
                        "type": "string"
                      },
                      "platformLabel": {
                        "maxLength": 60,
                        "type": "string"
                      },
                      "platformNames": {
                        "type": "object",
                        "additionalProperties": {
                          "maxLength": 60,
                          "type": "string"
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "202": {
            "description": "Accepted - processing asynchronously",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "job_id",
                    "worker_run_id",
                    "status",
                    "polling_interval_ms",
                    "created_at"
                  ],
                  "properties": {
                    "job_id": {
                      "format": "uuid",
                      "description": "Canonical async-job identifier - mirrors `worker_run_id` for cross-domain SDK consistency.",
                      "type": "string"
                    },
                    "worker_run_id": {
                      "format": "uuid",
                      "description": "Worker run identifier. Poll GET /api/v1/reports/:id/pdf-url for progress.",
                      "type": "string"
                    },
                    "status": {
                      "description": "Current job status. One of: RUNNING, COMPLETED, FAILED.",
                      "type": "string"
                    },
                    "polling_interval_ms": {
                      "minimum": 500,
                      "description": "Recommended polling interval (ms) for the matching status endpoint.",
                      "type": "integer"
                    },
                    "estimated_wait_ms": {
                      "minimum": 0,
                      "description": "Best-effort estimate of remaining work, in milliseconds.",
                      "type": "integer"
                    },
                    "created_at": {
                      "format": "date-time",
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/reports/{id}/retry": {
      "post": {
        "operationId": "retryReportExport",
        "summary": "Retry a failed report export job",
        "tags": [
          "reports"
        ],
        "description": "Re-enqueues a previously failed report export using its original payload (stored on the enqueued worker_run_event). Team-stamped runs follow current workspace access; legacy runs without a team stamp remain original-owner only. Returns the new worker_run as the canonical async-job envelope.",
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "202": {
            "description": "Accepted - processing asynchronously",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "job_id",
                    "worker_run_id",
                    "status",
                    "polling_interval_ms",
                    "created_at"
                  ],
                  "properties": {
                    "job_id": {
                      "format": "uuid",
                      "description": "Canonical async-job identifier - mirrors `worker_run_id` for cross-domain SDK consistency.",
                      "type": "string"
                    },
                    "worker_run_id": {
                      "format": "uuid",
                      "description": "Worker run identifier. Poll GET /api/v1/reports/:id/pdf-url for progress.",
                      "type": "string"
                    },
                    "status": {
                      "description": "Current job status. One of: RUNNING, COMPLETED, FAILED.",
                      "type": "string"
                    },
                    "polling_interval_ms": {
                      "minimum": 500,
                      "description": "Recommended polling interval (ms) for the matching status endpoint.",
                      "type": "integer"
                    },
                    "estimated_wait_ms": {
                      "minimum": 0,
                      "description": "Best-effort estimate of remaining work, in milliseconds.",
                      "type": "integer"
                    },
                    "created_at": {
                      "format": "date-time",
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "Conflict - resource state prevents the operation",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/reports/{id}/pdf-url": {
      "get": {
        "operationId": "getReportPdfUrl",
        "summary": "Poll status of a PDF report job and retrieve its signed URL",
        "tags": [
          "reports"
        ],
        "description": "Returns the current job status and, when COMPLETED, a freshly signed S3 download URL with its `expires_at` timestamp (~7 days). Accepts both on-demand exports and scheduled sends. Access follows the current workspace for team-stamped runs; legacy runs without a team stamp remain original-owner only. The URL is regenerated on demand from the stored S3 key, so completed runs remain re-downloadable for the lifetime of the underlying object.",
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "status",
                    "pdf_url",
                    "expires_at"
                  ],
                  "properties": {
                    "status": {
                      "anyOf": [
                        {
                          "type": "string",
                          "enum": [
                            "RUNNING"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "COMPLETED"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "FAILED"
                          ]
                        }
                      ]
                    },
                    "pdf_url": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "expires_at": {
                      "anyOf": [
                        {
                          "format": "date-time",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/reports/exports": {
      "get": {
        "operationId": "listReportExports",
        "summary": "List recent report exports visible in the current workspace scope",
        "tags": [
          "reports"
        ],
        "description": "Persistent history of recent PDF/CSV report exports visible to the authenticated caller, ordered newest first, covering both on-demand exports and scheduled sends. Team-stamped runs follow current workspace access; legacy runs without a team stamp remain original-owner only. Reads worker_run rows joined on the enqueued worker_run_event metadata so the Download Center UI can re-hydrate after a page refresh without losing track of completed exports whose presigned URLs have already expired.",
        "parameters": [
          {
            "schema": {
              "minimum": 1,
              "maximum": 100,
              "type": "integer"
            },
            "in": "query",
            "name": "limit",
            "required": false
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "items"
                  ],
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "id",
                          "format",
                          "status",
                          "display_name",
                          "title",
                          "from_date",
                          "to_date",
                          "created_at",
                          "completed_at",
                          "error_message",
                          "origin",
                          "retryable"
                        ],
                        "properties": {
                          "id": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "format": {
                            "anyOf": [
                              {
                                "type": "string",
                                "enum": [
                                  "pdf"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "csv"
                                ]
                              }
                            ]
                          },
                          "status": {
                            "anyOf": [
                              {
                                "type": "string",
                                "enum": [
                                  "RUNNING"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "COMPLETED"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "FAILED"
                                ]
                              }
                            ]
                          },
                          "display_name": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "title": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "from_date": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "to_date": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "created_at": {
                            "type": "string"
                          },
                          "completed_at": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "error_message": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "origin": {
                            "description": "Who asked for this artifact: `on_demand` = the caller pressed Export; `scheduled` = a recurring send produced it. The UI must not treat a scheduled artifact as a download the user is waiting on.",
                            "anyOf": [
                              {
                                "type": "string",
                                "enum": [
                                  "on_demand"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "scheduled"
                                ]
                              }
                            ]
                          },
                          "retryable": {
                            "description": "Whether POST /api/v1/reports/{id}/retry accepts this run. Only on-demand exports carry the stored request payload a retry replays; a scheduled send is re-run from its schedule instead.",
                            "type": "boolean"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/report-schedules": {
      "get": {
        "operationId": "listReportSchedules",
        "summary": "List report schedules visible in the current workspace scope",
        "tags": [
          "reports"
        ],
        "description": "Returns every active (non-deleted) report schedule visible to the caller: schedules stamped with one of the accessible team ids (workspace tenancy) plus the caller’s own legacy schedules without a team stamp. Includes template binding, recurrence configuration, recipients, and last/next run timestamps. Readable even when the scheduled-sends feature flag is off, so an owner can always find and stop the schedules they already have.",
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "header",
            "name": "x-team-id",
            "required": false,
            "description": "Destination workspace team id."
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "items"
                  ],
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "id",
                          "name",
                          "template_id",
                          "frequency",
                          "day_of_week",
                          "day_of_month",
                          "hour_utc",
                          "recipients",
                          "format",
                          "ad_account_ids",
                          "platforms",
                          "period",
                          "is_active",
                          "last_run_at",
                          "next_run_at",
                          "created_at"
                        ],
                        "properties": {
                          "id": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "name": {
                            "type": "string"
                          },
                          "template_id": {
                            "anyOf": [
                              {
                                "format": "uuid",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "frequency": {
                            "anyOf": [
                              {
                                "type": "string",
                                "enum": [
                                  "daily"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "weekly"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "monthly"
                                ]
                              }
                            ]
                          },
                          "day_of_week": {
                            "anyOf": [
                              {
                                "minimum": 0,
                                "maximum": 6,
                                "type": "integer"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "day_of_month": {
                            "anyOf": [
                              {
                                "minimum": 1,
                                "maximum": 28,
                                "type": "integer"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "hour_utc": {
                            "minimum": 0,
                            "maximum": 23,
                            "type": "integer"
                          },
                          "recipients": {
                            "type": "array",
                            "items": {
                              "additionalProperties": false,
                              "type": "object",
                              "required": [
                                "email"
                              ],
                              "properties": {
                                "email": {
                                  "format": "email",
                                  "type": "string"
                                },
                                "name": {
                                  "maxLength": 255,
                                  "type": "string"
                                }
                              }
                            }
                          },
                          "format": {
                            "anyOf": [
                              {
                                "type": "string",
                                "enum": [
                                  "pdf"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "csv"
                                ]
                              }
                            ]
                          },
                          "ad_account_ids": {
                            "type": "array",
                            "items": {
                              "type": "string"
                            }
                          },
                          "platforms": {
                            "type": "array",
                            "items": {
                              "type": "string"
                            }
                          },
                          "period": {
                            "anyOf": [
                              {
                                "description": "Rolling window recomputed at every run. Omitted/null falls back to the template period, else last 7 days.",
                                "anyOf": [
                                  {
                                    "type": "string",
                                    "enum": [
                                      "last7d"
                                    ]
                                  },
                                  {
                                    "type": "string",
                                    "enum": [
                                      "last14d"
                                    ]
                                  },
                                  {
                                    "type": "string",
                                    "enum": [
                                      "last30d"
                                    ]
                                  },
                                  {
                                    "type": "string",
                                    "enum": [
                                      "last90d"
                                    ]
                                  },
                                  {
                                    "type": "string",
                                    "enum": [
                                      "mtd"
                                    ]
                                  }
                                ]
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "is_active": {
                            "type": "boolean"
                          },
                          "last_run_at": {
                            "anyOf": [
                              {
                                "format": "date-time",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "next_run_at": {
                            "anyOf": [
                              {
                                "format": "date-time",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "created_at": {
                            "format": "date-time",
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "createReportSchedule",
        "summary": "Create a report schedule",
        "tags": [
          "reports"
        ],
        "description": "Creates a recurring report schedule stamped with the explicit destination workspace/team resolved by x-team-id or the active team/workspace scope. Requests without a resolvable destination fail with 400 SCOPE_TEAM_REQUIRED; there is no silent primary-team fallback. The cron loop picks it up at the configured cadence (daily/weekly/monthly + hour_utc) and enqueues GENERATE_SCHEDULED_REPORT jobs that email the artifact to the configured recipients. Optional `template_id` must reference a template visible in the destination team scope.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "name",
                  "frequency",
                  "recipients"
                ],
                "properties": {
                  "name": {
                    "minLength": 1,
                    "maxLength": 255,
                    "type": "string"
                  },
                  "template_id": {
                    "anyOf": [
                      {
                        "format": "uuid",
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "frequency": {
                    "anyOf": [
                      {
                        "type": "string",
                        "enum": [
                          "daily"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "weekly"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "monthly"
                        ]
                      }
                    ]
                  },
                  "day_of_week": {
                    "anyOf": [
                      {
                        "minimum": 0,
                        "maximum": 6,
                        "type": "integer"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "day_of_month": {
                    "anyOf": [
                      {
                        "minimum": 1,
                        "maximum": 28,
                        "type": "integer"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "hour_utc": {
                    "minimum": 0,
                    "maximum": 23,
                    "type": "integer"
                  },
                  "recipients": {
                    "minItems": 1,
                    "maxItems": 10,
                    "description": "Destination inboxes. Up to 10 on paid plans; lower plans are capped further and may be restricted to the owner's own address.",
                    "type": "array",
                    "items": {
                      "additionalProperties": false,
                      "type": "object",
                      "required": [
                        "email"
                      ],
                      "properties": {
                        "email": {
                          "format": "email",
                          "type": "string"
                        },
                        "name": {
                          "maxLength": 255,
                          "type": "string"
                        }
                      }
                    }
                  },
                  "format": {
                    "anyOf": [
                      {
                        "type": "string",
                        "enum": [
                          "pdf"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "csv"
                        ]
                      }
                    ]
                  },
                  "ad_account_ids": {
                    "maxItems": 50,
                    "description": "Ad accounts included in the export. Empty/omitted = every account in scope.",
                    "type": "array",
                    "items": {
                      "minLength": 1,
                      "type": "string"
                    }
                  },
                  "platforms": {
                    "maxItems": 10,
                    "description": "Restricts the export to these ad platforms (meta, google, tiktok, taboola, snapchat, outbrain). Empty = every platform, and the export gains a Platform column.",
                    "type": "array",
                    "items": {
                      "minLength": 1,
                      "maxLength": 20,
                      "type": "string"
                    }
                  },
                  "period": {
                    "anyOf": [
                      {
                        "description": "Rolling window recomputed at every run. Omitted/null falls back to the template period, else last 7 days.",
                        "anyOf": [
                          {
                            "type": "string",
                            "enum": [
                              "last7d"
                            ]
                          },
                          {
                            "type": "string",
                            "enum": [
                              "last14d"
                            ]
                          },
                          {
                            "type": "string",
                            "enum": [
                              "last30d"
                            ]
                          },
                          {
                            "type": "string",
                            "enum": [
                              "last90d"
                            ]
                          },
                          {
                            "type": "string",
                            "enum": [
                              "mtd"
                            ]
                          }
                        ]
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "is_active": {
                    "type": "boolean"
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "header",
            "name": "x-team-id",
            "required": false,
            "description": "Destination workspace team id."
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "201": {
            "description": "Resource created",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "id",
                    "name",
                    "template_id",
                    "frequency",
                    "day_of_week",
                    "day_of_month",
                    "hour_utc",
                    "recipients",
                    "format",
                    "ad_account_ids",
                    "platforms",
                    "period",
                    "is_active",
                    "last_run_at",
                    "next_run_at",
                    "created_at"
                  ],
                  "properties": {
                    "id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "name": {
                      "type": "string"
                    },
                    "template_id": {
                      "anyOf": [
                        {
                          "format": "uuid",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "frequency": {
                      "anyOf": [
                        {
                          "type": "string",
                          "enum": [
                            "daily"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "weekly"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "monthly"
                          ]
                        }
                      ]
                    },
                    "day_of_week": {
                      "anyOf": [
                        {
                          "minimum": 0,
                          "maximum": 6,
                          "type": "integer"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "day_of_month": {
                      "anyOf": [
                        {
                          "minimum": 1,
                          "maximum": 28,
                          "type": "integer"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "hour_utc": {
                      "minimum": 0,
                      "maximum": 23,
                      "type": "integer"
                    },
                    "recipients": {
                      "type": "array",
                      "items": {
                        "additionalProperties": false,
                        "type": "object",
                        "required": [
                          "email"
                        ],
                        "properties": {
                          "email": {
                            "format": "email",
                            "type": "string"
                          },
                          "name": {
                            "maxLength": 255,
                            "type": "string"
                          }
                        }
                      }
                    },
                    "format": {
                      "anyOf": [
                        {
                          "type": "string",
                          "enum": [
                            "pdf"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "csv"
                          ]
                        }
                      ]
                    },
                    "ad_account_ids": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "platforms": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "period": {
                      "anyOf": [
                        {
                          "description": "Rolling window recomputed at every run. Omitted/null falls back to the template period, else last 7 days.",
                          "anyOf": [
                            {
                              "type": "string",
                              "enum": [
                                "last7d"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "last14d"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "last30d"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "last90d"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "mtd"
                              ]
                            }
                          ]
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "is_active": {
                      "type": "boolean"
                    },
                    "last_run_at": {
                      "anyOf": [
                        {
                          "format": "date-time",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "next_run_at": {
                      "anyOf": [
                        {
                          "format": "date-time",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "created_at": {
                      "format": "date-time",
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "anyOf": [
                    {
                      "additionalProperties": false,
                      "type": "object",
                      "required": [
                        "error"
                      ],
                      "properties": {
                        "error": {
                          "type": "string"
                        }
                      }
                    },
                    {
                      "description": "Explicit destination workspace required: send the x-team-id header or activate a team scope for this operation.",
                      "additionalProperties": false,
                      "type": "object",
                      "required": [
                        "statusCode",
                        "error",
                        "message"
                      ],
                      "properties": {
                        "statusCode": {
                          "type": "number"
                        },
                        "error": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "code": {
                          "type": "string",
                          "enum": [
                            "SCOPE_TEAM_REQUIRED"
                          ]
                        }
                      }
                    },
                    {
                      "description": "The request failed schema validation.",
                      "type": "object",
                      "required": [
                        "statusCode",
                        "error",
                        "message"
                      ],
                      "properties": {
                        "statusCode": {
                          "type": "number"
                        },
                        "error": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "code": {
                          "type": "string"
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "402": {
            "description": "Response 402",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message",
                    "code",
                    "resource",
                    "current",
                    "max"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "resource": {
                      "type": "string",
                      "enum": [
                        "scheduled_report"
                      ]
                    },
                    "current": {
                      "type": "number"
                    },
                    "max": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "Service unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "anyOf": [
                    {
                      "additionalProperties": false,
                      "description": "Scheduled reports are not enabled for this account.",
                      "type": "object",
                      "required": [
                        "error",
                        "code"
                      ],
                      "properties": {
                        "error": {
                          "type": "string"
                        },
                        "code": {
                          "type": "string",
                          "enum": [
                            "FEATURE_DISABLED"
                          ]
                        }
                      }
                    },
                    {
                      "additionalProperties": false,
                      "description": "The caller’s plan could not be verified. Retry.",
                      "type": "object",
                      "required": [
                        "error",
                        "code",
                        "retry_after_seconds"
                      ],
                      "properties": {
                        "error": {
                          "type": "string"
                        },
                        "code": {
                          "type": "string",
                          "enum": [
                            "SCHEDULED_REPORT_PLAN_UNAVAILABLE"
                          ]
                        },
                        "retry_after_seconds": {
                          "minimum": 1,
                          "type": "integer"
                        }
                      }
                    }
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/report-schedules/{id}": {
      "get": {
        "operationId": "getReportSchedule",
        "summary": "Get a report schedule",
        "tags": [
          "reports"
        ],
        "description": "Returns a single schedule by id. Scoped to the caller’s accessible workspaces (plus own legacy schedules) - returns 404 when outside that scope. Readable even when the scheduled-sends feature flag is off, so an owner can always find and stop the schedules they already have.",
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          },
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "header",
            "name": "x-team-id",
            "required": false,
            "description": "Destination workspace team id."
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "id",
                    "name",
                    "template_id",
                    "frequency",
                    "day_of_week",
                    "day_of_month",
                    "hour_utc",
                    "recipients",
                    "format",
                    "ad_account_ids",
                    "platforms",
                    "period",
                    "is_active",
                    "last_run_at",
                    "next_run_at",
                    "created_at"
                  ],
                  "properties": {
                    "id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "name": {
                      "type": "string"
                    },
                    "template_id": {
                      "anyOf": [
                        {
                          "format": "uuid",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "frequency": {
                      "anyOf": [
                        {
                          "type": "string",
                          "enum": [
                            "daily"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "weekly"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "monthly"
                          ]
                        }
                      ]
                    },
                    "day_of_week": {
                      "anyOf": [
                        {
                          "minimum": 0,
                          "maximum": 6,
                          "type": "integer"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "day_of_month": {
                      "anyOf": [
                        {
                          "minimum": 1,
                          "maximum": 28,
                          "type": "integer"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "hour_utc": {
                      "minimum": 0,
                      "maximum": 23,
                      "type": "integer"
                    },
                    "recipients": {
                      "type": "array",
                      "items": {
                        "additionalProperties": false,
                        "type": "object",
                        "required": [
                          "email"
                        ],
                        "properties": {
                          "email": {
                            "format": "email",
                            "type": "string"
                          },
                          "name": {
                            "maxLength": 255,
                            "type": "string"
                          }
                        }
                      }
                    },
                    "format": {
                      "anyOf": [
                        {
                          "type": "string",
                          "enum": [
                            "pdf"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "csv"
                          ]
                        }
                      ]
                    },
                    "ad_account_ids": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "platforms": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "period": {
                      "anyOf": [
                        {
                          "description": "Rolling window recomputed at every run. Omitted/null falls back to the template period, else last 7 days.",
                          "anyOf": [
                            {
                              "type": "string",
                              "enum": [
                                "last7d"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "last14d"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "last30d"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "last90d"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "mtd"
                              ]
                            }
                          ]
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "is_active": {
                      "type": "boolean"
                    },
                    "last_run_at": {
                      "anyOf": [
                        {
                          "format": "date-time",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "next_run_at": {
                      "anyOf": [
                        {
                          "format": "date-time",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "created_at": {
                      "format": "date-time",
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      },
      "put": {
        "operationId": "updateReportSchedule",
        "summary": "Update a report schedule",
        "tags": [
          "reports"
        ],
        "description": "Partially updates the schedule. Any subset of mutable fields may be supplied. Recomputes `next_run_at` if cadence (frequency / day_of_week / day_of_month / hour_utc) changes. Returns 400 if `template_id` is reassigned to a template not owned by the session. Responds 503 when scheduled reports are disabled for the caller, EXCEPT for a body of exactly `{\"is_active\": false}` - pausing your own sends is always allowed.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "properties": {
                  "name": {
                    "minLength": 1,
                    "maxLength": 255,
                    "type": "string"
                  },
                  "template_id": {
                    "anyOf": [
                      {
                        "format": "uuid",
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "frequency": {
                    "anyOf": [
                      {
                        "type": "string",
                        "enum": [
                          "daily"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "weekly"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "monthly"
                        ]
                      }
                    ]
                  },
                  "day_of_week": {
                    "anyOf": [
                      {
                        "minimum": 0,
                        "maximum": 6,
                        "type": "integer"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "day_of_month": {
                    "anyOf": [
                      {
                        "minimum": 1,
                        "maximum": 28,
                        "type": "integer"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "hour_utc": {
                    "minimum": 0,
                    "maximum": 23,
                    "type": "integer"
                  },
                  "recipients": {
                    "minItems": 1,
                    "maxItems": 10,
                    "description": "Destination inboxes. Up to 10 on paid plans; lower plans are capped further and may be restricted to the owner's own address.",
                    "type": "array",
                    "items": {
                      "additionalProperties": false,
                      "type": "object",
                      "required": [
                        "email"
                      ],
                      "properties": {
                        "email": {
                          "format": "email",
                          "type": "string"
                        },
                        "name": {
                          "maxLength": 255,
                          "type": "string"
                        }
                      }
                    }
                  },
                  "format": {
                    "anyOf": [
                      {
                        "type": "string",
                        "enum": [
                          "pdf"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "csv"
                        ]
                      }
                    ]
                  },
                  "ad_account_ids": {
                    "maxItems": 50,
                    "description": "Ad accounts included in the export. Empty/omitted = every account in scope.",
                    "type": "array",
                    "items": {
                      "minLength": 1,
                      "type": "string"
                    }
                  },
                  "platforms": {
                    "maxItems": 10,
                    "description": "Restricts the export to these ad platforms (meta, google, tiktok, taboola, snapchat, outbrain). Empty = every platform, and the export gains a Platform column.",
                    "type": "array",
                    "items": {
                      "minLength": 1,
                      "maxLength": 20,
                      "type": "string"
                    }
                  },
                  "period": {
                    "anyOf": [
                      {
                        "description": "Rolling window recomputed at every run. Omitted/null falls back to the template period, else last 7 days.",
                        "anyOf": [
                          {
                            "type": "string",
                            "enum": [
                              "last7d"
                            ]
                          },
                          {
                            "type": "string",
                            "enum": [
                              "last14d"
                            ]
                          },
                          {
                            "type": "string",
                            "enum": [
                              "last30d"
                            ]
                          },
                          {
                            "type": "string",
                            "enum": [
                              "last90d"
                            ]
                          },
                          {
                            "type": "string",
                            "enum": [
                              "mtd"
                            ]
                          }
                        ]
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "is_active": {
                    "type": "boolean"
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          },
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "header",
            "name": "x-team-id",
            "required": false,
            "description": "Destination workspace team id."
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "id",
                    "name",
                    "template_id",
                    "frequency",
                    "day_of_week",
                    "day_of_month",
                    "hour_utc",
                    "recipients",
                    "format",
                    "ad_account_ids",
                    "platforms",
                    "period",
                    "is_active",
                    "last_run_at",
                    "next_run_at",
                    "created_at"
                  ],
                  "properties": {
                    "id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "name": {
                      "type": "string"
                    },
                    "template_id": {
                      "anyOf": [
                        {
                          "format": "uuid",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "frequency": {
                      "anyOf": [
                        {
                          "type": "string",
                          "enum": [
                            "daily"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "weekly"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "monthly"
                          ]
                        }
                      ]
                    },
                    "day_of_week": {
                      "anyOf": [
                        {
                          "minimum": 0,
                          "maximum": 6,
                          "type": "integer"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "day_of_month": {
                      "anyOf": [
                        {
                          "minimum": 1,
                          "maximum": 28,
                          "type": "integer"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "hour_utc": {
                      "minimum": 0,
                      "maximum": 23,
                      "type": "integer"
                    },
                    "recipients": {
                      "type": "array",
                      "items": {
                        "additionalProperties": false,
                        "type": "object",
                        "required": [
                          "email"
                        ],
                        "properties": {
                          "email": {
                            "format": "email",
                            "type": "string"
                          },
                          "name": {
                            "maxLength": 255,
                            "type": "string"
                          }
                        }
                      }
                    },
                    "format": {
                      "anyOf": [
                        {
                          "type": "string",
                          "enum": [
                            "pdf"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "csv"
                          ]
                        }
                      ]
                    },
                    "ad_account_ids": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "platforms": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "period": {
                      "anyOf": [
                        {
                          "description": "Rolling window recomputed at every run. Omitted/null falls back to the template period, else last 7 days.",
                          "anyOf": [
                            {
                              "type": "string",
                              "enum": [
                                "last7d"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "last14d"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "last30d"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "last90d"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "mtd"
                              ]
                            }
                          ]
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "is_active": {
                      "type": "boolean"
                    },
                    "last_run_at": {
                      "anyOf": [
                        {
                          "format": "date-time",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "next_run_at": {
                      "anyOf": [
                        {
                          "format": "date-time",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "created_at": {
                      "format": "date-time",
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "anyOf": [
                    {
                      "additionalProperties": false,
                      "type": "object",
                      "required": [
                        "error"
                      ],
                      "properties": {
                        "error": {
                          "type": "string"
                        }
                      }
                    },
                    {
                      "description": "Explicit destination workspace required: send the x-team-id header or activate a team scope for this operation.",
                      "additionalProperties": false,
                      "type": "object",
                      "required": [
                        "statusCode",
                        "error",
                        "message"
                      ],
                      "properties": {
                        "statusCode": {
                          "type": "number"
                        },
                        "error": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "code": {
                          "type": "string",
                          "enum": [
                            "SCOPE_TEAM_REQUIRED"
                          ]
                        }
                      }
                    },
                    {
                      "description": "The request failed schema validation.",
                      "type": "object",
                      "required": [
                        "statusCode",
                        "error",
                        "message"
                      ],
                      "properties": {
                        "statusCode": {
                          "type": "number"
                        },
                        "error": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "code": {
                          "type": "string"
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "Service unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "anyOf": [
                    {
                      "additionalProperties": false,
                      "description": "Scheduled reports are not enabled for this account.",
                      "type": "object",
                      "required": [
                        "error",
                        "code"
                      ],
                      "properties": {
                        "error": {
                          "type": "string"
                        },
                        "code": {
                          "type": "string",
                          "enum": [
                            "FEATURE_DISABLED"
                          ]
                        }
                      }
                    },
                    {
                      "additionalProperties": false,
                      "description": "The caller’s plan could not be verified. Retry.",
                      "type": "object",
                      "required": [
                        "error",
                        "code",
                        "retry_after_seconds"
                      ],
                      "properties": {
                        "error": {
                          "type": "string"
                        },
                        "code": {
                          "type": "string",
                          "enum": [
                            "SCHEDULED_REPORT_PLAN_UNAVAILABLE"
                          ]
                        },
                        "retry_after_seconds": {
                          "minimum": 1,
                          "type": "integer"
                        }
                      }
                    }
                  ]
                }
              }
            }
          }
        }
      },
      "delete": {
        "operationId": "deleteReportSchedule",
        "summary": "Soft delete a report schedule",
        "tags": [
          "reports"
        ],
        "description": "Marks the schedule as deleted (sets deleted_at) so the cron loop stops picking it up. Idempotent: returns 404 if the schedule was already deleted or never existed. Not gated by the scheduled-reports feature flag: stopping your own sends must stay possible while the feature is switched off.",
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          },
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "header",
            "name": "x-team-id",
            "required": false,
            "description": "Destination workspace team id."
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "204": {
            "description": "No content"
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "anyOf": [
                    {
                      "additionalProperties": false,
                      "type": "object",
                      "required": [
                        "error"
                      ],
                      "properties": {
                        "error": {
                          "type": "string"
                        }
                      }
                    },
                    {
                      "description": "Explicit destination workspace required: send the x-team-id header or activate a team scope for this operation.",
                      "additionalProperties": false,
                      "type": "object",
                      "required": [
                        "statusCode",
                        "error",
                        "message"
                      ],
                      "properties": {
                        "statusCode": {
                          "type": "number"
                        },
                        "error": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "code": {
                          "type": "string",
                          "enum": [
                            "SCOPE_TEAM_REQUIRED"
                          ]
                        }
                      }
                    },
                    {
                      "description": "The request failed schema validation.",
                      "type": "object",
                      "required": [
                        "statusCode",
                        "error",
                        "message"
                      ],
                      "properties": {
                        "statusCode": {
                          "type": "number"
                        },
                        "error": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "code": {
                          "type": "string"
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/report-schedules/{id}/run-now": {
      "post": {
        "operationId": "runReportScheduleNow",
        "summary": "Trigger immediate execution of a schedule",
        "tags": [
          "reports"
        ],
        "description": "Enqueues a one-off GENERATE_SCHEDULED_REPORT job for the given schedule, bypassing the cron cadence. The job emails the artifact to the schedule recipients and records a manual-trigger audit event. Returns the canonical async-job envelope (worker_run_id mirrored as job_id). A PAUSED schedule is refused with 409 SCHEDULED_REPORT_PAUSED: pausing is the customer's only brake on an outbound relay, so it binds this endpoint exactly as it binds the cron. Rate limited to 5 calls per 1 hour per user: one call is a PDF render plus an email fan-out, not a download.",
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          },
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "header",
            "name": "x-team-id",
            "required": false,
            "description": "Destination workspace team id."
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "202": {
            "description": "Accepted - processing asynchronously",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "job_id",
                    "worker_run_id",
                    "status",
                    "polling_interval_ms",
                    "created_at"
                  ],
                  "properties": {
                    "job_id": {
                      "format": "uuid",
                      "description": "Canonical async-job identifier - mirrors `worker_run_id` for cross-domain SDK consistency.",
                      "type": "string"
                    },
                    "worker_run_id": {
                      "format": "uuid",
                      "description": "Worker run identifier. Poll GET /api/v1/reports/:id/pdf-url for progress.",
                      "type": "string"
                    },
                    "status": {
                      "description": "Current job status. One of: RUNNING, COMPLETED, FAILED.",
                      "type": "string"
                    },
                    "polling_interval_ms": {
                      "minimum": 500,
                      "description": "Recommended polling interval (ms) for the matching status endpoint.",
                      "type": "integer"
                    },
                    "estimated_wait_ms": {
                      "minimum": 0,
                      "description": "Best-effort estimate of remaining work, in milliseconds.",
                      "type": "integer"
                    },
                    "created_at": {
                      "format": "date-time",
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "anyOf": [
                    {
                      "additionalProperties": false,
                      "type": "object",
                      "required": [
                        "error"
                      ],
                      "properties": {
                        "error": {
                          "type": "string"
                        }
                      }
                    },
                    {
                      "description": "Explicit destination workspace required: send the x-team-id header or activate a team scope for this operation.",
                      "additionalProperties": false,
                      "type": "object",
                      "required": [
                        "statusCode",
                        "error",
                        "message"
                      ],
                      "properties": {
                        "statusCode": {
                          "type": "number"
                        },
                        "error": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "code": {
                          "type": "string",
                          "enum": [
                            "SCOPE_TEAM_REQUIRED"
                          ]
                        }
                      }
                    },
                    {
                      "description": "The request failed schema validation.",
                      "type": "object",
                      "required": [
                        "statusCode",
                        "error",
                        "message"
                      ],
                      "properties": {
                        "statusCode": {
                          "type": "number"
                        },
                        "error": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "code": {
                          "type": "string"
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "The schedule is paused. Resume it before triggering an immediate send.",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "description": "The schedule is paused. Resume it before triggering an immediate send.",
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message",
                    "code"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "SCHEDULED_REPORT_PAUSED"
                      ]
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "Too many requests - rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "Scheduled reports are not enabled for this account.",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "description": "Scheduled reports are not enabled for this account.",
                  "type": "object",
                  "required": [
                    "error",
                    "code"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "FEATURE_DISABLED"
                      ]
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/report-templates": {
      "get": {
        "operationId": "listReportTemplates",
        "summary": "List report templates visible in the current workspace scope",
        "tags": [
          "reports"
        ],
        "description": "Returns every active (non-deleted) report template visible to the caller: templates stamped with one of the accessible team ids (workspace tenancy) plus the caller’s own legacy templates without a team stamp. Templates encapsulate the metric/column selection, grouping, period, format, and chart configuration reused by ad-hoc previews and recurring schedules.",
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "header",
            "name": "x-team-id",
            "required": false,
            "description": "Destination workspace team id."
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "items"
                  ],
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "id",
                          "name",
                          "description",
                          "definition",
                          "is_default",
                          "created_at",
                          "updated_at"
                        ],
                        "properties": {
                          "id": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "name": {
                            "type": "string"
                          },
                          "description": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "definition": {
                            "additionalProperties": false,
                            "type": "object",
                            "properties": {
                              "metrics": {
                                "type": "array",
                                "items": {
                                  "type": "string"
                                }
                              },
                              "columns": {
                                "type": "array",
                                "items": {
                                  "type": "string"
                                }
                              },
                              "groupBy": {
                                "anyOf": [
                                  {
                                    "type": "string",
                                    "enum": [
                                      "campaign"
                                    ]
                                  },
                                  {
                                    "type": "string",
                                    "enum": [
                                      "adset"
                                    ]
                                  },
                                  {
                                    "type": "string",
                                    "enum": [
                                      "ad"
                                    ]
                                  }
                                ]
                              },
                              "period": {
                                "anyOf": [
                                  {
                                    "type": "string",
                                    "enum": [
                                      "last7d"
                                    ]
                                  },
                                  {
                                    "type": "string",
                                    "enum": [
                                      "last14d"
                                    ]
                                  },
                                  {
                                    "type": "string",
                                    "enum": [
                                      "last30d"
                                    ]
                                  },
                                  {
                                    "type": "string",
                                    "enum": [
                                      "last90d"
                                    ]
                                  },
                                  {
                                    "type": "string",
                                    "enum": [
                                      "mtd"
                                    ]
                                  },
                                  {
                                    "type": "string",
                                    "enum": [
                                      "custom"
                                    ]
                                  }
                                ]
                              },
                              "format": {
                                "anyOf": [
                                  {
                                    "type": "string",
                                    "enum": [
                                      "pdf"
                                    ]
                                  },
                                  {
                                    "type": "string",
                                    "enum": [
                                      "csv"
                                    ]
                                  }
                                ]
                              },
                              "include_charts": {
                                "type": "boolean"
                              }
                            }
                          },
                          "is_default": {
                            "type": "boolean"
                          },
                          "created_at": {
                            "format": "date-time",
                            "type": "string"
                          },
                          "updated_at": {
                            "anyOf": [
                              {
                                "format": "date-time",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "createReportTemplate",
        "summary": "Create a new report template",
        "tags": [
          "reports"
        ],
        "description": "Creates a reusable report template stamped with the explicit destination workspace/team resolved by x-team-id or the active team/workspace scope. Requests without a resolvable destination fail with 400 SCOPE_TEAM_REQUIRED; there is no silent primary-team fallback. The optional `definition` block configures metrics, columns, group_by, period preset, output format, and whether charts are included.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "name"
                ],
                "properties": {
                  "name": {
                    "minLength": 1,
                    "maxLength": 255,
                    "type": "string"
                  },
                  "description": {
                    "anyOf": [
                      {
                        "maxLength": 2000,
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "definition": {
                    "additionalProperties": false,
                    "type": "object",
                    "properties": {
                      "metrics": {
                        "type": "array",
                        "items": {
                          "type": "string"
                        }
                      },
                      "columns": {
                        "type": "array",
                        "items": {
                          "type": "string"
                        }
                      },
                      "groupBy": {
                        "anyOf": [
                          {
                            "type": "string",
                            "enum": [
                              "campaign"
                            ]
                          },
                          {
                            "type": "string",
                            "enum": [
                              "adset"
                            ]
                          },
                          {
                            "type": "string",
                            "enum": [
                              "ad"
                            ]
                          }
                        ]
                      },
                      "period": {
                        "anyOf": [
                          {
                            "type": "string",
                            "enum": [
                              "last7d"
                            ]
                          },
                          {
                            "type": "string",
                            "enum": [
                              "last14d"
                            ]
                          },
                          {
                            "type": "string",
                            "enum": [
                              "last30d"
                            ]
                          },
                          {
                            "type": "string",
                            "enum": [
                              "last90d"
                            ]
                          },
                          {
                            "type": "string",
                            "enum": [
                              "mtd"
                            ]
                          },
                          {
                            "type": "string",
                            "enum": [
                              "custom"
                            ]
                          }
                        ]
                      },
                      "format": {
                        "anyOf": [
                          {
                            "type": "string",
                            "enum": [
                              "pdf"
                            ]
                          },
                          {
                            "type": "string",
                            "enum": [
                              "csv"
                            ]
                          }
                        ]
                      },
                      "include_charts": {
                        "type": "boolean"
                      }
                    }
                  },
                  "is_default": {
                    "type": "boolean"
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "header",
            "name": "x-team-id",
            "required": false,
            "description": "Destination workspace team id."
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "201": {
            "description": "Resource created",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "id",
                    "name",
                    "description",
                    "definition",
                    "is_default",
                    "created_at",
                    "updated_at"
                  ],
                  "properties": {
                    "id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "name": {
                      "type": "string"
                    },
                    "description": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "definition": {
                      "additionalProperties": false,
                      "type": "object",
                      "properties": {
                        "metrics": {
                          "type": "array",
                          "items": {
                            "type": "string"
                          }
                        },
                        "columns": {
                          "type": "array",
                          "items": {
                            "type": "string"
                          }
                        },
                        "groupBy": {
                          "anyOf": [
                            {
                              "type": "string",
                              "enum": [
                                "campaign"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "adset"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "ad"
                              ]
                            }
                          ]
                        },
                        "period": {
                          "anyOf": [
                            {
                              "type": "string",
                              "enum": [
                                "last7d"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "last14d"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "last30d"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "last90d"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "mtd"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "custom"
                              ]
                            }
                          ]
                        },
                        "format": {
                          "anyOf": [
                            {
                              "type": "string",
                              "enum": [
                                "pdf"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "csv"
                              ]
                            }
                          ]
                        },
                        "include_charts": {
                          "type": "boolean"
                        }
                      }
                    },
                    "is_default": {
                      "type": "boolean"
                    },
                    "created_at": {
                      "format": "date-time",
                      "type": "string"
                    },
                    "updated_at": {
                      "anyOf": [
                        {
                          "format": "date-time",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Explicit destination workspace required: send the x-team-id header or activate a team scope for this operation.",
            "content": {
              "application/json": {
                "schema": {
                  "description": "Explicit destination workspace required: send the x-team-id header or activate a team scope for this operation.",
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "SCOPE_TEAM_REQUIRED"
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/report-templates/{id}": {
      "get": {
        "operationId": "getReportTemplate",
        "summary": "Get a report template by id",
        "tags": [
          "reports"
        ],
        "description": "Returns a single template by id. Scoped to the caller’s accessible workspaces (plus own legacy templates) - returns 404 when outside that scope.",
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          },
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "header",
            "name": "x-team-id",
            "required": false,
            "description": "Destination workspace team id."
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "id",
                    "name",
                    "description",
                    "definition",
                    "is_default",
                    "created_at",
                    "updated_at"
                  ],
                  "properties": {
                    "id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "name": {
                      "type": "string"
                    },
                    "description": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "definition": {
                      "additionalProperties": false,
                      "type": "object",
                      "properties": {
                        "metrics": {
                          "type": "array",
                          "items": {
                            "type": "string"
                          }
                        },
                        "columns": {
                          "type": "array",
                          "items": {
                            "type": "string"
                          }
                        },
                        "groupBy": {
                          "anyOf": [
                            {
                              "type": "string",
                              "enum": [
                                "campaign"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "adset"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "ad"
                              ]
                            }
                          ]
                        },
                        "period": {
                          "anyOf": [
                            {
                              "type": "string",
                              "enum": [
                                "last7d"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "last14d"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "last30d"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "last90d"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "mtd"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "custom"
                              ]
                            }
                          ]
                        },
                        "format": {
                          "anyOf": [
                            {
                              "type": "string",
                              "enum": [
                                "pdf"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "csv"
                              ]
                            }
                          ]
                        },
                        "include_charts": {
                          "type": "boolean"
                        }
                      }
                    },
                    "is_default": {
                      "type": "boolean"
                    },
                    "created_at": {
                      "format": "date-time",
                      "type": "string"
                    },
                    "updated_at": {
                      "anyOf": [
                        {
                          "format": "date-time",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      },
      "put": {
        "operationId": "updateReportTemplate",
        "summary": "Update a report template",
        "tags": [
          "reports"
        ],
        "description": "Partially updates the template. Any subset of mutable fields may be supplied. Affects subsequent previews and any schedules referencing this template_id.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "properties": {
                  "name": {
                    "minLength": 1,
                    "maxLength": 255,
                    "type": "string"
                  },
                  "description": {
                    "anyOf": [
                      {
                        "maxLength": 2000,
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "definition": {
                    "additionalProperties": false,
                    "type": "object",
                    "properties": {
                      "metrics": {
                        "type": "array",
                        "items": {
                          "type": "string"
                        }
                      },
                      "columns": {
                        "type": "array",
                        "items": {
                          "type": "string"
                        }
                      },
                      "groupBy": {
                        "anyOf": [
                          {
                            "type": "string",
                            "enum": [
                              "campaign"
                            ]
                          },
                          {
                            "type": "string",
                            "enum": [
                              "adset"
                            ]
                          },
                          {
                            "type": "string",
                            "enum": [
                              "ad"
                            ]
                          }
                        ]
                      },
                      "period": {
                        "anyOf": [
                          {
                            "type": "string",
                            "enum": [
                              "last7d"
                            ]
                          },
                          {
                            "type": "string",
                            "enum": [
                              "last14d"
                            ]
                          },
                          {
                            "type": "string",
                            "enum": [
                              "last30d"
                            ]
                          },
                          {
                            "type": "string",
                            "enum": [
                              "last90d"
                            ]
                          },
                          {
                            "type": "string",
                            "enum": [
                              "mtd"
                            ]
                          },
                          {
                            "type": "string",
                            "enum": [
                              "custom"
                            ]
                          }
                        ]
                      },
                      "format": {
                        "anyOf": [
                          {
                            "type": "string",
                            "enum": [
                              "pdf"
                            ]
                          },
                          {
                            "type": "string",
                            "enum": [
                              "csv"
                            ]
                          }
                        ]
                      },
                      "include_charts": {
                        "type": "boolean"
                      }
                    }
                  },
                  "is_default": {
                    "type": "boolean"
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          },
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "header",
            "name": "x-team-id",
            "required": false,
            "description": "Destination workspace team id."
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "id",
                    "name",
                    "description",
                    "definition",
                    "is_default",
                    "created_at",
                    "updated_at"
                  ],
                  "properties": {
                    "id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "name": {
                      "type": "string"
                    },
                    "description": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "definition": {
                      "additionalProperties": false,
                      "type": "object",
                      "properties": {
                        "metrics": {
                          "type": "array",
                          "items": {
                            "type": "string"
                          }
                        },
                        "columns": {
                          "type": "array",
                          "items": {
                            "type": "string"
                          }
                        },
                        "groupBy": {
                          "anyOf": [
                            {
                              "type": "string",
                              "enum": [
                                "campaign"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "adset"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "ad"
                              ]
                            }
                          ]
                        },
                        "period": {
                          "anyOf": [
                            {
                              "type": "string",
                              "enum": [
                                "last7d"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "last14d"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "last30d"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "last90d"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "mtd"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "custom"
                              ]
                            }
                          ]
                        },
                        "format": {
                          "anyOf": [
                            {
                              "type": "string",
                              "enum": [
                                "pdf"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "csv"
                              ]
                            }
                          ]
                        },
                        "include_charts": {
                          "type": "boolean"
                        }
                      }
                    },
                    "is_default": {
                      "type": "boolean"
                    },
                    "created_at": {
                      "format": "date-time",
                      "type": "string"
                    },
                    "updated_at": {
                      "anyOf": [
                        {
                          "format": "date-time",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Explicit destination workspace required: send the x-team-id header or activate a team scope for this operation.",
            "content": {
              "application/json": {
                "schema": {
                  "description": "Explicit destination workspace required: send the x-team-id header or activate a team scope for this operation.",
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "SCOPE_TEAM_REQUIRED"
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      },
      "delete": {
        "operationId": "deleteReportTemplate",
        "summary": "Soft delete a report template",
        "tags": [
          "reports"
        ],
        "description": "Marks the template as deleted (sets deleted_at). Schedules referencing this template will fail their next run unless they are reconfigured. Idempotent: returns 404 if already deleted.",
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          },
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "header",
            "name": "x-team-id",
            "required": false,
            "description": "Destination workspace team id."
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "204": {
            "description": "No content"
          },
          "400": {
            "description": "Explicit destination workspace required: send the x-team-id header or activate a team scope for this operation.",
            "content": {
              "application/json": {
                "schema": {
                  "description": "Explicit destination workspace required: send the x-team-id header or activate a team scope for this operation.",
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "SCOPE_TEAM_REQUIRED"
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/report-templates/{id}/preview": {
      "post": {
        "operationId": "previewReportTemplate",
        "summary": "Generate a preview PDF for a template (async)",
        "tags": [
          "reports"
        ],
        "description": "Resolves the template period (relative or custom), creates a worker_run, and enqueues a GENERATE_PDF_REPORT job bound to the template. Returns the canonical async-job envelope (worker_run_id mirrored as job_id, recommended polling cadence). Client polls GET /api/v1/reports/:id/pdf-url for the signed URL once status is COMPLETED.",
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          },
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "header",
            "name": "x-team-id",
            "required": false,
            "description": "Destination workspace team id."
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "202": {
            "description": "Accepted - processing asynchronously",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "job_id",
                    "worker_run_id",
                    "status",
                    "polling_interval_ms",
                    "created_at"
                  ],
                  "properties": {
                    "job_id": {
                      "format": "uuid",
                      "description": "Canonical async-job identifier - mirrors `worker_run_id` for cross-domain SDK consistency.",
                      "type": "string"
                    },
                    "worker_run_id": {
                      "format": "uuid",
                      "description": "Worker run identifier. Poll GET /api/v1/reports/:id/pdf-url for progress.",
                      "type": "string"
                    },
                    "status": {
                      "description": "Current job status. One of: RUNNING, COMPLETED, FAILED.",
                      "type": "string"
                    },
                    "polling_interval_ms": {
                      "minimum": 500,
                      "description": "Recommended polling interval (ms) for the matching status endpoint.",
                      "type": "integer"
                    },
                    "estimated_wait_ms": {
                      "minimum": 0,
                      "description": "Best-effort estimate of remaining work, in milliseconds.",
                      "type": "integer"
                    },
                    "created_at": {
                      "format": "date-time",
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/reports/campaigns": {
      "post": {
        "operationId": "triggerCampaignReport",
        "summary": "Trigger campaign report generation",
        "tags": [
          "reports"
        ],
        "description": "Starts asynchronous campaign report generation for all connected ad accounts. Returns a worker_run_id (also exposed as the canonical job_id) plus a recommended polling interval. Clients should poll GET /api/v1/reports/:worker_run_id until status is COMPLETED or FAILED.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "from_date",
                  "to_date"
                ],
                "properties": {
                  "from_date": {
                    "format": "date",
                    "description": "Start date in YYYY-MM-DD format",
                    "type": "string"
                  },
                  "to_date": {
                    "format": "date",
                    "description": "End date in YYYY-MM-DD format",
                    "type": "string"
                  },
                  "timezone": {
                    "description": "Timezone for the report (e.g. America/New_York)",
                    "type": "string"
                  },
                  "platform": {
                    "description": "Ad platform - defaults to \"meta\" when omitted (preserves the legacy Meta-only flow).",
                    "anyOf": [
                      {
                        "type": "string",
                        "enum": [
                          "meta"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "google"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "tiktok"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "taboola"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "snapchat"
                        ]
                      }
                    ]
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "202": {
            "description": "Accepted - processing asynchronously",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "worker_run_id",
                    "job_id",
                    "type",
                    "total_tasks",
                    "status",
                    "polling_interval_ms",
                    "created_at"
                  ],
                  "properties": {
                    "worker_run_id": {
                      "format": "uuid",
                      "description": "Worker run identifier. Poll GET /api/v1/reports/:worker_run_id for progress.",
                      "type": "string"
                    },
                    "job_id": {
                      "format": "uuid",
                      "description": "Canonical async-job identifier - mirrors `worker_run_id` for cross-domain SDK consistency.",
                      "type": "string"
                    },
                    "type": {
                      "description": "Worker run type (e.g. CAMPAIGN_REPORT, ADSET_REPORT, AD_REPORT).",
                      "type": "string"
                    },
                    "total_tasks": {
                      "description": "Number of ad-account sub-tasks the report was split into.",
                      "type": "integer"
                    },
                    "status": {
                      "description": "Current job status. One of: RUNNING, COMPLETED, FAILED.",
                      "type": "string"
                    },
                    "polling_interval_ms": {
                      "minimum": 500,
                      "description": "Recommended polling interval (ms) for GET /api/v1/reports/:worker_run_id.",
                      "type": "integer"
                    },
                    "estimated_wait_ms": {
                      "minimum": 0,
                      "description": "Best-effort estimate of remaining work, in milliseconds.",
                      "type": "integer"
                    },
                    "created_at": {
                      "format": "date-time",
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/reports/adsets": {
      "post": {
        "operationId": "triggerAdsetReport",
        "summary": "Trigger adset report generation",
        "tags": [
          "reports"
        ],
        "description": "Starts asynchronous adset report generation for all connected ad accounts. Returns a worker_run_id (also exposed as the canonical job_id) plus a recommended polling interval. Clients should poll GET /api/v1/reports/:worker_run_id until status is COMPLETED or FAILED.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "from_date",
                  "to_date"
                ],
                "properties": {
                  "from_date": {
                    "format": "date",
                    "description": "Start date in YYYY-MM-DD format",
                    "type": "string"
                  },
                  "to_date": {
                    "format": "date",
                    "description": "End date in YYYY-MM-DD format",
                    "type": "string"
                  },
                  "timezone": {
                    "description": "Timezone for the report (e.g. America/New_York)",
                    "type": "string"
                  },
                  "platform": {
                    "description": "Ad platform - defaults to \"meta\" when omitted (preserves the legacy Meta-only flow).",
                    "anyOf": [
                      {
                        "type": "string",
                        "enum": [
                          "meta"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "google"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "tiktok"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "taboola"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "snapchat"
                        ]
                      }
                    ]
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "202": {
            "description": "Accepted - processing asynchronously",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "worker_run_id",
                    "job_id",
                    "type",
                    "total_tasks",
                    "status",
                    "polling_interval_ms",
                    "created_at"
                  ],
                  "properties": {
                    "worker_run_id": {
                      "format": "uuid",
                      "description": "Worker run identifier. Poll GET /api/v1/reports/:worker_run_id for progress.",
                      "type": "string"
                    },
                    "job_id": {
                      "format": "uuid",
                      "description": "Canonical async-job identifier - mirrors `worker_run_id` for cross-domain SDK consistency.",
                      "type": "string"
                    },
                    "type": {
                      "description": "Worker run type (e.g. CAMPAIGN_REPORT, ADSET_REPORT, AD_REPORT).",
                      "type": "string"
                    },
                    "total_tasks": {
                      "description": "Number of ad-account sub-tasks the report was split into.",
                      "type": "integer"
                    },
                    "status": {
                      "description": "Current job status. One of: RUNNING, COMPLETED, FAILED.",
                      "type": "string"
                    },
                    "polling_interval_ms": {
                      "minimum": 500,
                      "description": "Recommended polling interval (ms) for GET /api/v1/reports/:worker_run_id.",
                      "type": "integer"
                    },
                    "estimated_wait_ms": {
                      "minimum": 0,
                      "description": "Best-effort estimate of remaining work, in milliseconds.",
                      "type": "integer"
                    },
                    "created_at": {
                      "format": "date-time",
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/reports/ads": {
      "post": {
        "operationId": "triggerAdReport",
        "summary": "Trigger ad report generation",
        "tags": [
          "reports"
        ],
        "description": "Starts asynchronous ad report generation for all connected ad accounts. Returns a worker_run_id (also exposed as the canonical job_id) plus a recommended polling interval. Clients should poll GET /api/v1/reports/:worker_run_id until status is COMPLETED or FAILED.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "from_date",
                  "to_date"
                ],
                "properties": {
                  "from_date": {
                    "format": "date",
                    "description": "Start date in YYYY-MM-DD format",
                    "type": "string"
                  },
                  "to_date": {
                    "format": "date",
                    "description": "End date in YYYY-MM-DD format",
                    "type": "string"
                  },
                  "timezone": {
                    "description": "Timezone for the report (e.g. America/New_York)",
                    "type": "string"
                  },
                  "platform": {
                    "description": "Ad platform - defaults to \"meta\" when omitted (preserves the legacy Meta-only flow).",
                    "anyOf": [
                      {
                        "type": "string",
                        "enum": [
                          "meta"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "google"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "tiktok"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "taboola"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "snapchat"
                        ]
                      }
                    ]
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "202": {
            "description": "Accepted - processing asynchronously",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "worker_run_id",
                    "job_id",
                    "type",
                    "total_tasks",
                    "status",
                    "polling_interval_ms",
                    "created_at"
                  ],
                  "properties": {
                    "worker_run_id": {
                      "format": "uuid",
                      "description": "Worker run identifier. Poll GET /api/v1/reports/:worker_run_id for progress.",
                      "type": "string"
                    },
                    "job_id": {
                      "format": "uuid",
                      "description": "Canonical async-job identifier - mirrors `worker_run_id` for cross-domain SDK consistency.",
                      "type": "string"
                    },
                    "type": {
                      "description": "Worker run type (e.g. CAMPAIGN_REPORT, ADSET_REPORT, AD_REPORT).",
                      "type": "string"
                    },
                    "total_tasks": {
                      "description": "Number of ad-account sub-tasks the report was split into.",
                      "type": "integer"
                    },
                    "status": {
                      "description": "Current job status. One of: RUNNING, COMPLETED, FAILED.",
                      "type": "string"
                    },
                    "polling_interval_ms": {
                      "minimum": 500,
                      "description": "Recommended polling interval (ms) for GET /api/v1/reports/:worker_run_id.",
                      "type": "integer"
                    },
                    "estimated_wait_ms": {
                      "minimum": 0,
                      "description": "Best-effort estimate of remaining work, in milliseconds.",
                      "type": "integer"
                    },
                    "created_at": {
                      "format": "date-time",
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/reports/{worker_run_id}": {
      "get": {
        "operationId": "getReportByWorkerRunId",
        "summary": "Get report data by worker run ID",
        "tags": [
          "reports"
        ],
        "description": "Returns the cached report data for a specific worker run. Includes worker run status and paginated report cache entries. This is the polling endpoint for the 202 responses returned by POST /api/v1/reports/{campaigns,adsets,ads}.",
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "query",
            "name": "cursor",
            "required": false,
            "description": "Cursor for pagination (last item id)"
          },
          {
            "schema": {
              "minimum": 1,
              "maximum": 200,
              "default": 50,
              "type": "integer"
            },
            "in": "query",
            "name": "limit",
            "required": false
          },
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "worker_run_id",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "worker_run",
                    "items",
                    "next_cursor"
                  ],
                  "properties": {
                    "worker_run": {
                      "type": "object",
                      "required": [
                        "id",
                        "type",
                        "status",
                        "total_tasks",
                        "completed_tasks",
                        "failed_tasks",
                        "created_at",
                        "updated_at"
                      ],
                      "properties": {
                        "id": {
                          "format": "uuid",
                          "type": "string"
                        },
                        "type": {
                          "type": "string"
                        },
                        "status": {
                          "type": "string"
                        },
                        "total_tasks": {
                          "type": "integer"
                        },
                        "completed_tasks": {
                          "type": "integer"
                        },
                        "failed_tasks": {
                          "type": "integer"
                        },
                        "created_at": {
                          "format": "date-time",
                          "type": "string"
                        },
                        "updated_at": {
                          "anyOf": [
                            {
                              "format": "date-time",
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        }
                      }
                    },
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "id",
                          "ad_account_id",
                          "ad_account_data",
                          "insights_data",
                          "from_date",
                          "to_date",
                          "cached_at"
                        ],
                        "properties": {
                          "id": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "ad_account_id": {
                            "type": "string"
                          },
                          "ad_account_data": {
                            "$comment": "json-value",
                            "description": "Arbitrary JSON value with nested arrays and objects."
                          },
                          "insights_data": {
                            "$comment": "json-value",
                            "description": "Arbitrary JSON value with nested arrays and objects."
                          },
                          "from_date": {
                            "format": "date",
                            "type": "string"
                          },
                          "to_date": {
                            "format": "date",
                            "type": "string"
                          },
                          "cached_at": {
                            "anyOf": [
                              {
                                "format": "date-time",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          }
                        }
                      }
                    },
                    "next_cursor": {
                      "anyOf": [
                        {
                          "format": "uuid",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/reports": {
      "get": {
        "operationId": "listReports",
        "summary": "List report worker runs",
        "tags": [
          "reports"
        ],
        "description": "Returns a paginated list of report worker runs (campaigns, adsets, ads) for the authenticated user. Results are team-scoped and follow the active workspace scope: owners see runs from every accessible team member.",
        "parameters": [
          {
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "enum": [
                    "CAMPAIGN_REPORT"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "ADSET_REPORT"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "AD_REPORT"
                  ]
                }
              ]
            },
            "in": "query",
            "name": "type",
            "required": false,
            "description": "Filter by report type"
          },
          {
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "enum": [
                    "RUNNING"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "COMPLETED"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "FAILED"
                  ]
                }
              ]
            },
            "in": "query",
            "name": "status",
            "required": false,
            "description": "Filter by status"
          },
          {
            "schema": {
              "type": "boolean"
            },
            "in": "query",
            "name": "include_all_types",
            "required": false,
            "description": "Include all worker_run types, not just reports"
          },
          {
            "schema": {
              "minimum": 1,
              "maximum": 100,
              "default": 20,
              "type": "integer"
            },
            "in": "query",
            "name": "limit",
            "required": false
          },
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "query",
            "name": "cursor",
            "required": false,
            "description": "Cursor for pagination (last worker_run id)"
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "items",
                    "next_cursor"
                  ],
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "id",
                          "type",
                          "status",
                          "total_tasks",
                          "completed_tasks",
                          "failed_tasks",
                          "created_at",
                          "updated_at"
                        ],
                        "properties": {
                          "id": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "type": {
                            "type": "string"
                          },
                          "status": {
                            "type": "string"
                          },
                          "total_tasks": {
                            "type": "integer"
                          },
                          "completed_tasks": {
                            "type": "integer"
                          },
                          "failed_tasks": {
                            "type": "integer"
                          },
                          "created_at": {
                            "format": "date-time",
                            "type": "string"
                          },
                          "updated_at": {
                            "anyOf": [
                              {
                                "format": "date-time",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          }
                        }
                      }
                    },
                    "next_cursor": {
                      "anyOf": [
                        {
                          "format": "uuid",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/rules": {
      "get": {
        "operationId": "listAutomationRules",
        "summary": "List automation rules (server-side paginated)",
        "tags": [
          "rules"
        ],
        "description": "Returns a server-side paginated, filtered, sorted list of automation rules with status counts.",
        "parameters": [
          {
            "schema": {
              "minimum": 1,
              "maximum": 100,
              "default": 50,
              "type": "integer"
            },
            "in": "query",
            "name": "limit",
            "required": false
          },
          {
            "schema": {
              "minimum": 0,
              "default": 0,
              "type": "integer"
            },
            "in": "query",
            "name": "offset",
            "required": false
          },
          {
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "enum": [
                    "active"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "paused"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "error"
                  ]
                }
              ]
            },
            "in": "query",
            "name": "status",
            "required": false
          },
          {
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "enum": [
                    "campaign"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "adset"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "ad"
                  ]
                }
              ]
            },
            "in": "query",
            "name": "entity_level",
            "required": false
          },
          {
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "enum": [
                    "name"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "status"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "entity_level"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "created_at"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "last_executed_at"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "execution_count"
                  ]
                }
              ]
            },
            "in": "query",
            "name": "sort_by",
            "required": false
          },
          {
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "enum": [
                    "asc"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "desc"
                  ]
                }
              ]
            },
            "in": "query",
            "name": "sort_order",
            "required": false
          },
          {
            "schema": {
              "minLength": 2,
              "maxLength": 200,
              "type": "string"
            },
            "in": "query",
            "name": "search",
            "required": false
          },
          {
            "schema": {
              "format": "date-time",
              "type": "string"
            },
            "in": "query",
            "name": "created_from",
            "required": false
          },
          {
            "schema": {
              "format": "date-time",
              "type": "string"
            },
            "in": "query",
            "name": "created_to",
            "required": false
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "items",
                    "total",
                    "counts"
                  ],
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "additionalProperties": true,
                        "description": "Automation rule row as persisted in the automation_rule table.",
                        "type": "object",
                        "required": [
                          "id",
                          "user_id",
                          "name",
                          "description",
                          "status",
                          "entity_level",
                          "ad_account_ids",
                          "entity_filter",
                          "condition_logic",
                          "conditions",
                          "actions",
                          "schedule_type",
                          "interval_minutes",
                          "schedule_config",
                          "timezone",
                          "cooldown_minutes",
                          "max_executions_per_day",
                          "budget_change_limit_pct",
                          "budget_daily_cap",
                          "notify_on_execution",
                          "notify_channels",
                          "platforms",
                          "priority",
                          "template_id",
                          "last_evaluated_at",
                          "last_executed_at",
                          "execution_count",
                          "error_count",
                          "last_error",
                          "auto_paused_at",
                          "auto_pause_reason",
                          "created_at",
                          "updated_at"
                        ],
                        "properties": {
                          "id": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "user_id": {
                            "anyOf": [
                              {
                                "format": "uuid",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "created_by": {
                            "anyOf": [
                              {
                                "format": "uuid",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "name": {
                            "type": "string"
                          },
                          "description": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "status": {
                            "anyOf": [
                              {
                                "type": "string",
                                "enum": [
                                  "active"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "paused"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "error"
                                ]
                              }
                            ]
                          },
                          "entity_level": {
                            "anyOf": [
                              {
                                "type": "string",
                                "enum": [
                                  "campaign"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "adset"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "ad"
                                ]
                              }
                            ]
                          },
                          "ad_account_ids": {
                            "type": "array",
                            "items": {
                              "type": "string"
                            }
                          },
                          "entity_filter": {
                            "description": "Entity filter as stored, tolerant of filters written outside the strict request contract.",
                            "anyOf": [
                              {
                                "additionalProperties": false,
                                "description": "Optional entity filters applied before condition evaluation.",
                                "type": "object",
                                "properties": {
                                  "name_contains": {
                                    "description": "Case-insensitive substring that must be present in the entity name.",
                                    "minLength": 1,
                                    "maxLength": 200,
                                    "type": "string"
                                  },
                                  "name_not_contains": {
                                    "description": "Case-insensitive substring that must not be present in the entity name.",
                                    "minLength": 1,
                                    "maxLength": 200,
                                    "type": "string"
                                  },
                                  "status_in": {
                                    "description": "Entity statuses to include. Route validation checks whether each status is allowed for the selected entity level.",
                                    "minItems": 1,
                                    "maxItems": 20,
                                    "type": "array",
                                    "items": {
                                      "minLength": 1,
                                      "maxLength": 80,
                                      "type": "string"
                                    }
                                  },
                                  "account_mode": {
                                    "description": "Ad-account scope intent. \"selected\" means the rule must be restricted to ad_account_ids; combined with an empty ad_account_ids the evaluator matches no entities (it does NOT silently fall back to all accounts). \"all\" (or omitted) evaluates every accessible account.",
                                    "anyOf": [
                                      {
                                        "type": "string",
                                        "enum": [
                                          "all"
                                        ]
                                      },
                                      {
                                        "type": "string",
                                        "enum": [
                                          "selected"
                                        ]
                                      }
                                    ]
                                  }
                                },
                                "title": "RuleEntityFilter"
                              },
                              {
                                "additionalProperties": true,
                                "description": "Entity filter stored before/around the current contract; surfaced as-is so the list stays readable.",
                                "type": "object",
                                "properties": {
                                  "name_contains": {
                                    "description": "Name filter as stored; may be empty (\"no filter\").",
                                    "type": "string"
                                  },
                                  "name_not_contains": {
                                    "description": "Negative name filter as stored; may be empty (\"no filter\").",
                                    "type": "string"
                                  },
                                  "status_in": {
                                    "description": "Statuses as stored; may be empty (\"no filter\").",
                                    "type": "array",
                                    "items": {
                                      "type": "string"
                                    }
                                  },
                                  "account_mode": {
                                    "description": "Ad-account scope intent as stored.",
                                    "type": "string"
                                  }
                                },
                                "title": "RuleEntityFilterStored"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "condition_logic": {
                            "anyOf": [
                              {
                                "type": "string",
                                "enum": [
                                  "AND"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "OR"
                                ]
                              }
                            ]
                          },
                          "conditions": {
                            "description": "Ordered list of conditions as stored, tolerant of rules written outside the request contract.",
                            "type": "array",
                            "items": {
                              "anyOf": [
                                {
                                  "additionalProperties": false,
                                  "description": "Single metric threshold evaluated against entity insights.",
                                  "type": "object",
                                  "required": [
                                    "metric",
                                    "operator",
                                    "time_range",
                                    "value"
                                  ],
                                  "properties": {
                                    "metric": {
                                      "description": "Metric key (platform metric, derived metric, or action-type KPI from action_types_canonical).",
                                      "minLength": 1,
                                      "type": "string"
                                    },
                                    "operator": {
                                      "description": "Comparison operator. `between`/`not_between` require both `value` and `value2`; `increased_pct`/`decreased_pct` compare the current `time_range` against the immediately preceding period of equal duration.",
                                      "anyOf": [
                                        {
                                          "type": "string",
                                          "enum": [
                                            "gt"
                                          ]
                                        },
                                        {
                                          "type": "string",
                                          "enum": [
                                            "lt"
                                          ]
                                        },
                                        {
                                          "type": "string",
                                          "enum": [
                                            "gte"
                                          ]
                                        },
                                        {
                                          "type": "string",
                                          "enum": [
                                            "lte"
                                          ]
                                        },
                                        {
                                          "type": "string",
                                          "enum": [
                                            "eq"
                                          ]
                                        },
                                        {
                                          "type": "string",
                                          "enum": [
                                            "neq"
                                          ]
                                        },
                                        {
                                          "type": "string",
                                          "enum": [
                                            "between"
                                          ]
                                        },
                                        {
                                          "type": "string",
                                          "enum": [
                                            "not_between"
                                          ]
                                        },
                                        {
                                          "type": "string",
                                          "enum": [
                                            "increased_pct"
                                          ]
                                        },
                                        {
                                          "type": "string",
                                          "enum": [
                                            "decreased_pct"
                                          ]
                                        }
                                      ]
                                    },
                                    "time_range": {
                                      "description": "Time window over which the metric is aggregated.",
                                      "anyOf": [
                                        {
                                          "type": "string",
                                          "enum": [
                                            "today"
                                          ]
                                        },
                                        {
                                          "type": "string",
                                          "enum": [
                                            "yesterday"
                                          ]
                                        },
                                        {
                                          "type": "string",
                                          "enum": [
                                            "last_3d"
                                          ]
                                        },
                                        {
                                          "type": "string",
                                          "enum": [
                                            "last_7d"
                                          ]
                                        },
                                        {
                                          "type": "string",
                                          "enum": [
                                            "last_14d"
                                          ]
                                        },
                                        {
                                          "type": "string",
                                          "enum": [
                                            "last_30d"
                                          ]
                                        }
                                      ]
                                    },
                                    "value": {
                                      "description": "Primary threshold. Coerced to Number at evaluation time.",
                                      "anyOf": [
                                        {
                                          "type": "number"
                                        },
                                        {
                                          "type": "string"
                                        }
                                      ]
                                    },
                                    "value2": {
                                      "description": "Secondary threshold (required for `between` / `not_between`).",
                                      "anyOf": [
                                        {
                                          "type": "number"
                                        },
                                        {
                                          "type": "string"
                                        }
                                      ]
                                    },
                                    "trend_window": {
                                      "description": "Time window over which the metric is aggregated.",
                                      "anyOf": [
                                        {
                                          "type": "string",
                                          "enum": [
                                            "today"
                                          ]
                                        },
                                        {
                                          "type": "string",
                                          "enum": [
                                            "yesterday"
                                          ]
                                        },
                                        {
                                          "type": "string",
                                          "enum": [
                                            "last_3d"
                                          ]
                                        },
                                        {
                                          "type": "string",
                                          "enum": [
                                            "last_7d"
                                          ]
                                        },
                                        {
                                          "type": "string",
                                          "enum": [
                                            "last_14d"
                                          ]
                                        },
                                        {
                                          "type": "string",
                                          "enum": [
                                            "last_30d"
                                          ]
                                        }
                                      ]
                                    }
                                  },
                                  "title": "RuleCondition"
                                },
                                {
                                  "additionalProperties": false,
                                  "description": "Account-level comparison across two advertising platforms, or between one platform and a literal.",
                                  "type": "object",
                                  "required": [
                                    "type",
                                    "left",
                                    "operator",
                                    "right"
                                  ],
                                  "properties": {
                                    "type": {
                                      "type": "string",
                                      "enum": [
                                        "cross_platform_comparison"
                                      ]
                                    },
                                    "left": {
                                      "anyOf": [
                                        {
                                          "additionalProperties": false,
                                          "type": "object",
                                          "required": [
                                            "type",
                                            "platform",
                                            "metric"
                                          ],
                                          "properties": {
                                            "type": {
                                              "type": "string",
                                              "enum": [
                                                "platform_metric"
                                              ]
                                            },
                                            "platform": {
                                              "anyOf": [
                                                {
                                                  "type": "string",
                                                  "enum": [
                                                    "META"
                                                  ]
                                                },
                                                {
                                                  "type": "string",
                                                  "enum": [
                                                    "GOOGLE"
                                                  ]
                                                },
                                                {
                                                  "type": "string",
                                                  "enum": [
                                                    "TIKTOK"
                                                  ]
                                                },
                                                {
                                                  "type": "string",
                                                  "enum": [
                                                    "TABOOLA"
                                                  ]
                                                },
                                                {
                                                  "type": "string",
                                                  "enum": [
                                                    "LINKEDIN"
                                                  ]
                                                }
                                              ]
                                            },
                                            "metric": {
                                              "anyOf": [
                                                {
                                                  "type": "string",
                                                  "enum": [
                                                    "spend"
                                                  ]
                                                },
                                                {
                                                  "type": "string",
                                                  "enum": [
                                                    "spend_pct"
                                                  ]
                                                },
                                                {
                                                  "type": "string",
                                                  "enum": [
                                                    "impressions"
                                                  ]
                                                },
                                                {
                                                  "type": "string",
                                                  "enum": [
                                                    "clicks"
                                                  ]
                                                },
                                                {
                                                  "type": "string",
                                                  "enum": [
                                                    "ctr"
                                                  ]
                                                },
                                                {
                                                  "type": "string",
                                                  "enum": [
                                                    "cpc"
                                                  ]
                                                },
                                                {
                                                  "type": "string",
                                                  "enum": [
                                                    "cpm"
                                                  ]
                                                },
                                                {
                                                  "type": "string",
                                                  "enum": [
                                                    "purchases"
                                                  ]
                                                },
                                                {
                                                  "type": "string",
                                                  "enum": [
                                                    "purchase_value"
                                                  ]
                                                },
                                                {
                                                  "type": "string",
                                                  "enum": [
                                                    "conversions"
                                                  ]
                                                },
                                                {
                                                  "type": "string",
                                                  "enum": [
                                                    "roas"
                                                  ]
                                                },
                                                {
                                                  "type": "string",
                                                  "enum": [
                                                    "cpa"
                                                  ]
                                                },
                                                {
                                                  "type": "string",
                                                  "enum": [
                                                    "cpl"
                                                  ]
                                                }
                                              ]
                                            },
                                            "level": {
                                              "type": "string",
                                              "enum": [
                                                "account"
                                              ]
                                            },
                                            "timeframe_days": {
                                              "minimum": 1,
                                              "maximum": 90,
                                              "type": "integer"
                                            },
                                            "multiplier": {
                                              "minimum": 0,
                                              "type": "number"
                                            }
                                          }
                                        },
                                        {
                                          "additionalProperties": false,
                                          "type": "object",
                                          "required": [
                                            "type",
                                            "value"
                                          ],
                                          "properties": {
                                            "type": {
                                              "type": "string",
                                              "enum": [
                                                "literal"
                                              ]
                                            },
                                            "value": {
                                              "type": "number"
                                            }
                                          }
                                        }
                                      ]
                                    },
                                    "operator": {
                                      "anyOf": [
                                        {
                                          "type": "string",
                                          "enum": [
                                            "greater_than"
                                          ]
                                        },
                                        {
                                          "type": "string",
                                          "enum": [
                                            "less_than"
                                          ]
                                        },
                                        {
                                          "type": "string",
                                          "enum": [
                                            "greater_or_equal"
                                          ]
                                        },
                                        {
                                          "type": "string",
                                          "enum": [
                                            "less_or_equal"
                                          ]
                                        },
                                        {
                                          "type": "string",
                                          "enum": [
                                            "equal"
                                          ]
                                        }
                                      ]
                                    },
                                    "right": {
                                      "anyOf": [
                                        {
                                          "additionalProperties": false,
                                          "type": "object",
                                          "required": [
                                            "type",
                                            "platform",
                                            "metric"
                                          ],
                                          "properties": {
                                            "type": {
                                              "type": "string",
                                              "enum": [
                                                "platform_metric"
                                              ]
                                            },
                                            "platform": {
                                              "anyOf": [
                                                {
                                                  "type": "string",
                                                  "enum": [
                                                    "META"
                                                  ]
                                                },
                                                {
                                                  "type": "string",
                                                  "enum": [
                                                    "GOOGLE"
                                                  ]
                                                },
                                                {
                                                  "type": "string",
                                                  "enum": [
                                                    "TIKTOK"
                                                  ]
                                                },
                                                {
                                                  "type": "string",
                                                  "enum": [
                                                    "TABOOLA"
                                                  ]
                                                },
                                                {
                                                  "type": "string",
                                                  "enum": [
                                                    "LINKEDIN"
                                                  ]
                                                }
                                              ]
                                            },
                                            "metric": {
                                              "anyOf": [
                                                {
                                                  "type": "string",
                                                  "enum": [
                                                    "spend"
                                                  ]
                                                },
                                                {
                                                  "type": "string",
                                                  "enum": [
                                                    "spend_pct"
                                                  ]
                                                },
                                                {
                                                  "type": "string",
                                                  "enum": [
                                                    "impressions"
                                                  ]
                                                },
                                                {
                                                  "type": "string",
                                                  "enum": [
                                                    "clicks"
                                                  ]
                                                },
                                                {
                                                  "type": "string",
                                                  "enum": [
                                                    "ctr"
                                                  ]
                                                },
                                                {
                                                  "type": "string",
                                                  "enum": [
                                                    "cpc"
                                                  ]
                                                },
                                                {
                                                  "type": "string",
                                                  "enum": [
                                                    "cpm"
                                                  ]
                                                },
                                                {
                                                  "type": "string",
                                                  "enum": [
                                                    "purchases"
                                                  ]
                                                },
                                                {
                                                  "type": "string",
                                                  "enum": [
                                                    "purchase_value"
                                                  ]
                                                },
                                                {
                                                  "type": "string",
                                                  "enum": [
                                                    "conversions"
                                                  ]
                                                },
                                                {
                                                  "type": "string",
                                                  "enum": [
                                                    "roas"
                                                  ]
                                                },
                                                {
                                                  "type": "string",
                                                  "enum": [
                                                    "cpa"
                                                  ]
                                                },
                                                {
                                                  "type": "string",
                                                  "enum": [
                                                    "cpl"
                                                  ]
                                                }
                                              ]
                                            },
                                            "level": {
                                              "type": "string",
                                              "enum": [
                                                "account"
                                              ]
                                            },
                                            "timeframe_days": {
                                              "minimum": 1,
                                              "maximum": 90,
                                              "type": "integer"
                                            },
                                            "multiplier": {
                                              "minimum": 0,
                                              "type": "number"
                                            }
                                          }
                                        },
                                        {
                                          "additionalProperties": false,
                                          "type": "object",
                                          "required": [
                                            "type",
                                            "value"
                                          ],
                                          "properties": {
                                            "type": {
                                              "type": "string",
                                              "enum": [
                                                "literal"
                                              ]
                                            },
                                            "value": {
                                              "type": "number"
                                            }
                                          }
                                        }
                                      ]
                                    }
                                  },
                                  "title": "CrossPlatformRuleCondition"
                                },
                                {
                                  "additionalProperties": true,
                                  "description": "Rule condition stored without the full current contract; surfaced as-is so the list stays readable.",
                                  "type": "object",
                                  "properties": {
                                    "metric": {
                                      "description": "Metric key as stored.",
                                      "type": "string"
                                    },
                                    "operator": {
                                      "description": "Comparison operator as stored.",
                                      "type": "string"
                                    },
                                    "time_range": {
                                      "description": "Time window as stored; absent means the evaluator default (`today`).",
                                      "type": "string"
                                    }
                                  },
                                  "title": "RuleConditionLegacy"
                                }
                              ],
                              "title": "RuleConditionStored"
                            }
                          },
                          "actions": {
                            "description": "Ordered list of actions as stored, tolerant of rules written before the current schema.",
                            "type": "array",
                            "items": {
                              "anyOf": [
                                {
                                  "description": "Automation rule action. Discriminated on `type`. See RuleActionType in src/sqs/types/messages.ts.",
                                  "anyOf": [
                                    {
                                      "additionalProperties": false,
                                      "type": "object",
                                      "required": [
                                        "type"
                                      ],
                                      "properties": {
                                        "type": {
                                          "description": "Pause the matched entity (campaign/adset/ad).",
                                          "type": "string",
                                          "enum": [
                                            "pause"
                                          ]
                                        },
                                        "params": {
                                          "$comment": "json-value",
                                          "description": "Arbitrary JSON value with nested arrays and objects."
                                        }
                                      },
                                      "title": "RuleActionPause"
                                    },
                                    {
                                      "additionalProperties": false,
                                      "type": "object",
                                      "required": [
                                        "type"
                                      ],
                                      "properties": {
                                        "type": {
                                          "description": "Activate the matched entity (campaign/adset/ad).",
                                          "type": "string",
                                          "enum": [
                                            "activate"
                                          ]
                                        },
                                        "params": {
                                          "$comment": "json-value",
                                          "description": "Arbitrary JSON value with nested arrays and objects."
                                        }
                                      },
                                      "title": "RuleActionActivate"
                                    },
                                    {
                                      "additionalProperties": false,
                                      "type": "object",
                                      "required": [
                                        "type"
                                      ],
                                      "properties": {
                                        "type": {
                                          "description": "Increase campaign/adset budget by `params.percentage` percent.",
                                          "type": "string",
                                          "enum": [
                                            "increase_budget_pct"
                                          ]
                                        },
                                        "params": {
                                          "additionalProperties": false,
                                          "type": "object",
                                          "properties": {
                                            "percentage": {
                                              "description": "Percent increase in [1, 1000] (defaults to 20 if omitted at runtime). 0 is rejected because a 0% change is a no-op and the worker clamps it to 1 anyway — the schema makes that contract explicit. The ceiling is deliberately far above 100: doubling or tripling a budget is ordinary media buying, and the old 100 cap (borrowed from the decrease action, where >100% is meaningless) made the rules list unserializable for anyone who had scaled a budget by more.",
                                              "minimum": 1,
                                              "maximum": 1000,
                                              "type": "number"
                                            },
                                            "pct": {
                                              "description": "Legacy template alias for `percentage`; accepted for seeded rule templates.",
                                              "minimum": 1,
                                              "maximum": 1000,
                                              "type": "number"
                                            }
                                          }
                                        }
                                      },
                                      "title": "RuleActionIncreaseBudget"
                                    },
                                    {
                                      "additionalProperties": false,
                                      "type": "object",
                                      "required": [
                                        "type"
                                      ],
                                      "properties": {
                                        "type": {
                                          "description": "Decrease campaign/adset budget by `params.percentage` percent.",
                                          "type": "string",
                                          "enum": [
                                            "decrease_budget_pct"
                                          ]
                                        },
                                        "params": {
                                          "additionalProperties": false,
                                          "type": "object",
                                          "properties": {
                                            "percentage": {
                                              "description": "Percent change in [1, 100] (defaults to 20 if omitted at runtime). 0 is rejected because a 0% change is a no-op and the worker clamps it to 1 anyway — the schema makes that contract explicit.",
                                              "minimum": 1,
                                              "maximum": 100,
                                              "type": "number"
                                            },
                                            "pct": {
                                              "description": "Legacy template alias for `percentage`; accepted for seeded rule templates.",
                                              "minimum": 1,
                                              "maximum": 100,
                                              "type": "number"
                                            }
                                          }
                                        }
                                      },
                                      "title": "RuleActionDecreaseBudget"
                                    },
                                    {
                                      "additionalProperties": false,
                                      "type": "object",
                                      "required": [
                                        "type"
                                      ],
                                      "properties": {
                                        "type": {
                                          "description": "Relaunch the ad (duplicate + delete original). Only valid at ad level.",
                                          "type": "string",
                                          "enum": [
                                            "relaunch"
                                          ]
                                        },
                                        "params": {
                                          "$comment": "json-value",
                                          "description": "Arbitrary JSON value with nested arrays and objects."
                                        }
                                      },
                                      "title": "RuleActionRelaunch"
                                    },
                                    {
                                      "additionalProperties": false,
                                      "type": "object",
                                      "required": [
                                        "type"
                                      ],
                                      "properties": {
                                        "type": {
                                          "description": "Send a notification but do not mutate anything on Meta.",
                                          "type": "string",
                                          "enum": [
                                            "notify_only"
                                          ]
                                        },
                                        "params": {
                                          "$comment": "json-value",
                                          "description": "Arbitrary JSON value with nested arrays and objects."
                                        }
                                      },
                                      "title": "RuleActionNotifyOnly"
                                    },
                                    {
                                      "additionalProperties": false,
                                      "type": "object",
                                      "required": [
                                        "type",
                                        "platform",
                                        "entity_level"
                                      ],
                                      "properties": {
                                        "type": {
                                          "type": "string",
                                          "enum": [
                                            "PAUSE_TOP_SPEND_CAMPAIGN"
                                          ]
                                        },
                                        "platform": {
                                          "anyOf": [
                                            {
                                              "type": "string",
                                              "enum": [
                                                "META"
                                              ]
                                            },
                                            {
                                              "type": "string",
                                              "enum": [
                                                "GOOGLE"
                                              ]
                                            },
                                            {
                                              "type": "string",
                                              "enum": [
                                                "TIKTOK"
                                              ]
                                            },
                                            {
                                              "type": "string",
                                              "enum": [
                                                "TABOOLA"
                                              ]
                                            },
                                            {
                                              "type": "string",
                                              "enum": [
                                                "LINKEDIN"
                                              ]
                                            }
                                          ]
                                        },
                                        "entity_level": {
                                          "type": "string",
                                          "enum": [
                                            "campaign"
                                          ]
                                        }
                                      },
                                      "title": "RuleActionPauseTopSpendCampaign"
                                    },
                                    {
                                      "additionalProperties": false,
                                      "type": "object",
                                      "required": [
                                        "type",
                                        "platform",
                                        "entity_level",
                                        "pct"
                                      ],
                                      "properties": {
                                        "type": {
                                          "anyOf": [
                                            {
                                              "type": "string",
                                              "enum": [
                                                "INCREASE_BUDGET_PCT"
                                              ]
                                            },
                                            {
                                              "type": "string",
                                              "enum": [
                                                "DECREASE_BUDGET_PCT"
                                              ]
                                            }
                                          ]
                                        },
                                        "platform": {
                                          "anyOf": [
                                            {
                                              "type": "string",
                                              "enum": [
                                                "META"
                                              ]
                                            },
                                            {
                                              "type": "string",
                                              "enum": [
                                                "GOOGLE"
                                              ]
                                            },
                                            {
                                              "type": "string",
                                              "enum": [
                                                "TIKTOK"
                                              ]
                                            },
                                            {
                                              "type": "string",
                                              "enum": [
                                                "TABOOLA"
                                              ]
                                            },
                                            {
                                              "type": "string",
                                              "enum": [
                                                "LINKEDIN"
                                              ]
                                            }
                                          ]
                                        },
                                        "entity_level": {
                                          "type": "string",
                                          "enum": [
                                            "campaign"
                                          ]
                                        },
                                        "pct": {
                                          "minimum": 1,
                                          "maximum": 100,
                                          "type": "number"
                                        }
                                      },
                                      "title": "RuleActionCrossPlatformBudgetPct"
                                    },
                                    {
                                      "additionalProperties": false,
                                      "type": "object",
                                      "required": [
                                        "type",
                                        "channel",
                                        "message_template"
                                      ],
                                      "properties": {
                                        "type": {
                                          "type": "string",
                                          "enum": [
                                            "NOTIFY_CHANNEL"
                                          ]
                                        },
                                        "channel": {
                                          "anyOf": [
                                            {
                                              "type": "string",
                                              "enum": [
                                                "in_app"
                                              ]
                                            },
                                            {
                                              "type": "string",
                                              "enum": [
                                                "email"
                                              ]
                                            },
                                            {
                                              "type": "string",
                                              "enum": [
                                                "telegram"
                                              ]
                                            }
                                          ]
                                        },
                                        "message_template": {
                                          "minLength": 1,
                                          "maxLength": 500,
                                          "type": "string"
                                        }
                                      },
                                      "title": "RuleActionNotifyChannel"
                                    }
                                  ],
                                  "title": "RuleAction"
                                },
                                {
                                  "additionalProperties": true,
                                  "description": "Rule action stored before the current schema; surfaced as-is so the list stays readable.",
                                  "type": "object",
                                  "required": [
                                    "type"
                                  ],
                                  "properties": {
                                    "type": {
                                      "description": "Action discriminator as stored, including legacy spellings.",
                                      "type": "string"
                                    },
                                    "params": {
                                      "$comment": "json-value",
                                      "description": "Arbitrary JSON value with nested arrays and objects."
                                    }
                                  },
                                  "title": "RuleActionLegacy"
                                }
                              ],
                              "title": "RuleActionStored"
                            }
                          },
                          "schedule_type": {
                            "anyOf": [
                              {
                                "type": "string",
                                "enum": [
                                  "interval"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "daily"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "daily_at_time"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "day_parting"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "custom"
                                ]
                              }
                            ]
                          },
                          "interval_minutes": {
                            "type": "integer"
                          },
                          "schedule_config": {
                            "description": "Schedule config as stored, tolerant of values written outside the strict request contract.",
                            "anyOf": [
                              {
                                "additionalProperties": false,
                                "description": "Optional schedule-specific rule configuration. `daily_at_time` uses `time`; `day_parting` uses `hours_of_day`/`days_of_week` and/or explicit `slots`.",
                                "type": "object",
                                "properties": {
                                  "time": {
                                    "description": "Daily evaluation time in HH:MM format. Runtime validation enforces 00:00-23:59.",
                                    "type": "string"
                                  },
                                  "type": {
                                    "type": "string",
                                    "enum": [
                                      "day_parting"
                                    ]
                                  },
                                  "hours_of_day": {
                                    "description": "Hours of day eligible for evaluation. Runtime validation enforces non-empty integers 0-23.",
                                    "maxItems": 24,
                                    "type": "array",
                                    "items": {
                                      "type": "number"
                                    }
                                  },
                                  "days_of_week": {
                                    "description": "Days of week eligible for evaluation, where 0 is Sunday and 6 is Saturday.",
                                    "maxItems": 7,
                                    "type": "array",
                                    "items": {
                                      "type": "number"
                                    }
                                  },
                                  "slots": {
                                    "description": "Explicit day/hour evaluation slots. Runtime validation enforces non-empty valid slots.",
                                    "type": "array",
                                    "items": {
                                      "additionalProperties": false,
                                      "type": "object",
                                      "required": [
                                        "day",
                                        "hour"
                                      ],
                                      "properties": {
                                        "day": {
                                          "description": "Day of week, where 0 is Sunday and 6 is Saturday. Runtime validation enforces integer 0-6.",
                                          "type": "number"
                                        },
                                        "hour": {
                                          "description": "Hour of day in 24-hour format. Runtime validation enforces integer 0-23.",
                                          "type": "number"
                                        }
                                      }
                                    }
                                  },
                                  "timezone": {
                                    "minLength": 1,
                                    "maxLength": 100,
                                    "type": "string"
                                  }
                                },
                                "title": "RuleScheduleConfig"
                              },
                              {
                                "additionalProperties": true,
                                "description": "Schedule config stored before/around the current contract; surfaced as-is.",
                                "type": "object",
                                "properties": {
                                  "time": {
                                    "description": "Daily evaluation time as stored.",
                                    "type": "string"
                                  },
                                  "type": {
                                    "description": "Schedule discriminator as stored.",
                                    "type": "string"
                                  },
                                  "hours_of_day": {
                                    "description": "Hours as stored.",
                                    "type": "array",
                                    "items": {
                                      "type": "number"
                                    }
                                  },
                                  "days_of_week": {
                                    "description": "Days as stored.",
                                    "type": "array",
                                    "items": {
                                      "type": "number"
                                    }
                                  },
                                  "slots": {
                                    "description": "Day/hour slots as stored.",
                                    "type": "array",
                                    "items": {
                                      "additionalProperties": true,
                                      "type": "object",
                                      "properties": {
                                        "day": {
                                          "type": "number"
                                        },
                                        "hour": {
                                          "type": "number"
                                        }
                                      }
                                    }
                                  },
                                  "timezone": {
                                    "description": "Timezone as stored.",
                                    "type": "string"
                                  }
                                },
                                "title": "RuleScheduleConfigStored"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "timezone": {
                            "type": "string"
                          },
                          "cooldown_minutes": {
                            "type": "integer"
                          },
                          "max_executions_per_day": {
                            "type": "integer"
                          },
                          "budget_change_limit_pct": {
                            "anyOf": [
                              {
                                "type": "number"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "budget_daily_cap": {
                            "anyOf": [
                              {
                                "type": "number"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "notify_on_execution": {
                            "type": "boolean"
                          },
                          "notify_channels": {
                            "description": "Notify channels as stored, tolerant of values written outside the strict request contract.",
                            "anyOf": [
                              {
                                "additionalProperties": false,
                                "description": "Notification channels used when notify_on_execution is enabled.",
                                "type": "object",
                                "properties": {
                                  "email": {
                                    "type": "boolean"
                                  },
                                  "in_app": {
                                    "type": "boolean"
                                  },
                                  "telegram": {
                                    "type": "boolean"
                                  }
                                },
                                "title": "RuleNotifyChannels"
                              },
                              {
                                "additionalProperties": true,
                                "description": "Notify channels stored before/around the current contract; surfaced as-is.",
                                "type": "object",
                                "properties": {
                                  "email": {
                                    "type": "boolean"
                                  },
                                  "in_app": {
                                    "type": "boolean"
                                  },
                                  "telegram": {
                                    "type": "boolean"
                                  }
                                },
                                "title": "RuleNotifyChannelsStored"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "platforms": {
                            "type": "array",
                            "items": {
                              "minLength": 1,
                              "maxLength": 40,
                              "type": "string"
                            }
                          },
                          "priority": {
                            "type": "integer"
                          },
                          "template_id": {
                            "anyOf": [
                              {
                                "format": "uuid",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "last_evaluated_at": {
                            "anyOf": [
                              {
                                "format": "date-time",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "last_executed_at": {
                            "anyOf": [
                              {
                                "format": "date-time",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "execution_count": {
                            "type": "integer"
                          },
                          "error_count": {
                            "type": "integer"
                          },
                          "last_error": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "auto_paused_at": {
                            "anyOf": [
                              {
                                "format": "date-time",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "auto_pause_reason": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "cb_reset_after": {
                            "anyOf": [
                              {
                                "format": "date-time",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "created_at": {
                            "format": "date-time",
                            "type": "string"
                          },
                          "updated_at": {
                            "format": "date-time",
                            "type": "string"
                          }
                        }
                      }
                    },
                    "total": {
                      "type": "integer"
                    },
                    "counts": {
                      "additionalProperties": false,
                      "type": "object",
                      "required": [
                        "active",
                        "paused",
                        "error"
                      ],
                      "properties": {
                        "active": {
                          "type": "integer"
                        },
                        "paused": {
                          "type": "integer"
                        },
                        "error": {
                          "type": "integer"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "integer"
                    },
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "details": {
                      "type": "array",
                      "items": {
                        "additionalProperties": false,
                        "type": "object",
                        "required": [
                          "code",
                          "field",
                          "message"
                        ],
                        "properties": {
                          "code": {
                            "type": "string"
                          },
                          "field": {
                            "type": "string"
                          },
                          "message": {
                            "type": "string"
                          }
                        }
                      }
                    },
                    "validation": {
                      "type": "array",
                      "items": {
                        "additionalProperties": true,
                        "description": "AJV validation error item returned by Fastify for invalid params, querystrings, or bodies.",
                        "type": "object",
                        "properties": {
                          "instancePath": {
                            "type": "string"
                          },
                          "schemaPath": {
                            "type": "string"
                          },
                          "keyword": {
                            "type": "string"
                          },
                          "params": {
                            "type": "object",
                            "additionalProperties": {
                              "$comment": "json-value",
                              "description": "Arbitrary JSON value with nested arrays and objects."
                            }
                          },
                          "message": {
                            "type": "string"
                          }
                        }
                      }
                    },
                    "validationContext": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "integer"
                    },
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "createAutomationRule",
        "summary": "Create automation rule",
        "tags": [
          "rules"
        ],
        "description": "Creates a new automation rule in paused state with the given conditions, actions, and schedule configuration. The rule is created in the destination workspace: send x-team-id or activate a team scope, otherwise the request fails with 400 and code SCOPE_TEAM_REQUIRED.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "name",
                  "entity_level",
                  "conditions",
                  "actions"
                ],
                "properties": {
                  "name": {
                    "minLength": 1,
                    "type": "string"
                  },
                  "description": {
                    "anyOf": [
                      {
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "entity_level": {
                    "anyOf": [
                      {
                        "type": "string",
                        "enum": [
                          "campaign"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "adset"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "ad"
                        ]
                      }
                    ]
                  },
                  "ad_account_ids": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  },
                  "entity_filter": {
                    "anyOf": [
                      {
                        "additionalProperties": false,
                        "description": "Optional entity filters applied before condition evaluation.",
                        "type": "object",
                        "properties": {
                          "name_contains": {
                            "description": "Case-insensitive substring that must be present in the entity name.",
                            "minLength": 1,
                            "maxLength": 200,
                            "type": "string"
                          },
                          "name_not_contains": {
                            "description": "Case-insensitive substring that must not be present in the entity name.",
                            "minLength": 1,
                            "maxLength": 200,
                            "type": "string"
                          },
                          "status_in": {
                            "description": "Entity statuses to include. Route validation checks whether each status is allowed for the selected entity level.",
                            "minItems": 1,
                            "maxItems": 20,
                            "type": "array",
                            "items": {
                              "minLength": 1,
                              "maxLength": 80,
                              "type": "string"
                            }
                          },
                          "account_mode": {
                            "description": "Ad-account scope intent. \"selected\" means the rule must be restricted to ad_account_ids; combined with an empty ad_account_ids the evaluator matches no entities (it does NOT silently fall back to all accounts). \"all\" (or omitted) evaluates every accessible account.",
                            "anyOf": [
                              {
                                "type": "string",
                                "enum": [
                                  "all"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "selected"
                                ]
                              }
                            ]
                          }
                        }
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "condition_logic": {
                    "anyOf": [
                      {
                        "type": "string",
                        "enum": [
                          "AND"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "OR"
                        ]
                      }
                    ]
                  },
                  "conditions": {
                    "description": "Ordered list of conditions combined via `condition_logic` (AND/OR).",
                    "type": "array",
                    "items": {
                      "anyOf": [
                        {
                          "additionalProperties": false,
                          "description": "Single metric threshold evaluated against entity insights.",
                          "type": "object",
                          "required": [
                            "metric",
                            "operator",
                            "time_range",
                            "value"
                          ],
                          "properties": {
                            "metric": {
                              "description": "Metric key (platform metric, derived metric, or action-type KPI from action_types_canonical).",
                              "minLength": 1,
                              "type": "string"
                            },
                            "operator": {
                              "description": "Comparison operator. `between`/`not_between` require both `value` and `value2`; `increased_pct`/`decreased_pct` compare the current `time_range` against the immediately preceding period of equal duration.",
                              "anyOf": [
                                {
                                  "type": "string",
                                  "enum": [
                                    "gt"
                                  ]
                                },
                                {
                                  "type": "string",
                                  "enum": [
                                    "lt"
                                  ]
                                },
                                {
                                  "type": "string",
                                  "enum": [
                                    "gte"
                                  ]
                                },
                                {
                                  "type": "string",
                                  "enum": [
                                    "lte"
                                  ]
                                },
                                {
                                  "type": "string",
                                  "enum": [
                                    "eq"
                                  ]
                                },
                                {
                                  "type": "string",
                                  "enum": [
                                    "neq"
                                  ]
                                },
                                {
                                  "type": "string",
                                  "enum": [
                                    "between"
                                  ]
                                },
                                {
                                  "type": "string",
                                  "enum": [
                                    "not_between"
                                  ]
                                },
                                {
                                  "type": "string",
                                  "enum": [
                                    "increased_pct"
                                  ]
                                },
                                {
                                  "type": "string",
                                  "enum": [
                                    "decreased_pct"
                                  ]
                                }
                              ]
                            },
                            "time_range": {
                              "description": "Time window over which the metric is aggregated.",
                              "anyOf": [
                                {
                                  "type": "string",
                                  "enum": [
                                    "today"
                                  ]
                                },
                                {
                                  "type": "string",
                                  "enum": [
                                    "yesterday"
                                  ]
                                },
                                {
                                  "type": "string",
                                  "enum": [
                                    "last_3d"
                                  ]
                                },
                                {
                                  "type": "string",
                                  "enum": [
                                    "last_7d"
                                  ]
                                },
                                {
                                  "type": "string",
                                  "enum": [
                                    "last_14d"
                                  ]
                                },
                                {
                                  "type": "string",
                                  "enum": [
                                    "last_30d"
                                  ]
                                }
                              ]
                            },
                            "value": {
                              "description": "Primary threshold. Coerced to Number at evaluation time.",
                              "anyOf": [
                                {
                                  "type": "number"
                                },
                                {
                                  "type": "string"
                                }
                              ]
                            },
                            "value2": {
                              "description": "Secondary threshold (required for `between` / `not_between`).",
                              "anyOf": [
                                {
                                  "type": "number"
                                },
                                {
                                  "type": "string"
                                }
                              ]
                            },
                            "trend_window": {
                              "description": "Time window over which the metric is aggregated.",
                              "anyOf": [
                                {
                                  "type": "string",
                                  "enum": [
                                    "today"
                                  ]
                                },
                                {
                                  "type": "string",
                                  "enum": [
                                    "yesterday"
                                  ]
                                },
                                {
                                  "type": "string",
                                  "enum": [
                                    "last_3d"
                                  ]
                                },
                                {
                                  "type": "string",
                                  "enum": [
                                    "last_7d"
                                  ]
                                },
                                {
                                  "type": "string",
                                  "enum": [
                                    "last_14d"
                                  ]
                                },
                                {
                                  "type": "string",
                                  "enum": [
                                    "last_30d"
                                  ]
                                }
                              ]
                            }
                          }
                        },
                        {
                          "additionalProperties": false,
                          "description": "Account-level comparison across two advertising platforms, or between one platform and a literal.",
                          "type": "object",
                          "required": [
                            "type",
                            "left",
                            "operator",
                            "right"
                          ],
                          "properties": {
                            "type": {
                              "type": "string",
                              "enum": [
                                "cross_platform_comparison"
                              ]
                            },
                            "left": {
                              "anyOf": [
                                {
                                  "additionalProperties": false,
                                  "type": "object",
                                  "required": [
                                    "type",
                                    "platform",
                                    "metric"
                                  ],
                                  "properties": {
                                    "type": {
                                      "type": "string",
                                      "enum": [
                                        "platform_metric"
                                      ]
                                    },
                                    "platform": {
                                      "anyOf": [
                                        {
                                          "type": "string",
                                          "enum": [
                                            "META"
                                          ]
                                        },
                                        {
                                          "type": "string",
                                          "enum": [
                                            "GOOGLE"
                                          ]
                                        },
                                        {
                                          "type": "string",
                                          "enum": [
                                            "TIKTOK"
                                          ]
                                        },
                                        {
                                          "type": "string",
                                          "enum": [
                                            "TABOOLA"
                                          ]
                                        },
                                        {
                                          "type": "string",
                                          "enum": [
                                            "LINKEDIN"
                                          ]
                                        }
                                      ]
                                    },
                                    "metric": {
                                      "anyOf": [
                                        {
                                          "type": "string",
                                          "enum": [
                                            "spend"
                                          ]
                                        },
                                        {
                                          "type": "string",
                                          "enum": [
                                            "spend_pct"
                                          ]
                                        },
                                        {
                                          "type": "string",
                                          "enum": [
                                            "impressions"
                                          ]
                                        },
                                        {
                                          "type": "string",
                                          "enum": [
                                            "clicks"
                                          ]
                                        },
                                        {
                                          "type": "string",
                                          "enum": [
                                            "ctr"
                                          ]
                                        },
                                        {
                                          "type": "string",
                                          "enum": [
                                            "cpc"
                                          ]
                                        },
                                        {
                                          "type": "string",
                                          "enum": [
                                            "cpm"
                                          ]
                                        },
                                        {
                                          "type": "string",
                                          "enum": [
                                            "purchases"
                                          ]
                                        },
                                        {
                                          "type": "string",
                                          "enum": [
                                            "purchase_value"
                                          ]
                                        },
                                        {
                                          "type": "string",
                                          "enum": [
                                            "conversions"
                                          ]
                                        },
                                        {
                                          "type": "string",
                                          "enum": [
                                            "roas"
                                          ]
                                        },
                                        {
                                          "type": "string",
                                          "enum": [
                                            "cpa"
                                          ]
                                        },
                                        {
                                          "type": "string",
                                          "enum": [
                                            "cpl"
                                          ]
                                        }
                                      ]
                                    },
                                    "level": {
                                      "type": "string",
                                      "enum": [
                                        "account"
                                      ]
                                    },
                                    "timeframe_days": {
                                      "minimum": 1,
                                      "maximum": 90,
                                      "type": "integer"
                                    },
                                    "multiplier": {
                                      "minimum": 0,
                                      "type": "number"
                                    }
                                  }
                                },
                                {
                                  "additionalProperties": false,
                                  "type": "object",
                                  "required": [
                                    "type",
                                    "value"
                                  ],
                                  "properties": {
                                    "type": {
                                      "type": "string",
                                      "enum": [
                                        "literal"
                                      ]
                                    },
                                    "value": {
                                      "type": "number"
                                    }
                                  }
                                }
                              ]
                            },
                            "operator": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "enum": [
                                    "greater_than"
                                  ]
                                },
                                {
                                  "type": "string",
                                  "enum": [
                                    "less_than"
                                  ]
                                },
                                {
                                  "type": "string",
                                  "enum": [
                                    "greater_or_equal"
                                  ]
                                },
                                {
                                  "type": "string",
                                  "enum": [
                                    "less_or_equal"
                                  ]
                                },
                                {
                                  "type": "string",
                                  "enum": [
                                    "equal"
                                  ]
                                }
                              ]
                            },
                            "right": {
                              "anyOf": [
                                {
                                  "additionalProperties": false,
                                  "type": "object",
                                  "required": [
                                    "type",
                                    "platform",
                                    "metric"
                                  ],
                                  "properties": {
                                    "type": {
                                      "type": "string",
                                      "enum": [
                                        "platform_metric"
                                      ]
                                    },
                                    "platform": {
                                      "anyOf": [
                                        {
                                          "type": "string",
                                          "enum": [
                                            "META"
                                          ]
                                        },
                                        {
                                          "type": "string",
                                          "enum": [
                                            "GOOGLE"
                                          ]
                                        },
                                        {
                                          "type": "string",
                                          "enum": [
                                            "TIKTOK"
                                          ]
                                        },
                                        {
                                          "type": "string",
                                          "enum": [
                                            "TABOOLA"
                                          ]
                                        },
                                        {
                                          "type": "string",
                                          "enum": [
                                            "LINKEDIN"
                                          ]
                                        }
                                      ]
                                    },
                                    "metric": {
                                      "anyOf": [
                                        {
                                          "type": "string",
                                          "enum": [
                                            "spend"
                                          ]
                                        },
                                        {
                                          "type": "string",
                                          "enum": [
                                            "spend_pct"
                                          ]
                                        },
                                        {
                                          "type": "string",
                                          "enum": [
                                            "impressions"
                                          ]
                                        },
                                        {
                                          "type": "string",
                                          "enum": [
                                            "clicks"
                                          ]
                                        },
                                        {
                                          "type": "string",
                                          "enum": [
                                            "ctr"
                                          ]
                                        },
                                        {
                                          "type": "string",
                                          "enum": [
                                            "cpc"
                                          ]
                                        },
                                        {
                                          "type": "string",
                                          "enum": [
                                            "cpm"
                                          ]
                                        },
                                        {
                                          "type": "string",
                                          "enum": [
                                            "purchases"
                                          ]
                                        },
                                        {
                                          "type": "string",
                                          "enum": [
                                            "purchase_value"
                                          ]
                                        },
                                        {
                                          "type": "string",
                                          "enum": [
                                            "conversions"
                                          ]
                                        },
                                        {
                                          "type": "string",
                                          "enum": [
                                            "roas"
                                          ]
                                        },
                                        {
                                          "type": "string",
                                          "enum": [
                                            "cpa"
                                          ]
                                        },
                                        {
                                          "type": "string",
                                          "enum": [
                                            "cpl"
                                          ]
                                        }
                                      ]
                                    },
                                    "level": {
                                      "type": "string",
                                      "enum": [
                                        "account"
                                      ]
                                    },
                                    "timeframe_days": {
                                      "minimum": 1,
                                      "maximum": 90,
                                      "type": "integer"
                                    },
                                    "multiplier": {
                                      "minimum": 0,
                                      "type": "number"
                                    }
                                  }
                                },
                                {
                                  "additionalProperties": false,
                                  "type": "object",
                                  "required": [
                                    "type",
                                    "value"
                                  ],
                                  "properties": {
                                    "type": {
                                      "type": "string",
                                      "enum": [
                                        "literal"
                                      ]
                                    },
                                    "value": {
                                      "type": "number"
                                    }
                                  }
                                }
                              ]
                            }
                          }
                        }
                      ]
                    }
                  },
                  "actions": {
                    "description": "Ordered list of actions applied to each matched entity.",
                    "type": "array",
                    "items": {
                      "description": "Automation rule action. Discriminated on `type`. See RuleActionType in src/sqs/types/messages.ts.",
                      "anyOf": [
                        {
                          "additionalProperties": false,
                          "type": "object",
                          "required": [
                            "type"
                          ],
                          "properties": {
                            "type": {
                              "description": "Pause the matched entity (campaign/adset/ad).",
                              "type": "string",
                              "enum": [
                                "pause"
                              ]
                            },
                            "params": {
                              "$comment": "json-value",
                              "description": "Arbitrary JSON value with nested arrays and objects."
                            }
                          }
                        },
                        {
                          "additionalProperties": false,
                          "type": "object",
                          "required": [
                            "type"
                          ],
                          "properties": {
                            "type": {
                              "description": "Activate the matched entity (campaign/adset/ad).",
                              "type": "string",
                              "enum": [
                                "activate"
                              ]
                            },
                            "params": {
                              "$comment": "json-value",
                              "description": "Arbitrary JSON value with nested arrays and objects."
                            }
                          }
                        },
                        {
                          "additionalProperties": false,
                          "type": "object",
                          "required": [
                            "type"
                          ],
                          "properties": {
                            "type": {
                              "description": "Increase campaign/adset budget by `params.percentage` percent.",
                              "type": "string",
                              "enum": [
                                "increase_budget_pct"
                              ]
                            },
                            "params": {
                              "additionalProperties": false,
                              "type": "object",
                              "properties": {
                                "percentage": {
                                  "description": "Percent increase in [1, 1000] (defaults to 20 if omitted at runtime). 0 is rejected because a 0% change is a no-op and the worker clamps it to 1 anyway — the schema makes that contract explicit. The ceiling is deliberately far above 100: doubling or tripling a budget is ordinary media buying, and the old 100 cap (borrowed from the decrease action, where >100% is meaningless) made the rules list unserializable for anyone who had scaled a budget by more.",
                                  "minimum": 1,
                                  "maximum": 1000,
                                  "type": "number"
                                },
                                "pct": {
                                  "description": "Legacy template alias for `percentage`; accepted for seeded rule templates.",
                                  "minimum": 1,
                                  "maximum": 1000,
                                  "type": "number"
                                }
                              }
                            }
                          }
                        },
                        {
                          "additionalProperties": false,
                          "type": "object",
                          "required": [
                            "type"
                          ],
                          "properties": {
                            "type": {
                              "description": "Decrease campaign/adset budget by `params.percentage` percent.",
                              "type": "string",
                              "enum": [
                                "decrease_budget_pct"
                              ]
                            },
                            "params": {
                              "additionalProperties": false,
                              "type": "object",
                              "properties": {
                                "percentage": {
                                  "description": "Percent change in [1, 100] (defaults to 20 if omitted at runtime). 0 is rejected because a 0% change is a no-op and the worker clamps it to 1 anyway — the schema makes that contract explicit.",
                                  "minimum": 1,
                                  "maximum": 100,
                                  "type": "number"
                                },
                                "pct": {
                                  "description": "Legacy template alias for `percentage`; accepted for seeded rule templates.",
                                  "minimum": 1,
                                  "maximum": 100,
                                  "type": "number"
                                }
                              }
                            }
                          }
                        },
                        {
                          "additionalProperties": false,
                          "type": "object",
                          "required": [
                            "type"
                          ],
                          "properties": {
                            "type": {
                              "description": "Relaunch the ad (duplicate + delete original). Only valid at ad level.",
                              "type": "string",
                              "enum": [
                                "relaunch"
                              ]
                            },
                            "params": {
                              "$comment": "json-value",
                              "description": "Arbitrary JSON value with nested arrays and objects."
                            }
                          }
                        },
                        {
                          "additionalProperties": false,
                          "type": "object",
                          "required": [
                            "type"
                          ],
                          "properties": {
                            "type": {
                              "description": "Send a notification but do not mutate anything on Meta.",
                              "type": "string",
                              "enum": [
                                "notify_only"
                              ]
                            },
                            "params": {
                              "$comment": "json-value",
                              "description": "Arbitrary JSON value with nested arrays and objects."
                            }
                          }
                        },
                        {
                          "additionalProperties": false,
                          "type": "object",
                          "required": [
                            "type",
                            "platform",
                            "entity_level"
                          ],
                          "properties": {
                            "type": {
                              "type": "string",
                              "enum": [
                                "PAUSE_TOP_SPEND_CAMPAIGN"
                              ]
                            },
                            "platform": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "enum": [
                                    "META"
                                  ]
                                },
                                {
                                  "type": "string",
                                  "enum": [
                                    "GOOGLE"
                                  ]
                                },
                                {
                                  "type": "string",
                                  "enum": [
                                    "TIKTOK"
                                  ]
                                },
                                {
                                  "type": "string",
                                  "enum": [
                                    "TABOOLA"
                                  ]
                                },
                                {
                                  "type": "string",
                                  "enum": [
                                    "LINKEDIN"
                                  ]
                                }
                              ]
                            },
                            "entity_level": {
                              "type": "string",
                              "enum": [
                                "campaign"
                              ]
                            }
                          }
                        },
                        {
                          "additionalProperties": false,
                          "type": "object",
                          "required": [
                            "type",
                            "platform",
                            "entity_level",
                            "pct"
                          ],
                          "properties": {
                            "type": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "enum": [
                                    "INCREASE_BUDGET_PCT"
                                  ]
                                },
                                {
                                  "type": "string",
                                  "enum": [
                                    "DECREASE_BUDGET_PCT"
                                  ]
                                }
                              ]
                            },
                            "platform": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "enum": [
                                    "META"
                                  ]
                                },
                                {
                                  "type": "string",
                                  "enum": [
                                    "GOOGLE"
                                  ]
                                },
                                {
                                  "type": "string",
                                  "enum": [
                                    "TIKTOK"
                                  ]
                                },
                                {
                                  "type": "string",
                                  "enum": [
                                    "TABOOLA"
                                  ]
                                },
                                {
                                  "type": "string",
                                  "enum": [
                                    "LINKEDIN"
                                  ]
                                }
                              ]
                            },
                            "entity_level": {
                              "type": "string",
                              "enum": [
                                "campaign"
                              ]
                            },
                            "pct": {
                              "minimum": 1,
                              "maximum": 100,
                              "type": "number"
                            }
                          }
                        },
                        {
                          "additionalProperties": false,
                          "type": "object",
                          "required": [
                            "type",
                            "channel",
                            "message_template"
                          ],
                          "properties": {
                            "type": {
                              "type": "string",
                              "enum": [
                                "NOTIFY_CHANNEL"
                              ]
                            },
                            "channel": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "enum": [
                                    "in_app"
                                  ]
                                },
                                {
                                  "type": "string",
                                  "enum": [
                                    "email"
                                  ]
                                },
                                {
                                  "type": "string",
                                  "enum": [
                                    "telegram"
                                  ]
                                }
                              ]
                            },
                            "message_template": {
                              "minLength": 1,
                              "maxLength": 500,
                              "type": "string"
                            }
                          }
                        }
                      ]
                    }
                  },
                  "schedule_type": {
                    "anyOf": [
                      {
                        "type": "string",
                        "enum": [
                          "interval"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "daily"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "daily_at_time"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "day_parting"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "custom"
                        ]
                      }
                    ]
                  },
                  "interval_minutes": {
                    "minimum": 1,
                    "type": "integer"
                  },
                  "schedule_config": {
                    "anyOf": [
                      {
                        "additionalProperties": false,
                        "description": "Optional schedule-specific rule configuration. `daily_at_time` uses `time`; `day_parting` uses `hours_of_day`/`days_of_week` and/or explicit `slots`.",
                        "type": "object",
                        "properties": {
                          "time": {
                            "description": "Daily evaluation time in HH:MM format. Runtime validation enforces 00:00-23:59.",
                            "type": "string"
                          },
                          "type": {
                            "type": "string",
                            "enum": [
                              "day_parting"
                            ]
                          },
                          "hours_of_day": {
                            "description": "Hours of day eligible for evaluation. Runtime validation enforces non-empty integers 0-23.",
                            "maxItems": 24,
                            "type": "array",
                            "items": {
                              "type": "number"
                            }
                          },
                          "days_of_week": {
                            "description": "Days of week eligible for evaluation, where 0 is Sunday and 6 is Saturday.",
                            "maxItems": 7,
                            "type": "array",
                            "items": {
                              "type": "number"
                            }
                          },
                          "slots": {
                            "description": "Explicit day/hour evaluation slots. Runtime validation enforces non-empty valid slots.",
                            "type": "array",
                            "items": {
                              "additionalProperties": false,
                              "type": "object",
                              "required": [
                                "day",
                                "hour"
                              ],
                              "properties": {
                                "day": {
                                  "description": "Day of week, where 0 is Sunday and 6 is Saturday. Runtime validation enforces integer 0-6.",
                                  "type": "number"
                                },
                                "hour": {
                                  "description": "Hour of day in 24-hour format. Runtime validation enforces integer 0-23.",
                                  "type": "number"
                                }
                              }
                            }
                          },
                          "timezone": {
                            "minLength": 1,
                            "maxLength": 100,
                            "type": "string"
                          }
                        }
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "timezone": {
                    "type": "string"
                  },
                  "cooldown_minutes": {
                    "minimum": 0,
                    "type": "integer"
                  },
                  "max_executions_per_day": {
                    "minimum": 1,
                    "type": "integer"
                  },
                  "budget_change_limit_pct": {
                    "anyOf": [
                      {
                        "type": "number"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "budget_daily_cap": {
                    "anyOf": [
                      {
                        "type": "number"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "notify_on_execution": {
                    "type": "boolean"
                  },
                  "notify_channels": {
                    "anyOf": [
                      {
                        "additionalProperties": false,
                        "description": "Notification channels used when notify_on_execution is enabled.",
                        "type": "object",
                        "properties": {
                          "email": {
                            "type": "boolean"
                          },
                          "in_app": {
                            "type": "boolean"
                          },
                          "telegram": {
                            "type": "boolean"
                          }
                        }
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "priority": {
                    "type": "integer"
                  },
                  "template_id": {
                    "anyOf": [
                      {
                        "format": "uuid",
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "platforms": {
                    "type": "array",
                    "items": {
                      "minLength": 1,
                      "maxLength": 40,
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "header",
            "name": "x-team-id",
            "required": false,
            "description": "Destination workspace team id."
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "201": {
            "description": "Automation rule row as persisted in the automation_rule table.",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "description": "Automation rule row as persisted in the automation_rule table.",
                  "type": "object",
                  "required": [
                    "id",
                    "user_id",
                    "name",
                    "description",
                    "status",
                    "entity_level",
                    "ad_account_ids",
                    "entity_filter",
                    "condition_logic",
                    "conditions",
                    "actions",
                    "schedule_type",
                    "interval_minutes",
                    "schedule_config",
                    "timezone",
                    "cooldown_minutes",
                    "max_executions_per_day",
                    "budget_change_limit_pct",
                    "budget_daily_cap",
                    "notify_on_execution",
                    "notify_channels",
                    "platforms",
                    "priority",
                    "template_id",
                    "last_evaluated_at",
                    "last_executed_at",
                    "execution_count",
                    "error_count",
                    "last_error",
                    "auto_paused_at",
                    "auto_pause_reason",
                    "created_at",
                    "updated_at"
                  ],
                  "properties": {
                    "id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "user_id": {
                      "anyOf": [
                        {
                          "format": "uuid",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "created_by": {
                      "anyOf": [
                        {
                          "format": "uuid",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "name": {
                      "type": "string"
                    },
                    "description": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "status": {
                      "anyOf": [
                        {
                          "type": "string",
                          "enum": [
                            "active"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "paused"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "error"
                          ]
                        }
                      ]
                    },
                    "entity_level": {
                      "anyOf": [
                        {
                          "type": "string",
                          "enum": [
                            "campaign"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "adset"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "ad"
                          ]
                        }
                      ]
                    },
                    "ad_account_ids": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "entity_filter": {
                      "description": "Entity filter as stored, tolerant of filters written outside the strict request contract.",
                      "anyOf": [
                        {
                          "additionalProperties": false,
                          "description": "Optional entity filters applied before condition evaluation.",
                          "type": "object",
                          "properties": {
                            "name_contains": {
                              "description": "Case-insensitive substring that must be present in the entity name.",
                              "minLength": 1,
                              "maxLength": 200,
                              "type": "string"
                            },
                            "name_not_contains": {
                              "description": "Case-insensitive substring that must not be present in the entity name.",
                              "minLength": 1,
                              "maxLength": 200,
                              "type": "string"
                            },
                            "status_in": {
                              "description": "Entity statuses to include. Route validation checks whether each status is allowed for the selected entity level.",
                              "minItems": 1,
                              "maxItems": 20,
                              "type": "array",
                              "items": {
                                "minLength": 1,
                                "maxLength": 80,
                                "type": "string"
                              }
                            },
                            "account_mode": {
                              "description": "Ad-account scope intent. \"selected\" means the rule must be restricted to ad_account_ids; combined with an empty ad_account_ids the evaluator matches no entities (it does NOT silently fall back to all accounts). \"all\" (or omitted) evaluates every accessible account.",
                              "anyOf": [
                                {
                                  "type": "string",
                                  "enum": [
                                    "all"
                                  ]
                                },
                                {
                                  "type": "string",
                                  "enum": [
                                    "selected"
                                  ]
                                }
                              ]
                            }
                          }
                        },
                        {
                          "additionalProperties": true,
                          "description": "Entity filter stored before/around the current contract; surfaced as-is so the list stays readable.",
                          "type": "object",
                          "properties": {
                            "name_contains": {
                              "description": "Name filter as stored; may be empty (\"no filter\").",
                              "type": "string"
                            },
                            "name_not_contains": {
                              "description": "Negative name filter as stored; may be empty (\"no filter\").",
                              "type": "string"
                            },
                            "status_in": {
                              "description": "Statuses as stored; may be empty (\"no filter\").",
                              "type": "array",
                              "items": {
                                "type": "string"
                              }
                            },
                            "account_mode": {
                              "description": "Ad-account scope intent as stored.",
                              "type": "string"
                            }
                          }
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "condition_logic": {
                      "anyOf": [
                        {
                          "type": "string",
                          "enum": [
                            "AND"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "OR"
                          ]
                        }
                      ]
                    },
                    "conditions": {
                      "description": "Ordered list of conditions as stored, tolerant of rules written outside the request contract.",
                      "type": "array",
                      "items": {
                        "anyOf": [
                          {
                            "additionalProperties": false,
                            "description": "Single metric threshold evaluated against entity insights.",
                            "type": "object",
                            "required": [
                              "metric",
                              "operator",
                              "time_range",
                              "value"
                            ],
                            "properties": {
                              "metric": {
                                "description": "Metric key (platform metric, derived metric, or action-type KPI from action_types_canonical).",
                                "minLength": 1,
                                "type": "string"
                              },
                              "operator": {
                                "description": "Comparison operator. `between`/`not_between` require both `value` and `value2`; `increased_pct`/`decreased_pct` compare the current `time_range` against the immediately preceding period of equal duration.",
                                "anyOf": [
                                  {
                                    "type": "string",
                                    "enum": [
                                      "gt"
                                    ]
                                  },
                                  {
                                    "type": "string",
                                    "enum": [
                                      "lt"
                                    ]
                                  },
                                  {
                                    "type": "string",
                                    "enum": [
                                      "gte"
                                    ]
                                  },
                                  {
                                    "type": "string",
                                    "enum": [
                                      "lte"
                                    ]
                                  },
                                  {
                                    "type": "string",
                                    "enum": [
                                      "eq"
                                    ]
                                  },
                                  {
                                    "type": "string",
                                    "enum": [
                                      "neq"
                                    ]
                                  },
                                  {
                                    "type": "string",
                                    "enum": [
                                      "between"
                                    ]
                                  },
                                  {
                                    "type": "string",
                                    "enum": [
                                      "not_between"
                                    ]
                                  },
                                  {
                                    "type": "string",
                                    "enum": [
                                      "increased_pct"
                                    ]
                                  },
                                  {
                                    "type": "string",
                                    "enum": [
                                      "decreased_pct"
                                    ]
                                  }
                                ]
                              },
                              "time_range": {
                                "description": "Time window over which the metric is aggregated.",
                                "anyOf": [
                                  {
                                    "type": "string",
                                    "enum": [
                                      "today"
                                    ]
                                  },
                                  {
                                    "type": "string",
                                    "enum": [
                                      "yesterday"
                                    ]
                                  },
                                  {
                                    "type": "string",
                                    "enum": [
                                      "last_3d"
                                    ]
                                  },
                                  {
                                    "type": "string",
                                    "enum": [
                                      "last_7d"
                                    ]
                                  },
                                  {
                                    "type": "string",
                                    "enum": [
                                      "last_14d"
                                    ]
                                  },
                                  {
                                    "type": "string",
                                    "enum": [
                                      "last_30d"
                                    ]
                                  }
                                ]
                              },
                              "value": {
                                "description": "Primary threshold. Coerced to Number at evaluation time.",
                                "anyOf": [
                                  {
                                    "type": "number"
                                  },
                                  {
                                    "type": "string"
                                  }
                                ]
                              },
                              "value2": {
                                "description": "Secondary threshold (required for `between` / `not_between`).",
                                "anyOf": [
                                  {
                                    "type": "number"
                                  },
                                  {
                                    "type": "string"
                                  }
                                ]
                              },
                              "trend_window": {
                                "description": "Time window over which the metric is aggregated.",
                                "anyOf": [
                                  {
                                    "type": "string",
                                    "enum": [
                                      "today"
                                    ]
                                  },
                                  {
                                    "type": "string",
                                    "enum": [
                                      "yesterday"
                                    ]
                                  },
                                  {
                                    "type": "string",
                                    "enum": [
                                      "last_3d"
                                    ]
                                  },
                                  {
                                    "type": "string",
                                    "enum": [
                                      "last_7d"
                                    ]
                                  },
                                  {
                                    "type": "string",
                                    "enum": [
                                      "last_14d"
                                    ]
                                  },
                                  {
                                    "type": "string",
                                    "enum": [
                                      "last_30d"
                                    ]
                                  }
                                ]
                              }
                            }
                          },
                          {
                            "additionalProperties": false,
                            "description": "Account-level comparison across two advertising platforms, or between one platform and a literal.",
                            "type": "object",
                            "required": [
                              "type",
                              "left",
                              "operator",
                              "right"
                            ],
                            "properties": {
                              "type": {
                                "type": "string",
                                "enum": [
                                  "cross_platform_comparison"
                                ]
                              },
                              "left": {
                                "anyOf": [
                                  {
                                    "additionalProperties": false,
                                    "type": "object",
                                    "required": [
                                      "type",
                                      "platform",
                                      "metric"
                                    ],
                                    "properties": {
                                      "type": {
                                        "type": "string",
                                        "enum": [
                                          "platform_metric"
                                        ]
                                      },
                                      "platform": {
                                        "anyOf": [
                                          {
                                            "type": "string",
                                            "enum": [
                                              "META"
                                            ]
                                          },
                                          {
                                            "type": "string",
                                            "enum": [
                                              "GOOGLE"
                                            ]
                                          },
                                          {
                                            "type": "string",
                                            "enum": [
                                              "TIKTOK"
                                            ]
                                          },
                                          {
                                            "type": "string",
                                            "enum": [
                                              "TABOOLA"
                                            ]
                                          },
                                          {
                                            "type": "string",
                                            "enum": [
                                              "LINKEDIN"
                                            ]
                                          }
                                        ]
                                      },
                                      "metric": {
                                        "anyOf": [
                                          {
                                            "type": "string",
                                            "enum": [
                                              "spend"
                                            ]
                                          },
                                          {
                                            "type": "string",
                                            "enum": [
                                              "spend_pct"
                                            ]
                                          },
                                          {
                                            "type": "string",
                                            "enum": [
                                              "impressions"
                                            ]
                                          },
                                          {
                                            "type": "string",
                                            "enum": [
                                              "clicks"
                                            ]
                                          },
                                          {
                                            "type": "string",
                                            "enum": [
                                              "ctr"
                                            ]
                                          },
                                          {
                                            "type": "string",
                                            "enum": [
                                              "cpc"
                                            ]
                                          },
                                          {
                                            "type": "string",
                                            "enum": [
                                              "cpm"
                                            ]
                                          },
                                          {
                                            "type": "string",
                                            "enum": [
                                              "purchases"
                                            ]
                                          },
                                          {
                                            "type": "string",
                                            "enum": [
                                              "purchase_value"
                                            ]
                                          },
                                          {
                                            "type": "string",
                                            "enum": [
                                              "conversions"
                                            ]
                                          },
                                          {
                                            "type": "string",
                                            "enum": [
                                              "roas"
                                            ]
                                          },
                                          {
                                            "type": "string",
                                            "enum": [
                                              "cpa"
                                            ]
                                          },
                                          {
                                            "type": "string",
                                            "enum": [
                                              "cpl"
                                            ]
                                          }
                                        ]
                                      },
                                      "level": {
                                        "type": "string",
                                        "enum": [
                                          "account"
                                        ]
                                      },
                                      "timeframe_days": {
                                        "minimum": 1,
                                        "maximum": 90,
                                        "type": "integer"
                                      },
                                      "multiplier": {
                                        "minimum": 0,
                                        "type": "number"
                                      }
                                    }
                                  },
                                  {
                                    "additionalProperties": false,
                                    "type": "object",
                                    "required": [
                                      "type",
                                      "value"
                                    ],
                                    "properties": {
                                      "type": {
                                        "type": "string",
                                        "enum": [
                                          "literal"
                                        ]
                                      },
                                      "value": {
                                        "type": "number"
                                      }
                                    }
                                  }
                                ]
                              },
                              "operator": {
                                "anyOf": [
                                  {
                                    "type": "string",
                                    "enum": [
                                      "greater_than"
                                    ]
                                  },
                                  {
                                    "type": "string",
                                    "enum": [
                                      "less_than"
                                    ]
                                  },
                                  {
                                    "type": "string",
                                    "enum": [
                                      "greater_or_equal"
                                    ]
                                  },
                                  {
                                    "type": "string",
                                    "enum": [
                                      "less_or_equal"
                                    ]
                                  },
                                  {
                                    "type": "string",
                                    "enum": [
                                      "equal"
                                    ]
                                  }
                                ]
                              },
                              "right": {
                                "anyOf": [
                                  {
                                    "additionalProperties": false,
                                    "type": "object",
                                    "required": [
                                      "type",
                                      "platform",
                                      "metric"
                                    ],
                                    "properties": {
                                      "type": {
                                        "type": "string",
                                        "enum": [
                                          "platform_metric"
                                        ]
                                      },
                                      "platform": {
                                        "anyOf": [
                                          {
                                            "type": "string",
                                            "enum": [
                                              "META"
                                            ]
                                          },
                                          {
                                            "type": "string",
                                            "enum": [
                                              "GOOGLE"
                                            ]
                                          },
                                          {
                                            "type": "string",
                                            "enum": [
                                              "TIKTOK"
                                            ]
                                          },
                                          {
                                            "type": "string",
                                            "enum": [
                                              "TABOOLA"
                                            ]
                                          },
                                          {
                                            "type": "string",
                                            "enum": [
                                              "LINKEDIN"
                                            ]
                                          }
                                        ]
                                      },
                                      "metric": {
                                        "anyOf": [
                                          {
                                            "type": "string",
                                            "enum": [
                                              "spend"
                                            ]
                                          },
                                          {
                                            "type": "string",
                                            "enum": [
                                              "spend_pct"
                                            ]
                                          },
                                          {
                                            "type": "string",
                                            "enum": [
                                              "impressions"
                                            ]
                                          },
                                          {
                                            "type": "string",
                                            "enum": [
                                              "clicks"
                                            ]
                                          },
                                          {
                                            "type": "string",
                                            "enum": [
                                              "ctr"
                                            ]
                                          },
                                          {
                                            "type": "string",
                                            "enum": [
                                              "cpc"
                                            ]
                                          },
                                          {
                                            "type": "string",
                                            "enum": [
                                              "cpm"
                                            ]
                                          },
                                          {
                                            "type": "string",
                                            "enum": [
                                              "purchases"
                                            ]
                                          },
                                          {
                                            "type": "string",
                                            "enum": [
                                              "purchase_value"
                                            ]
                                          },
                                          {
                                            "type": "string",
                                            "enum": [
                                              "conversions"
                                            ]
                                          },
                                          {
                                            "type": "string",
                                            "enum": [
                                              "roas"
                                            ]
                                          },
                                          {
                                            "type": "string",
                                            "enum": [
                                              "cpa"
                                            ]
                                          },
                                          {
                                            "type": "string",
                                            "enum": [
                                              "cpl"
                                            ]
                                          }
                                        ]
                                      },
                                      "level": {
                                        "type": "string",
                                        "enum": [
                                          "account"
                                        ]
                                      },
                                      "timeframe_days": {
                                        "minimum": 1,
                                        "maximum": 90,
                                        "type": "integer"
                                      },
                                      "multiplier": {
                                        "minimum": 0,
                                        "type": "number"
                                      }
                                    }
                                  },
                                  {
                                    "additionalProperties": false,
                                    "type": "object",
                                    "required": [
                                      "type",
                                      "value"
                                    ],
                                    "properties": {
                                      "type": {
                                        "type": "string",
                                        "enum": [
                                          "literal"
                                        ]
                                      },
                                      "value": {
                                        "type": "number"
                                      }
                                    }
                                  }
                                ]
                              }
                            }
                          },
                          {
                            "additionalProperties": true,
                            "description": "Rule condition stored without the full current contract; surfaced as-is so the list stays readable.",
                            "type": "object",
                            "properties": {
                              "metric": {
                                "description": "Metric key as stored.",
                                "type": "string"
                              },
                              "operator": {
                                "description": "Comparison operator as stored.",
                                "type": "string"
                              },
                              "time_range": {
                                "description": "Time window as stored; absent means the evaluator default (`today`).",
                                "type": "string"
                              }
                            }
                          }
                        ]
                      }
                    },
                    "actions": {
                      "description": "Ordered list of actions as stored, tolerant of rules written before the current schema.",
                      "type": "array",
                      "items": {
                        "anyOf": [
                          {
                            "description": "Automation rule action. Discriminated on `type`. See RuleActionType in src/sqs/types/messages.ts.",
                            "anyOf": [
                              {
                                "additionalProperties": false,
                                "type": "object",
                                "required": [
                                  "type"
                                ],
                                "properties": {
                                  "type": {
                                    "description": "Pause the matched entity (campaign/adset/ad).",
                                    "type": "string",
                                    "enum": [
                                      "pause"
                                    ]
                                  },
                                  "params": {
                                    "$comment": "json-value",
                                    "description": "Arbitrary JSON value with nested arrays and objects."
                                  }
                                }
                              },
                              {
                                "additionalProperties": false,
                                "type": "object",
                                "required": [
                                  "type"
                                ],
                                "properties": {
                                  "type": {
                                    "description": "Activate the matched entity (campaign/adset/ad).",
                                    "type": "string",
                                    "enum": [
                                      "activate"
                                    ]
                                  },
                                  "params": {
                                    "$comment": "json-value",
                                    "description": "Arbitrary JSON value with nested arrays and objects."
                                  }
                                }
                              },
                              {
                                "additionalProperties": false,
                                "type": "object",
                                "required": [
                                  "type"
                                ],
                                "properties": {
                                  "type": {
                                    "description": "Increase campaign/adset budget by `params.percentage` percent.",
                                    "type": "string",
                                    "enum": [
                                      "increase_budget_pct"
                                    ]
                                  },
                                  "params": {
                                    "additionalProperties": false,
                                    "type": "object",
                                    "properties": {
                                      "percentage": {
                                        "description": "Percent increase in [1, 1000] (defaults to 20 if omitted at runtime). 0 is rejected because a 0% change is a no-op and the worker clamps it to 1 anyway — the schema makes that contract explicit. The ceiling is deliberately far above 100: doubling or tripling a budget is ordinary media buying, and the old 100 cap (borrowed from the decrease action, where >100% is meaningless) made the rules list unserializable for anyone who had scaled a budget by more.",
                                        "minimum": 1,
                                        "maximum": 1000,
                                        "type": "number"
                                      },
                                      "pct": {
                                        "description": "Legacy template alias for `percentage`; accepted for seeded rule templates.",
                                        "minimum": 1,
                                        "maximum": 1000,
                                        "type": "number"
                                      }
                                    }
                                  }
                                }
                              },
                              {
                                "additionalProperties": false,
                                "type": "object",
                                "required": [
                                  "type"
                                ],
                                "properties": {
                                  "type": {
                                    "description": "Decrease campaign/adset budget by `params.percentage` percent.",
                                    "type": "string",
                                    "enum": [
                                      "decrease_budget_pct"
                                    ]
                                  },
                                  "params": {
                                    "additionalProperties": false,
                                    "type": "object",
                                    "properties": {
                                      "percentage": {
                                        "description": "Percent change in [1, 100] (defaults to 20 if omitted at runtime). 0 is rejected because a 0% change is a no-op and the worker clamps it to 1 anyway — the schema makes that contract explicit.",
                                        "minimum": 1,
                                        "maximum": 100,
                                        "type": "number"
                                      },
                                      "pct": {
                                        "description": "Legacy template alias for `percentage`; accepted for seeded rule templates.",
                                        "minimum": 1,
                                        "maximum": 100,
                                        "type": "number"
                                      }
                                    }
                                  }
                                }
                              },
                              {
                                "additionalProperties": false,
                                "type": "object",
                                "required": [
                                  "type"
                                ],
                                "properties": {
                                  "type": {
                                    "description": "Relaunch the ad (duplicate + delete original). Only valid at ad level.",
                                    "type": "string",
                                    "enum": [
                                      "relaunch"
                                    ]
                                  },
                                  "params": {
                                    "$comment": "json-value",
                                    "description": "Arbitrary JSON value with nested arrays and objects."
                                  }
                                }
                              },
                              {
                                "additionalProperties": false,
                                "type": "object",
                                "required": [
                                  "type"
                                ],
                                "properties": {
                                  "type": {
                                    "description": "Send a notification but do not mutate anything on Meta.",
                                    "type": "string",
                                    "enum": [
                                      "notify_only"
                                    ]
                                  },
                                  "params": {
                                    "$comment": "json-value",
                                    "description": "Arbitrary JSON value with nested arrays and objects."
                                  }
                                }
                              },
                              {
                                "additionalProperties": false,
                                "type": "object",
                                "required": [
                                  "type",
                                  "platform",
                                  "entity_level"
                                ],
                                "properties": {
                                  "type": {
                                    "type": "string",
                                    "enum": [
                                      "PAUSE_TOP_SPEND_CAMPAIGN"
                                    ]
                                  },
                                  "platform": {
                                    "anyOf": [
                                      {
                                        "type": "string",
                                        "enum": [
                                          "META"
                                        ]
                                      },
                                      {
                                        "type": "string",
                                        "enum": [
                                          "GOOGLE"
                                        ]
                                      },
                                      {
                                        "type": "string",
                                        "enum": [
                                          "TIKTOK"
                                        ]
                                      },
                                      {
                                        "type": "string",
                                        "enum": [
                                          "TABOOLA"
                                        ]
                                      },
                                      {
                                        "type": "string",
                                        "enum": [
                                          "LINKEDIN"
                                        ]
                                      }
                                    ]
                                  },
                                  "entity_level": {
                                    "type": "string",
                                    "enum": [
                                      "campaign"
                                    ]
                                  }
                                }
                              },
                              {
                                "additionalProperties": false,
                                "type": "object",
                                "required": [
                                  "type",
                                  "platform",
                                  "entity_level",
                                  "pct"
                                ],
                                "properties": {
                                  "type": {
                                    "anyOf": [
                                      {
                                        "type": "string",
                                        "enum": [
                                          "INCREASE_BUDGET_PCT"
                                        ]
                                      },
                                      {
                                        "type": "string",
                                        "enum": [
                                          "DECREASE_BUDGET_PCT"
                                        ]
                                      }
                                    ]
                                  },
                                  "platform": {
                                    "anyOf": [
                                      {
                                        "type": "string",
                                        "enum": [
                                          "META"
                                        ]
                                      },
                                      {
                                        "type": "string",
                                        "enum": [
                                          "GOOGLE"
                                        ]
                                      },
                                      {
                                        "type": "string",
                                        "enum": [
                                          "TIKTOK"
                                        ]
                                      },
                                      {
                                        "type": "string",
                                        "enum": [
                                          "TABOOLA"
                                        ]
                                      },
                                      {
                                        "type": "string",
                                        "enum": [
                                          "LINKEDIN"
                                        ]
                                      }
                                    ]
                                  },
                                  "entity_level": {
                                    "type": "string",
                                    "enum": [
                                      "campaign"
                                    ]
                                  },
                                  "pct": {
                                    "minimum": 1,
                                    "maximum": 100,
                                    "type": "number"
                                  }
                                }
                              },
                              {
                                "additionalProperties": false,
                                "type": "object",
                                "required": [
                                  "type",
                                  "channel",
                                  "message_template"
                                ],
                                "properties": {
                                  "type": {
                                    "type": "string",
                                    "enum": [
                                      "NOTIFY_CHANNEL"
                                    ]
                                  },
                                  "channel": {
                                    "anyOf": [
                                      {
                                        "type": "string",
                                        "enum": [
                                          "in_app"
                                        ]
                                      },
                                      {
                                        "type": "string",
                                        "enum": [
                                          "email"
                                        ]
                                      },
                                      {
                                        "type": "string",
                                        "enum": [
                                          "telegram"
                                        ]
                                      }
                                    ]
                                  },
                                  "message_template": {
                                    "minLength": 1,
                                    "maxLength": 500,
                                    "type": "string"
                                  }
                                }
                              }
                            ]
                          },
                          {
                            "additionalProperties": true,
                            "description": "Rule action stored before the current schema; surfaced as-is so the list stays readable.",
                            "type": "object",
                            "required": [
                              "type"
                            ],
                            "properties": {
                              "type": {
                                "description": "Action discriminator as stored, including legacy spellings.",
                                "type": "string"
                              },
                              "params": {
                                "$comment": "json-value",
                                "description": "Arbitrary JSON value with nested arrays and objects."
                              }
                            }
                          }
                        ]
                      }
                    },
                    "schedule_type": {
                      "anyOf": [
                        {
                          "type": "string",
                          "enum": [
                            "interval"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "daily"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "daily_at_time"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "day_parting"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "custom"
                          ]
                        }
                      ]
                    },
                    "interval_minutes": {
                      "type": "integer"
                    },
                    "schedule_config": {
                      "description": "Schedule config as stored, tolerant of values written outside the strict request contract.",
                      "anyOf": [
                        {
                          "additionalProperties": false,
                          "description": "Optional schedule-specific rule configuration. `daily_at_time` uses `time`; `day_parting` uses `hours_of_day`/`days_of_week` and/or explicit `slots`.",
                          "type": "object",
                          "properties": {
                            "time": {
                              "description": "Daily evaluation time in HH:MM format. Runtime validation enforces 00:00-23:59.",
                              "type": "string"
                            },
                            "type": {
                              "type": "string",
                              "enum": [
                                "day_parting"
                              ]
                            },
                            "hours_of_day": {
                              "description": "Hours of day eligible for evaluation. Runtime validation enforces non-empty integers 0-23.",
                              "maxItems": 24,
                              "type": "array",
                              "items": {
                                "type": "number"
                              }
                            },
                            "days_of_week": {
                              "description": "Days of week eligible for evaluation, where 0 is Sunday and 6 is Saturday.",
                              "maxItems": 7,
                              "type": "array",
                              "items": {
                                "type": "number"
                              }
                            },
                            "slots": {
                              "description": "Explicit day/hour evaluation slots. Runtime validation enforces non-empty valid slots.",
                              "type": "array",
                              "items": {
                                "additionalProperties": false,
                                "type": "object",
                                "required": [
                                  "day",
                                  "hour"
                                ],
                                "properties": {
                                  "day": {
                                    "description": "Day of week, where 0 is Sunday and 6 is Saturday. Runtime validation enforces integer 0-6.",
                                    "type": "number"
                                  },
                                  "hour": {
                                    "description": "Hour of day in 24-hour format. Runtime validation enforces integer 0-23.",
                                    "type": "number"
                                  }
                                }
                              }
                            },
                            "timezone": {
                              "minLength": 1,
                              "maxLength": 100,
                              "type": "string"
                            }
                          }
                        },
                        {
                          "additionalProperties": true,
                          "description": "Schedule config stored before/around the current contract; surfaced as-is.",
                          "type": "object",
                          "properties": {
                            "time": {
                              "description": "Daily evaluation time as stored.",
                              "type": "string"
                            },
                            "type": {
                              "description": "Schedule discriminator as stored.",
                              "type": "string"
                            },
                            "hours_of_day": {
                              "description": "Hours as stored.",
                              "type": "array",
                              "items": {
                                "type": "number"
                              }
                            },
                            "days_of_week": {
                              "description": "Days as stored.",
                              "type": "array",
                              "items": {
                                "type": "number"
                              }
                            },
                            "slots": {
                              "description": "Day/hour slots as stored.",
                              "type": "array",
                              "items": {
                                "additionalProperties": true,
                                "type": "object",
                                "properties": {
                                  "day": {
                                    "type": "number"
                                  },
                                  "hour": {
                                    "type": "number"
                                  }
                                }
                              }
                            },
                            "timezone": {
                              "description": "Timezone as stored.",
                              "type": "string"
                            }
                          }
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "timezone": {
                      "type": "string"
                    },
                    "cooldown_minutes": {
                      "type": "integer"
                    },
                    "max_executions_per_day": {
                      "type": "integer"
                    },
                    "budget_change_limit_pct": {
                      "anyOf": [
                        {
                          "type": "number"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "budget_daily_cap": {
                      "anyOf": [
                        {
                          "type": "number"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "notify_on_execution": {
                      "type": "boolean"
                    },
                    "notify_channels": {
                      "description": "Notify channels as stored, tolerant of values written outside the strict request contract.",
                      "anyOf": [
                        {
                          "additionalProperties": false,
                          "description": "Notification channels used when notify_on_execution is enabled.",
                          "type": "object",
                          "properties": {
                            "email": {
                              "type": "boolean"
                            },
                            "in_app": {
                              "type": "boolean"
                            },
                            "telegram": {
                              "type": "boolean"
                            }
                          }
                        },
                        {
                          "additionalProperties": true,
                          "description": "Notify channels stored before/around the current contract; surfaced as-is.",
                          "type": "object",
                          "properties": {
                            "email": {
                              "type": "boolean"
                            },
                            "in_app": {
                              "type": "boolean"
                            },
                            "telegram": {
                              "type": "boolean"
                            }
                          }
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "platforms": {
                      "type": "array",
                      "items": {
                        "minLength": 1,
                        "maxLength": 40,
                        "type": "string"
                      }
                    },
                    "priority": {
                      "type": "integer"
                    },
                    "template_id": {
                      "anyOf": [
                        {
                          "format": "uuid",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "last_evaluated_at": {
                      "anyOf": [
                        {
                          "format": "date-time",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "last_executed_at": {
                      "anyOf": [
                        {
                          "format": "date-time",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "execution_count": {
                      "type": "integer"
                    },
                    "error_count": {
                      "type": "integer"
                    },
                    "last_error": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "auto_paused_at": {
                      "anyOf": [
                        {
                          "format": "date-time",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "auto_pause_reason": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "cb_reset_after": {
                      "anyOf": [
                        {
                          "format": "date-time",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "created_at": {
                      "format": "date-time",
                      "type": "string"
                    },
                    "updated_at": {
                      "format": "date-time",
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "integer"
                    },
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "details": {
                      "type": "array",
                      "items": {
                        "additionalProperties": false,
                        "type": "object",
                        "required": [
                          "code",
                          "field",
                          "message"
                        ],
                        "properties": {
                          "code": {
                            "type": "string"
                          },
                          "field": {
                            "type": "string"
                          },
                          "message": {
                            "type": "string"
                          }
                        }
                      }
                    },
                    "validation": {
                      "type": "array",
                      "items": {
                        "additionalProperties": true,
                        "description": "AJV validation error item returned by Fastify for invalid params, querystrings, or bodies.",
                        "type": "object",
                        "properties": {
                          "instancePath": {
                            "type": "string"
                          },
                          "schemaPath": {
                            "type": "string"
                          },
                          "keyword": {
                            "type": "string"
                          },
                          "params": {
                            "type": "object",
                            "additionalProperties": {
                              "$comment": "json-value",
                              "description": "Arbitrary JSON value with nested arrays and objects."
                            }
                          },
                          "message": {
                            "type": "string"
                          }
                        }
                      }
                    },
                    "validationContext": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "integer"
                    },
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "integer"
                    },
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/rules/templates": {
      "get": {
        "operationId": "listRuleTemplates",
        "summary": "List rule templates",
        "tags": [
          "rules"
        ],
        "description": "Returns a list of active rule templates, optionally filtered by category and entity level.",
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "category",
            "required": false
          },
          {
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "enum": [
                    "campaign"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "adset"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "ad"
                  ]
                }
              ]
            },
            "in": "query",
            "name": "entity_level",
            "required": false
          },
          {
            "schema": {
              "pattern": "^[a-z]+(?:,[a-z]+)*$",
              "type": "string"
            },
            "in": "query",
            "name": "platform",
            "required": false
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "items"
                  ],
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "additionalProperties": true,
                        "type": "object",
                        "required": [
                          "id",
                          "name",
                          "name_it",
                          "name_en",
                          "description_it",
                          "description_en",
                          "category",
                          "icon",
                          "entity_level",
                          "condition_logic",
                          "conditions",
                          "actions",
                          "schedule_type",
                          "interval_minutes",
                          "cooldown_minutes",
                          "parameters",
                          "popularity",
                          "is_active",
                          "platforms",
                          "created_at"
                        ],
                        "properties": {
                          "id": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "name": {
                            "type": "string"
                          },
                          "name_it": {
                            "type": "string"
                          },
                          "name_en": {
                            "type": "string"
                          },
                          "description_it": {
                            "type": "string"
                          },
                          "description_en": {
                            "type": "string"
                          },
                          "category": {
                            "type": "string"
                          },
                          "icon": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "entity_level": {
                            "anyOf": [
                              {
                                "type": "string",
                                "enum": [
                                  "campaign"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "adset"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "ad"
                                ]
                              }
                            ]
                          },
                          "condition_logic": {
                            "anyOf": [
                              {
                                "type": "string",
                                "enum": [
                                  "AND"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "OR"
                                ]
                              }
                            ]
                          },
                          "conditions": {
                            "description": "Ordered list of conditions as stored, tolerant of rules written outside the request contract.",
                            "type": "array",
                            "items": {
                              "anyOf": [
                                {
                                  "additionalProperties": false,
                                  "description": "Single metric threshold evaluated against entity insights.",
                                  "type": "object",
                                  "required": [
                                    "metric",
                                    "operator",
                                    "time_range",
                                    "value"
                                  ],
                                  "properties": {
                                    "metric": {
                                      "description": "Metric key (platform metric, derived metric, or action-type KPI from action_types_canonical).",
                                      "minLength": 1,
                                      "type": "string"
                                    },
                                    "operator": {
                                      "description": "Comparison operator. `between`/`not_between` require both `value` and `value2`; `increased_pct`/`decreased_pct` compare the current `time_range` against the immediately preceding period of equal duration.",
                                      "anyOf": [
                                        {
                                          "type": "string",
                                          "enum": [
                                            "gt"
                                          ]
                                        },
                                        {
                                          "type": "string",
                                          "enum": [
                                            "lt"
                                          ]
                                        },
                                        {
                                          "type": "string",
                                          "enum": [
                                            "gte"
                                          ]
                                        },
                                        {
                                          "type": "string",
                                          "enum": [
                                            "lte"
                                          ]
                                        },
                                        {
                                          "type": "string",
                                          "enum": [
                                            "eq"
                                          ]
                                        },
                                        {
                                          "type": "string",
                                          "enum": [
                                            "neq"
                                          ]
                                        },
                                        {
                                          "type": "string",
                                          "enum": [
                                            "between"
                                          ]
                                        },
                                        {
                                          "type": "string",
                                          "enum": [
                                            "not_between"
                                          ]
                                        },
                                        {
                                          "type": "string",
                                          "enum": [
                                            "increased_pct"
                                          ]
                                        },
                                        {
                                          "type": "string",
                                          "enum": [
                                            "decreased_pct"
                                          ]
                                        }
                                      ]
                                    },
                                    "time_range": {
                                      "description": "Time window over which the metric is aggregated.",
                                      "anyOf": [
                                        {
                                          "type": "string",
                                          "enum": [
                                            "today"
                                          ]
                                        },
                                        {
                                          "type": "string",
                                          "enum": [
                                            "yesterday"
                                          ]
                                        },
                                        {
                                          "type": "string",
                                          "enum": [
                                            "last_3d"
                                          ]
                                        },
                                        {
                                          "type": "string",
                                          "enum": [
                                            "last_7d"
                                          ]
                                        },
                                        {
                                          "type": "string",
                                          "enum": [
                                            "last_14d"
                                          ]
                                        },
                                        {
                                          "type": "string",
                                          "enum": [
                                            "last_30d"
                                          ]
                                        }
                                      ]
                                    },
                                    "value": {
                                      "description": "Primary threshold. Coerced to Number at evaluation time.",
                                      "anyOf": [
                                        {
                                          "type": "number"
                                        },
                                        {
                                          "type": "string"
                                        }
                                      ]
                                    },
                                    "value2": {
                                      "description": "Secondary threshold (required for `between` / `not_between`).",
                                      "anyOf": [
                                        {
                                          "type": "number"
                                        },
                                        {
                                          "type": "string"
                                        }
                                      ]
                                    },
                                    "trend_window": {
                                      "description": "Time window over which the metric is aggregated.",
                                      "anyOf": [
                                        {
                                          "type": "string",
                                          "enum": [
                                            "today"
                                          ]
                                        },
                                        {
                                          "type": "string",
                                          "enum": [
                                            "yesterday"
                                          ]
                                        },
                                        {
                                          "type": "string",
                                          "enum": [
                                            "last_3d"
                                          ]
                                        },
                                        {
                                          "type": "string",
                                          "enum": [
                                            "last_7d"
                                          ]
                                        },
                                        {
                                          "type": "string",
                                          "enum": [
                                            "last_14d"
                                          ]
                                        },
                                        {
                                          "type": "string",
                                          "enum": [
                                            "last_30d"
                                          ]
                                        }
                                      ]
                                    }
                                  }
                                },
                                {
                                  "additionalProperties": false,
                                  "description": "Account-level comparison across two advertising platforms, or between one platform and a literal.",
                                  "type": "object",
                                  "required": [
                                    "type",
                                    "left",
                                    "operator",
                                    "right"
                                  ],
                                  "properties": {
                                    "type": {
                                      "type": "string",
                                      "enum": [
                                        "cross_platform_comparison"
                                      ]
                                    },
                                    "left": {
                                      "anyOf": [
                                        {
                                          "additionalProperties": false,
                                          "type": "object",
                                          "required": [
                                            "type",
                                            "platform",
                                            "metric"
                                          ],
                                          "properties": {
                                            "type": {
                                              "type": "string",
                                              "enum": [
                                                "platform_metric"
                                              ]
                                            },
                                            "platform": {
                                              "anyOf": [
                                                {
                                                  "type": "string",
                                                  "enum": [
                                                    "META"
                                                  ]
                                                },
                                                {
                                                  "type": "string",
                                                  "enum": [
                                                    "GOOGLE"
                                                  ]
                                                },
                                                {
                                                  "type": "string",
                                                  "enum": [
                                                    "TIKTOK"
                                                  ]
                                                },
                                                {
                                                  "type": "string",
                                                  "enum": [
                                                    "TABOOLA"
                                                  ]
                                                },
                                                {
                                                  "type": "string",
                                                  "enum": [
                                                    "LINKEDIN"
                                                  ]
                                                }
                                              ]
                                            },
                                            "metric": {
                                              "anyOf": [
                                                {
                                                  "type": "string",
                                                  "enum": [
                                                    "spend"
                                                  ]
                                                },
                                                {
                                                  "type": "string",
                                                  "enum": [
                                                    "spend_pct"
                                                  ]
                                                },
                                                {
                                                  "type": "string",
                                                  "enum": [
                                                    "impressions"
                                                  ]
                                                },
                                                {
                                                  "type": "string",
                                                  "enum": [
                                                    "clicks"
                                                  ]
                                                },
                                                {
                                                  "type": "string",
                                                  "enum": [
                                                    "ctr"
                                                  ]
                                                },
                                                {
                                                  "type": "string",
                                                  "enum": [
                                                    "cpc"
                                                  ]
                                                },
                                                {
                                                  "type": "string",
                                                  "enum": [
                                                    "cpm"
                                                  ]
                                                },
                                                {
                                                  "type": "string",
                                                  "enum": [
                                                    "purchases"
                                                  ]
                                                },
                                                {
                                                  "type": "string",
                                                  "enum": [
                                                    "purchase_value"
                                                  ]
                                                },
                                                {
                                                  "type": "string",
                                                  "enum": [
                                                    "conversions"
                                                  ]
                                                },
                                                {
                                                  "type": "string",
                                                  "enum": [
                                                    "roas"
                                                  ]
                                                },
                                                {
                                                  "type": "string",
                                                  "enum": [
                                                    "cpa"
                                                  ]
                                                },
                                                {
                                                  "type": "string",
                                                  "enum": [
                                                    "cpl"
                                                  ]
                                                }
                                              ]
                                            },
                                            "level": {
                                              "type": "string",
                                              "enum": [
                                                "account"
                                              ]
                                            },
                                            "timeframe_days": {
                                              "minimum": 1,
                                              "maximum": 90,
                                              "type": "integer"
                                            },
                                            "multiplier": {
                                              "minimum": 0,
                                              "type": "number"
                                            }
                                          }
                                        },
                                        {
                                          "additionalProperties": false,
                                          "type": "object",
                                          "required": [
                                            "type",
                                            "value"
                                          ],
                                          "properties": {
                                            "type": {
                                              "type": "string",
                                              "enum": [
                                                "literal"
                                              ]
                                            },
                                            "value": {
                                              "type": "number"
                                            }
                                          }
                                        }
                                      ]
                                    },
                                    "operator": {
                                      "anyOf": [
                                        {
                                          "type": "string",
                                          "enum": [
                                            "greater_than"
                                          ]
                                        },
                                        {
                                          "type": "string",
                                          "enum": [
                                            "less_than"
                                          ]
                                        },
                                        {
                                          "type": "string",
                                          "enum": [
                                            "greater_or_equal"
                                          ]
                                        },
                                        {
                                          "type": "string",
                                          "enum": [
                                            "less_or_equal"
                                          ]
                                        },
                                        {
                                          "type": "string",
                                          "enum": [
                                            "equal"
                                          ]
                                        }
                                      ]
                                    },
                                    "right": {
                                      "anyOf": [
                                        {
                                          "additionalProperties": false,
                                          "type": "object",
                                          "required": [
                                            "type",
                                            "platform",
                                            "metric"
                                          ],
                                          "properties": {
                                            "type": {
                                              "type": "string",
                                              "enum": [
                                                "platform_metric"
                                              ]
                                            },
                                            "platform": {
                                              "anyOf": [
                                                {
                                                  "type": "string",
                                                  "enum": [
                                                    "META"
                                                  ]
                                                },
                                                {
                                                  "type": "string",
                                                  "enum": [
                                                    "GOOGLE"
                                                  ]
                                                },
                                                {
                                                  "type": "string",
                                                  "enum": [
                                                    "TIKTOK"
                                                  ]
                                                },
                                                {
                                                  "type": "string",
                                                  "enum": [
                                                    "TABOOLA"
                                                  ]
                                                },
                                                {
                                                  "type": "string",
                                                  "enum": [
                                                    "LINKEDIN"
                                                  ]
                                                }
                                              ]
                                            },
                                            "metric": {
                                              "anyOf": [
                                                {
                                                  "type": "string",
                                                  "enum": [
                                                    "spend"
                                                  ]
                                                },
                                                {
                                                  "type": "string",
                                                  "enum": [
                                                    "spend_pct"
                                                  ]
                                                },
                                                {
                                                  "type": "string",
                                                  "enum": [
                                                    "impressions"
                                                  ]
                                                },
                                                {
                                                  "type": "string",
                                                  "enum": [
                                                    "clicks"
                                                  ]
                                                },
                                                {
                                                  "type": "string",
                                                  "enum": [
                                                    "ctr"
                                                  ]
                                                },
                                                {
                                                  "type": "string",
                                                  "enum": [
                                                    "cpc"
                                                  ]
                                                },
                                                {
                                                  "type": "string",
                                                  "enum": [
                                                    "cpm"
                                                  ]
                                                },
                                                {
                                                  "type": "string",
                                                  "enum": [
                                                    "purchases"
                                                  ]
                                                },
                                                {
                                                  "type": "string",
                                                  "enum": [
                                                    "purchase_value"
                                                  ]
                                                },
                                                {
                                                  "type": "string",
                                                  "enum": [
                                                    "conversions"
                                                  ]
                                                },
                                                {
                                                  "type": "string",
                                                  "enum": [
                                                    "roas"
                                                  ]
                                                },
                                                {
                                                  "type": "string",
                                                  "enum": [
                                                    "cpa"
                                                  ]
                                                },
                                                {
                                                  "type": "string",
                                                  "enum": [
                                                    "cpl"
                                                  ]
                                                }
                                              ]
                                            },
                                            "level": {
                                              "type": "string",
                                              "enum": [
                                                "account"
                                              ]
                                            },
                                            "timeframe_days": {
                                              "minimum": 1,
                                              "maximum": 90,
                                              "type": "integer"
                                            },
                                            "multiplier": {
                                              "minimum": 0,
                                              "type": "number"
                                            }
                                          }
                                        },
                                        {
                                          "additionalProperties": false,
                                          "type": "object",
                                          "required": [
                                            "type",
                                            "value"
                                          ],
                                          "properties": {
                                            "type": {
                                              "type": "string",
                                              "enum": [
                                                "literal"
                                              ]
                                            },
                                            "value": {
                                              "type": "number"
                                            }
                                          }
                                        }
                                      ]
                                    }
                                  }
                                },
                                {
                                  "additionalProperties": true,
                                  "description": "Rule condition stored without the full current contract; surfaced as-is so the list stays readable.",
                                  "type": "object",
                                  "properties": {
                                    "metric": {
                                      "description": "Metric key as stored.",
                                      "type": "string"
                                    },
                                    "operator": {
                                      "description": "Comparison operator as stored.",
                                      "type": "string"
                                    },
                                    "time_range": {
                                      "description": "Time window as stored; absent means the evaluator default (`today`).",
                                      "type": "string"
                                    }
                                  }
                                }
                              ]
                            }
                          },
                          "actions": {
                            "description": "Ordered list of actions as stored, tolerant of rules written before the current schema.",
                            "type": "array",
                            "items": {
                              "anyOf": [
                                {
                                  "description": "Automation rule action. Discriminated on `type`. See RuleActionType in src/sqs/types/messages.ts.",
                                  "anyOf": [
                                    {
                                      "additionalProperties": false,
                                      "type": "object",
                                      "required": [
                                        "type"
                                      ],
                                      "properties": {
                                        "type": {
                                          "description": "Pause the matched entity (campaign/adset/ad).",
                                          "type": "string",
                                          "enum": [
                                            "pause"
                                          ]
                                        },
                                        "params": {
                                          "$comment": "json-value",
                                          "description": "Arbitrary JSON value with nested arrays and objects."
                                        }
                                      }
                                    },
                                    {
                                      "additionalProperties": false,
                                      "type": "object",
                                      "required": [
                                        "type"
                                      ],
                                      "properties": {
                                        "type": {
                                          "description": "Activate the matched entity (campaign/adset/ad).",
                                          "type": "string",
                                          "enum": [
                                            "activate"
                                          ]
                                        },
                                        "params": {
                                          "$comment": "json-value",
                                          "description": "Arbitrary JSON value with nested arrays and objects."
                                        }
                                      }
                                    },
                                    {
                                      "additionalProperties": false,
                                      "type": "object",
                                      "required": [
                                        "type"
                                      ],
                                      "properties": {
                                        "type": {
                                          "description": "Increase campaign/adset budget by `params.percentage` percent.",
                                          "type": "string",
                                          "enum": [
                                            "increase_budget_pct"
                                          ]
                                        },
                                        "params": {
                                          "additionalProperties": false,
                                          "type": "object",
                                          "properties": {
                                            "percentage": {
                                              "description": "Percent increase in [1, 1000] (defaults to 20 if omitted at runtime). 0 is rejected because a 0% change is a no-op and the worker clamps it to 1 anyway — the schema makes that contract explicit. The ceiling is deliberately far above 100: doubling or tripling a budget is ordinary media buying, and the old 100 cap (borrowed from the decrease action, where >100% is meaningless) made the rules list unserializable for anyone who had scaled a budget by more.",
                                              "minimum": 1,
                                              "maximum": 1000,
                                              "type": "number"
                                            },
                                            "pct": {
                                              "description": "Legacy template alias for `percentage`; accepted for seeded rule templates.",
                                              "minimum": 1,
                                              "maximum": 1000,
                                              "type": "number"
                                            }
                                          }
                                        }
                                      }
                                    },
                                    {
                                      "additionalProperties": false,
                                      "type": "object",
                                      "required": [
                                        "type"
                                      ],
                                      "properties": {
                                        "type": {
                                          "description": "Decrease campaign/adset budget by `params.percentage` percent.",
                                          "type": "string",
                                          "enum": [
                                            "decrease_budget_pct"
                                          ]
                                        },
                                        "params": {
                                          "additionalProperties": false,
                                          "type": "object",
                                          "properties": {
                                            "percentage": {
                                              "description": "Percent change in [1, 100] (defaults to 20 if omitted at runtime). 0 is rejected because a 0% change is a no-op and the worker clamps it to 1 anyway — the schema makes that contract explicit.",
                                              "minimum": 1,
                                              "maximum": 100,
                                              "type": "number"
                                            },
                                            "pct": {
                                              "description": "Legacy template alias for `percentage`; accepted for seeded rule templates.",
                                              "minimum": 1,
                                              "maximum": 100,
                                              "type": "number"
                                            }
                                          }
                                        }
                                      }
                                    },
                                    {
                                      "additionalProperties": false,
                                      "type": "object",
                                      "required": [
                                        "type"
                                      ],
                                      "properties": {
                                        "type": {
                                          "description": "Relaunch the ad (duplicate + delete original). Only valid at ad level.",
                                          "type": "string",
                                          "enum": [
                                            "relaunch"
                                          ]
                                        },
                                        "params": {
                                          "$comment": "json-value",
                                          "description": "Arbitrary JSON value with nested arrays and objects."
                                        }
                                      }
                                    },
                                    {
                                      "additionalProperties": false,
                                      "type": "object",
                                      "required": [
                                        "type"
                                      ],
                                      "properties": {
                                        "type": {
                                          "description": "Send a notification but do not mutate anything on Meta.",
                                          "type": "string",
                                          "enum": [
                                            "notify_only"
                                          ]
                                        },
                                        "params": {
                                          "$comment": "json-value",
                                          "description": "Arbitrary JSON value with nested arrays and objects."
                                        }
                                      }
                                    },
                                    {
                                      "additionalProperties": false,
                                      "type": "object",
                                      "required": [
                                        "type",
                                        "platform",
                                        "entity_level"
                                      ],
                                      "properties": {
                                        "type": {
                                          "type": "string",
                                          "enum": [
                                            "PAUSE_TOP_SPEND_CAMPAIGN"
                                          ]
                                        },
                                        "platform": {
                                          "anyOf": [
                                            {
                                              "type": "string",
                                              "enum": [
                                                "META"
                                              ]
                                            },
                                            {
                                              "type": "string",
                                              "enum": [
                                                "GOOGLE"
                                              ]
                                            },
                                            {
                                              "type": "string",
                                              "enum": [
                                                "TIKTOK"
                                              ]
                                            },
                                            {
                                              "type": "string",
                                              "enum": [
                                                "TABOOLA"
                                              ]
                                            },
                                            {
                                              "type": "string",
                                              "enum": [
                                                "LINKEDIN"
                                              ]
                                            }
                                          ]
                                        },
                                        "entity_level": {
                                          "type": "string",
                                          "enum": [
                                            "campaign"
                                          ]
                                        }
                                      }
                                    },
                                    {
                                      "additionalProperties": false,
                                      "type": "object",
                                      "required": [
                                        "type",
                                        "platform",
                                        "entity_level",
                                        "pct"
                                      ],
                                      "properties": {
                                        "type": {
                                          "anyOf": [
                                            {
                                              "type": "string",
                                              "enum": [
                                                "INCREASE_BUDGET_PCT"
                                              ]
                                            },
                                            {
                                              "type": "string",
                                              "enum": [
                                                "DECREASE_BUDGET_PCT"
                                              ]
                                            }
                                          ]
                                        },
                                        "platform": {
                                          "anyOf": [
                                            {
                                              "type": "string",
                                              "enum": [
                                                "META"
                                              ]
                                            },
                                            {
                                              "type": "string",
                                              "enum": [
                                                "GOOGLE"
                                              ]
                                            },
                                            {
                                              "type": "string",
                                              "enum": [
                                                "TIKTOK"
                                              ]
                                            },
                                            {
                                              "type": "string",
                                              "enum": [
                                                "TABOOLA"
                                              ]
                                            },
                                            {
                                              "type": "string",
                                              "enum": [
                                                "LINKEDIN"
                                              ]
                                            }
                                          ]
                                        },
                                        "entity_level": {
                                          "type": "string",
                                          "enum": [
                                            "campaign"
                                          ]
                                        },
                                        "pct": {
                                          "minimum": 1,
                                          "maximum": 100,
                                          "type": "number"
                                        }
                                      }
                                    },
                                    {
                                      "additionalProperties": false,
                                      "type": "object",
                                      "required": [
                                        "type",
                                        "channel",
                                        "message_template"
                                      ],
                                      "properties": {
                                        "type": {
                                          "type": "string",
                                          "enum": [
                                            "NOTIFY_CHANNEL"
                                          ]
                                        },
                                        "channel": {
                                          "anyOf": [
                                            {
                                              "type": "string",
                                              "enum": [
                                                "in_app"
                                              ]
                                            },
                                            {
                                              "type": "string",
                                              "enum": [
                                                "email"
                                              ]
                                            },
                                            {
                                              "type": "string",
                                              "enum": [
                                                "telegram"
                                              ]
                                            }
                                          ]
                                        },
                                        "message_template": {
                                          "minLength": 1,
                                          "maxLength": 500,
                                          "type": "string"
                                        }
                                      }
                                    }
                                  ]
                                },
                                {
                                  "additionalProperties": true,
                                  "description": "Rule action stored before the current schema; surfaced as-is so the list stays readable.",
                                  "type": "object",
                                  "required": [
                                    "type"
                                  ],
                                  "properties": {
                                    "type": {
                                      "description": "Action discriminator as stored, including legacy spellings.",
                                      "type": "string"
                                    },
                                    "params": {
                                      "$comment": "json-value",
                                      "description": "Arbitrary JSON value with nested arrays and objects."
                                    }
                                  }
                                }
                              ]
                            }
                          },
                          "schedule_type": {
                            "anyOf": [
                              {
                                "type": "string",
                                "enum": [
                                  "interval"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "daily"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "daily_at_time"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "day_parting"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "custom"
                                ]
                              }
                            ]
                          },
                          "interval_minutes": {
                            "type": "integer"
                          },
                          "cooldown_minutes": {
                            "type": "integer"
                          },
                          "parameters": {
                            "description": "Configurable template parameters used to hydrate condition and action placeholders.",
                            "type": "array",
                            "items": {
                              "additionalProperties": false,
                              "description": "Configurable parameter exposed by a predefined automation rule template.",
                              "type": "object",
                              "required": [
                                "key",
                                "type"
                              ],
                              "properties": {
                                "key": {
                                  "description": "Placeholder key used in template conditions/actions, without surrounding braces.",
                                  "minLength": 1,
                                  "maxLength": 100,
                                  "type": "string"
                                },
                                "label": {
                                  "minLength": 1,
                                  "maxLength": 200,
                                  "type": "string"
                                },
                                "label_it": {
                                  "minLength": 1,
                                  "maxLength": 200,
                                  "type": "string"
                                },
                                "label_en": {
                                  "minLength": 1,
                                  "maxLength": 200,
                                  "type": "string"
                                },
                                "type": {
                                  "description": "Input control type used by the rule builder, for example number, boolean, or text.",
                                  "minLength": 1,
                                  "maxLength": 50,
                                  "type": "string"
                                },
                                "default": {
                                  "description": "Default value used by the rule builder when hydrating template placeholders.",
                                  "anyOf": [
                                    {
                                      "type": "string"
                                    },
                                    {
                                      "type": "number"
                                    },
                                    {
                                      "type": "boolean"
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "required": {
                                  "type": "boolean"
                                },
                                "min": {
                                  "type": "number"
                                },
                                "max": {
                                  "type": "number"
                                },
                                "step": {
                                  "type": "number"
                                },
                                "options": {
                                  "type": "array",
                                  "items": {
                                    "additionalProperties": false,
                                    "type": "object",
                                    "required": [
                                      "value"
                                    ],
                                    "properties": {
                                      "label": {
                                        "minLength": 1,
                                        "maxLength": 200,
                                        "type": "string"
                                      },
                                      "label_it": {
                                        "minLength": 1,
                                        "maxLength": 200,
                                        "type": "string"
                                      },
                                      "label_en": {
                                        "minLength": 1,
                                        "maxLength": 200,
                                        "type": "string"
                                      },
                                      "value": {
                                        "anyOf": [
                                          {
                                            "type": "string"
                                          },
                                          {
                                            "type": "number"
                                          },
                                          {
                                            "type": "boolean"
                                          }
                                        ]
                                      }
                                    }
                                  }
                                }
                              },
                              "title": "RuleTemplateParameter"
                            }
                          },
                          "popularity": {
                            "type": "integer"
                          },
                          "is_active": {
                            "type": "boolean"
                          },
                          "platforms": {
                            "type": "array",
                            "items": {
                              "minLength": 1,
                              "maxLength": 40,
                              "type": "string"
                            }
                          },
                          "created_at": {
                            "format": "date-time",
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "integer"
                    },
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "details": {
                      "type": "array",
                      "items": {
                        "additionalProperties": false,
                        "type": "object",
                        "required": [
                          "code",
                          "field",
                          "message"
                        ],
                        "properties": {
                          "code": {
                            "type": "string"
                          },
                          "field": {
                            "type": "string"
                          },
                          "message": {
                            "type": "string"
                          }
                        }
                      }
                    },
                    "validation": {
                      "type": "array",
                      "items": {
                        "additionalProperties": true,
                        "description": "AJV validation error item returned by Fastify for invalid params, querystrings, or bodies.",
                        "type": "object",
                        "properties": {
                          "instancePath": {
                            "type": "string"
                          },
                          "schemaPath": {
                            "type": "string"
                          },
                          "keyword": {
                            "type": "string"
                          },
                          "params": {
                            "type": "object",
                            "additionalProperties": {
                              "$comment": "json-value",
                              "description": "Arbitrary JSON value with nested arrays and objects."
                            }
                          },
                          "message": {
                            "type": "string"
                          }
                        }
                      }
                    },
                    "validationContext": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "integer"
                    },
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/rules/available-kpis": {
      "get": {
        "operationId": "listRuleAvailableKpis",
        "summary": "List available KPIs for rule conditions",
        "tags": [
          "rules"
        ],
        "description": "Returns platform metrics (spend, roas, etc.) and action-type KPIs from action_types_canonical where available_in_rules = TRUE. When `?platform` is `google`/`tiktok`/`taboola`, the response is narrowed to universal metrics only and action-type KPIs are omitted (those are Meta-specific by design - `meta_action_type` keyed off the Meta Marketing API).",
        "parameters": [
          {
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "enum": [
                    "meta"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "google"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "tiktok"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "taboola"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "snapchat"
                  ]
                }
              ]
            },
            "in": "query",
            "name": "platform",
            "required": false,
            "description": "Filter KPIs to those supported by the platform. Defaults to `meta` for backwards compatibility with existing rule builder calls."
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "platform_metrics",
                    "action_type_kpis"
                  ],
                  "properties": {
                    "platform_metrics": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "action_type_kpis": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "key",
                          "label_en",
                          "label_it",
                          "api_version"
                        ],
                        "properties": {
                          "key": {
                            "type": "string"
                          },
                          "label_en": {
                            "type": "string"
                          },
                          "label_it": {
                            "type": "string"
                          },
                          "api_version": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "integer"
                    },
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "details": {
                      "type": "array",
                      "items": {
                        "additionalProperties": false,
                        "type": "object",
                        "required": [
                          "code",
                          "field",
                          "message"
                        ],
                        "properties": {
                          "code": {
                            "type": "string"
                          },
                          "field": {
                            "type": "string"
                          },
                          "message": {
                            "type": "string"
                          }
                        }
                      }
                    },
                    "validation": {
                      "type": "array",
                      "items": {
                        "additionalProperties": true,
                        "description": "AJV validation error item returned by Fastify for invalid params, querystrings, or bodies.",
                        "type": "object",
                        "properties": {
                          "instancePath": {
                            "type": "string"
                          },
                          "schemaPath": {
                            "type": "string"
                          },
                          "keyword": {
                            "type": "string"
                          },
                          "params": {
                            "type": "object",
                            "additionalProperties": {
                              "$comment": "json-value",
                              "description": "Arbitrary JSON value with nested arrays and objects."
                            }
                          },
                          "message": {
                            "type": "string"
                          }
                        }
                      }
                    },
                    "validationContext": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "integer"
                    },
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/rules/stats": {
      "get": {
        "operationId": "getAutomationRulesStats",
        "summary": "Get automation rules stats",
        "tags": [
          "rules"
        ],
        "description": "Returns aggregate statistics for automation rules including total, active, executions today, actions today, and errors today.",
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "total_rules",
                    "active_rules",
                    "executions_today",
                    "actions_today",
                    "errors_today"
                  ],
                  "properties": {
                    "total_rules": {
                      "type": "integer"
                    },
                    "active_rules": {
                      "type": "integer"
                    },
                    "executions_today": {
                      "type": "integer"
                    },
                    "actions_today": {
                      "type": "integer"
                    },
                    "errors_today": {
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "integer"
                    },
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/rules/{id}": {
      "get": {
        "operationId": "getAutomationRule",
        "summary": "Get automation rule detail",
        "tags": [
          "rules"
        ],
        "description": "Returns the full detail of a single automation rule by ID, including execution count and creator info.",
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "allOf": [
                    {
                      "additionalProperties": true,
                      "description": "Automation rule row as persisted in the automation_rule table.",
                      "type": "object",
                      "required": [
                        "id",
                        "user_id",
                        "name",
                        "description",
                        "status",
                        "entity_level",
                        "ad_account_ids",
                        "entity_filter",
                        "condition_logic",
                        "conditions",
                        "actions",
                        "schedule_type",
                        "interval_minutes",
                        "schedule_config",
                        "timezone",
                        "cooldown_minutes",
                        "max_executions_per_day",
                        "budget_change_limit_pct",
                        "budget_daily_cap",
                        "notify_on_execution",
                        "notify_channels",
                        "platforms",
                        "priority",
                        "template_id",
                        "last_evaluated_at",
                        "last_executed_at",
                        "execution_count",
                        "error_count",
                        "last_error",
                        "auto_paused_at",
                        "auto_pause_reason",
                        "created_at",
                        "updated_at"
                      ],
                      "properties": {
                        "id": {
                          "format": "uuid",
                          "type": "string"
                        },
                        "user_id": {
                          "anyOf": [
                            {
                              "format": "uuid",
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "created_by": {
                          "anyOf": [
                            {
                              "format": "uuid",
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "name": {
                          "type": "string"
                        },
                        "description": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "status": {
                          "anyOf": [
                            {
                              "type": "string",
                              "enum": [
                                "active"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "paused"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "error"
                              ]
                            }
                          ]
                        },
                        "entity_level": {
                          "anyOf": [
                            {
                              "type": "string",
                              "enum": [
                                "campaign"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "adset"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "ad"
                              ]
                            }
                          ]
                        },
                        "ad_account_ids": {
                          "type": "array",
                          "items": {
                            "type": "string"
                          }
                        },
                        "entity_filter": {
                          "description": "Entity filter as stored, tolerant of filters written outside the strict request contract.",
                          "anyOf": [
                            {
                              "additionalProperties": false,
                              "description": "Optional entity filters applied before condition evaluation.",
                              "type": "object",
                              "properties": {
                                "name_contains": {
                                  "description": "Case-insensitive substring that must be present in the entity name.",
                                  "minLength": 1,
                                  "maxLength": 200,
                                  "type": "string"
                                },
                                "name_not_contains": {
                                  "description": "Case-insensitive substring that must not be present in the entity name.",
                                  "minLength": 1,
                                  "maxLength": 200,
                                  "type": "string"
                                },
                                "status_in": {
                                  "description": "Entity statuses to include. Route validation checks whether each status is allowed for the selected entity level.",
                                  "minItems": 1,
                                  "maxItems": 20,
                                  "type": "array",
                                  "items": {
                                    "minLength": 1,
                                    "maxLength": 80,
                                    "type": "string"
                                  }
                                },
                                "account_mode": {
                                  "description": "Ad-account scope intent. \"selected\" means the rule must be restricted to ad_account_ids; combined with an empty ad_account_ids the evaluator matches no entities (it does NOT silently fall back to all accounts). \"all\" (or omitted) evaluates every accessible account.",
                                  "anyOf": [
                                    {
                                      "type": "string",
                                      "enum": [
                                        "all"
                                      ]
                                    },
                                    {
                                      "type": "string",
                                      "enum": [
                                        "selected"
                                      ]
                                    }
                                  ]
                                }
                              }
                            },
                            {
                              "additionalProperties": true,
                              "description": "Entity filter stored before/around the current contract; surfaced as-is so the list stays readable.",
                              "type": "object",
                              "properties": {
                                "name_contains": {
                                  "description": "Name filter as stored; may be empty (\"no filter\").",
                                  "type": "string"
                                },
                                "name_not_contains": {
                                  "description": "Negative name filter as stored; may be empty (\"no filter\").",
                                  "type": "string"
                                },
                                "status_in": {
                                  "description": "Statuses as stored; may be empty (\"no filter\").",
                                  "type": "array",
                                  "items": {
                                    "type": "string"
                                  }
                                },
                                "account_mode": {
                                  "description": "Ad-account scope intent as stored.",
                                  "type": "string"
                                }
                              }
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "condition_logic": {
                          "anyOf": [
                            {
                              "type": "string",
                              "enum": [
                                "AND"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "OR"
                              ]
                            }
                          ]
                        },
                        "conditions": {
                          "description": "Ordered list of conditions as stored, tolerant of rules written outside the request contract.",
                          "type": "array",
                          "items": {
                            "anyOf": [
                              {
                                "additionalProperties": false,
                                "description": "Single metric threshold evaluated against entity insights.",
                                "type": "object",
                                "required": [
                                  "metric",
                                  "operator",
                                  "time_range",
                                  "value"
                                ],
                                "properties": {
                                  "metric": {
                                    "description": "Metric key (platform metric, derived metric, or action-type KPI from action_types_canonical).",
                                    "minLength": 1,
                                    "type": "string"
                                  },
                                  "operator": {
                                    "description": "Comparison operator. `between`/`not_between` require both `value` and `value2`; `increased_pct`/`decreased_pct` compare the current `time_range` against the immediately preceding period of equal duration.",
                                    "anyOf": [
                                      {
                                        "type": "string",
                                        "enum": [
                                          "gt"
                                        ]
                                      },
                                      {
                                        "type": "string",
                                        "enum": [
                                          "lt"
                                        ]
                                      },
                                      {
                                        "type": "string",
                                        "enum": [
                                          "gte"
                                        ]
                                      },
                                      {
                                        "type": "string",
                                        "enum": [
                                          "lte"
                                        ]
                                      },
                                      {
                                        "type": "string",
                                        "enum": [
                                          "eq"
                                        ]
                                      },
                                      {
                                        "type": "string",
                                        "enum": [
                                          "neq"
                                        ]
                                      },
                                      {
                                        "type": "string",
                                        "enum": [
                                          "between"
                                        ]
                                      },
                                      {
                                        "type": "string",
                                        "enum": [
                                          "not_between"
                                        ]
                                      },
                                      {
                                        "type": "string",
                                        "enum": [
                                          "increased_pct"
                                        ]
                                      },
                                      {
                                        "type": "string",
                                        "enum": [
                                          "decreased_pct"
                                        ]
                                      }
                                    ]
                                  },
                                  "time_range": {
                                    "description": "Time window over which the metric is aggregated.",
                                    "anyOf": [
                                      {
                                        "type": "string",
                                        "enum": [
                                          "today"
                                        ]
                                      },
                                      {
                                        "type": "string",
                                        "enum": [
                                          "yesterday"
                                        ]
                                      },
                                      {
                                        "type": "string",
                                        "enum": [
                                          "last_3d"
                                        ]
                                      },
                                      {
                                        "type": "string",
                                        "enum": [
                                          "last_7d"
                                        ]
                                      },
                                      {
                                        "type": "string",
                                        "enum": [
                                          "last_14d"
                                        ]
                                      },
                                      {
                                        "type": "string",
                                        "enum": [
                                          "last_30d"
                                        ]
                                      }
                                    ]
                                  },
                                  "value": {
                                    "description": "Primary threshold. Coerced to Number at evaluation time.",
                                    "anyOf": [
                                      {
                                        "type": "number"
                                      },
                                      {
                                        "type": "string"
                                      }
                                    ]
                                  },
                                  "value2": {
                                    "description": "Secondary threshold (required for `between` / `not_between`).",
                                    "anyOf": [
                                      {
                                        "type": "number"
                                      },
                                      {
                                        "type": "string"
                                      }
                                    ]
                                  },
                                  "trend_window": {
                                    "description": "Time window over which the metric is aggregated.",
                                    "anyOf": [
                                      {
                                        "type": "string",
                                        "enum": [
                                          "today"
                                        ]
                                      },
                                      {
                                        "type": "string",
                                        "enum": [
                                          "yesterday"
                                        ]
                                      },
                                      {
                                        "type": "string",
                                        "enum": [
                                          "last_3d"
                                        ]
                                      },
                                      {
                                        "type": "string",
                                        "enum": [
                                          "last_7d"
                                        ]
                                      },
                                      {
                                        "type": "string",
                                        "enum": [
                                          "last_14d"
                                        ]
                                      },
                                      {
                                        "type": "string",
                                        "enum": [
                                          "last_30d"
                                        ]
                                      }
                                    ]
                                  }
                                }
                              },
                              {
                                "additionalProperties": false,
                                "description": "Account-level comparison across two advertising platforms, or between one platform and a literal.",
                                "type": "object",
                                "required": [
                                  "type",
                                  "left",
                                  "operator",
                                  "right"
                                ],
                                "properties": {
                                  "type": {
                                    "type": "string",
                                    "enum": [
                                      "cross_platform_comparison"
                                    ]
                                  },
                                  "left": {
                                    "anyOf": [
                                      {
                                        "additionalProperties": false,
                                        "type": "object",
                                        "required": [
                                          "type",
                                          "platform",
                                          "metric"
                                        ],
                                        "properties": {
                                          "type": {
                                            "type": "string",
                                            "enum": [
                                              "platform_metric"
                                            ]
                                          },
                                          "platform": {
                                            "anyOf": [
                                              {
                                                "type": "string",
                                                "enum": [
                                                  "META"
                                                ]
                                              },
                                              {
                                                "type": "string",
                                                "enum": [
                                                  "GOOGLE"
                                                ]
                                              },
                                              {
                                                "type": "string",
                                                "enum": [
                                                  "TIKTOK"
                                                ]
                                              },
                                              {
                                                "type": "string",
                                                "enum": [
                                                  "TABOOLA"
                                                ]
                                              },
                                              {
                                                "type": "string",
                                                "enum": [
                                                  "LINKEDIN"
                                                ]
                                              }
                                            ]
                                          },
                                          "metric": {
                                            "anyOf": [
                                              {
                                                "type": "string",
                                                "enum": [
                                                  "spend"
                                                ]
                                              },
                                              {
                                                "type": "string",
                                                "enum": [
                                                  "spend_pct"
                                                ]
                                              },
                                              {
                                                "type": "string",
                                                "enum": [
                                                  "impressions"
                                                ]
                                              },
                                              {
                                                "type": "string",
                                                "enum": [
                                                  "clicks"
                                                ]
                                              },
                                              {
                                                "type": "string",
                                                "enum": [
                                                  "ctr"
                                                ]
                                              },
                                              {
                                                "type": "string",
                                                "enum": [
                                                  "cpc"
                                                ]
                                              },
                                              {
                                                "type": "string",
                                                "enum": [
                                                  "cpm"
                                                ]
                                              },
                                              {
                                                "type": "string",
                                                "enum": [
                                                  "purchases"
                                                ]
                                              },
                                              {
                                                "type": "string",
                                                "enum": [
                                                  "purchase_value"
                                                ]
                                              },
                                              {
                                                "type": "string",
                                                "enum": [
                                                  "conversions"
                                                ]
                                              },
                                              {
                                                "type": "string",
                                                "enum": [
                                                  "roas"
                                                ]
                                              },
                                              {
                                                "type": "string",
                                                "enum": [
                                                  "cpa"
                                                ]
                                              },
                                              {
                                                "type": "string",
                                                "enum": [
                                                  "cpl"
                                                ]
                                              }
                                            ]
                                          },
                                          "level": {
                                            "type": "string",
                                            "enum": [
                                              "account"
                                            ]
                                          },
                                          "timeframe_days": {
                                            "minimum": 1,
                                            "maximum": 90,
                                            "type": "integer"
                                          },
                                          "multiplier": {
                                            "minimum": 0,
                                            "type": "number"
                                          }
                                        }
                                      },
                                      {
                                        "additionalProperties": false,
                                        "type": "object",
                                        "required": [
                                          "type",
                                          "value"
                                        ],
                                        "properties": {
                                          "type": {
                                            "type": "string",
                                            "enum": [
                                              "literal"
                                            ]
                                          },
                                          "value": {
                                            "type": "number"
                                          }
                                        }
                                      }
                                    ]
                                  },
                                  "operator": {
                                    "anyOf": [
                                      {
                                        "type": "string",
                                        "enum": [
                                          "greater_than"
                                        ]
                                      },
                                      {
                                        "type": "string",
                                        "enum": [
                                          "less_than"
                                        ]
                                      },
                                      {
                                        "type": "string",
                                        "enum": [
                                          "greater_or_equal"
                                        ]
                                      },
                                      {
                                        "type": "string",
                                        "enum": [
                                          "less_or_equal"
                                        ]
                                      },
                                      {
                                        "type": "string",
                                        "enum": [
                                          "equal"
                                        ]
                                      }
                                    ]
                                  },
                                  "right": {
                                    "anyOf": [
                                      {
                                        "additionalProperties": false,
                                        "type": "object",
                                        "required": [
                                          "type",
                                          "platform",
                                          "metric"
                                        ],
                                        "properties": {
                                          "type": {
                                            "type": "string",
                                            "enum": [
                                              "platform_metric"
                                            ]
                                          },
                                          "platform": {
                                            "anyOf": [
                                              {
                                                "type": "string",
                                                "enum": [
                                                  "META"
                                                ]
                                              },
                                              {
                                                "type": "string",
                                                "enum": [
                                                  "GOOGLE"
                                                ]
                                              },
                                              {
                                                "type": "string",
                                                "enum": [
                                                  "TIKTOK"
                                                ]
                                              },
                                              {
                                                "type": "string",
                                                "enum": [
                                                  "TABOOLA"
                                                ]
                                              },
                                              {
                                                "type": "string",
                                                "enum": [
                                                  "LINKEDIN"
                                                ]
                                              }
                                            ]
                                          },
                                          "metric": {
                                            "anyOf": [
                                              {
                                                "type": "string",
                                                "enum": [
                                                  "spend"
                                                ]
                                              },
                                              {
                                                "type": "string",
                                                "enum": [
                                                  "spend_pct"
                                                ]
                                              },
                                              {
                                                "type": "string",
                                                "enum": [
                                                  "impressions"
                                                ]
                                              },
                                              {
                                                "type": "string",
                                                "enum": [
                                                  "clicks"
                                                ]
                                              },
                                              {
                                                "type": "string",
                                                "enum": [
                                                  "ctr"
                                                ]
                                              },
                                              {
                                                "type": "string",
                                                "enum": [
                                                  "cpc"
                                                ]
                                              },
                                              {
                                                "type": "string",
                                                "enum": [
                                                  "cpm"
                                                ]
                                              },
                                              {
                                                "type": "string",
                                                "enum": [
                                                  "purchases"
                                                ]
                                              },
                                              {
                                                "type": "string",
                                                "enum": [
                                                  "purchase_value"
                                                ]
                                              },
                                              {
                                                "type": "string",
                                                "enum": [
                                                  "conversions"
                                                ]
                                              },
                                              {
                                                "type": "string",
                                                "enum": [
                                                  "roas"
                                                ]
                                              },
                                              {
                                                "type": "string",
                                                "enum": [
                                                  "cpa"
                                                ]
                                              },
                                              {
                                                "type": "string",
                                                "enum": [
                                                  "cpl"
                                                ]
                                              }
                                            ]
                                          },
                                          "level": {
                                            "type": "string",
                                            "enum": [
                                              "account"
                                            ]
                                          },
                                          "timeframe_days": {
                                            "minimum": 1,
                                            "maximum": 90,
                                            "type": "integer"
                                          },
                                          "multiplier": {
                                            "minimum": 0,
                                            "type": "number"
                                          }
                                        }
                                      },
                                      {
                                        "additionalProperties": false,
                                        "type": "object",
                                        "required": [
                                          "type",
                                          "value"
                                        ],
                                        "properties": {
                                          "type": {
                                            "type": "string",
                                            "enum": [
                                              "literal"
                                            ]
                                          },
                                          "value": {
                                            "type": "number"
                                          }
                                        }
                                      }
                                    ]
                                  }
                                }
                              },
                              {
                                "additionalProperties": true,
                                "description": "Rule condition stored without the full current contract; surfaced as-is so the list stays readable.",
                                "type": "object",
                                "properties": {
                                  "metric": {
                                    "description": "Metric key as stored.",
                                    "type": "string"
                                  },
                                  "operator": {
                                    "description": "Comparison operator as stored.",
                                    "type": "string"
                                  },
                                  "time_range": {
                                    "description": "Time window as stored; absent means the evaluator default (`today`).",
                                    "type": "string"
                                  }
                                }
                              }
                            ]
                          }
                        },
                        "actions": {
                          "description": "Ordered list of actions as stored, tolerant of rules written before the current schema.",
                          "type": "array",
                          "items": {
                            "anyOf": [
                              {
                                "description": "Automation rule action. Discriminated on `type`. See RuleActionType in src/sqs/types/messages.ts.",
                                "anyOf": [
                                  {
                                    "additionalProperties": false,
                                    "type": "object",
                                    "required": [
                                      "type"
                                    ],
                                    "properties": {
                                      "type": {
                                        "description": "Pause the matched entity (campaign/adset/ad).",
                                        "type": "string",
                                        "enum": [
                                          "pause"
                                        ]
                                      },
                                      "params": {
                                        "$comment": "json-value",
                                        "description": "Arbitrary JSON value with nested arrays and objects."
                                      }
                                    }
                                  },
                                  {
                                    "additionalProperties": false,
                                    "type": "object",
                                    "required": [
                                      "type"
                                    ],
                                    "properties": {
                                      "type": {
                                        "description": "Activate the matched entity (campaign/adset/ad).",
                                        "type": "string",
                                        "enum": [
                                          "activate"
                                        ]
                                      },
                                      "params": {
                                        "$comment": "json-value",
                                        "description": "Arbitrary JSON value with nested arrays and objects."
                                      }
                                    }
                                  },
                                  {
                                    "additionalProperties": false,
                                    "type": "object",
                                    "required": [
                                      "type"
                                    ],
                                    "properties": {
                                      "type": {
                                        "description": "Increase campaign/adset budget by `params.percentage` percent.",
                                        "type": "string",
                                        "enum": [
                                          "increase_budget_pct"
                                        ]
                                      },
                                      "params": {
                                        "additionalProperties": false,
                                        "type": "object",
                                        "properties": {
                                          "percentage": {
                                            "description": "Percent increase in [1, 1000] (defaults to 20 if omitted at runtime). 0 is rejected because a 0% change is a no-op and the worker clamps it to 1 anyway — the schema makes that contract explicit. The ceiling is deliberately far above 100: doubling or tripling a budget is ordinary media buying, and the old 100 cap (borrowed from the decrease action, where >100% is meaningless) made the rules list unserializable for anyone who had scaled a budget by more.",
                                            "minimum": 1,
                                            "maximum": 1000,
                                            "type": "number"
                                          },
                                          "pct": {
                                            "description": "Legacy template alias for `percentage`; accepted for seeded rule templates.",
                                            "minimum": 1,
                                            "maximum": 1000,
                                            "type": "number"
                                          }
                                        }
                                      }
                                    }
                                  },
                                  {
                                    "additionalProperties": false,
                                    "type": "object",
                                    "required": [
                                      "type"
                                    ],
                                    "properties": {
                                      "type": {
                                        "description": "Decrease campaign/adset budget by `params.percentage` percent.",
                                        "type": "string",
                                        "enum": [
                                          "decrease_budget_pct"
                                        ]
                                      },
                                      "params": {
                                        "additionalProperties": false,
                                        "type": "object",
                                        "properties": {
                                          "percentage": {
                                            "description": "Percent change in [1, 100] (defaults to 20 if omitted at runtime). 0 is rejected because a 0% change is a no-op and the worker clamps it to 1 anyway — the schema makes that contract explicit.",
                                            "minimum": 1,
                                            "maximum": 100,
                                            "type": "number"
                                          },
                                          "pct": {
                                            "description": "Legacy template alias for `percentage`; accepted for seeded rule templates.",
                                            "minimum": 1,
                                            "maximum": 100,
                                            "type": "number"
                                          }
                                        }
                                      }
                                    }
                                  },
                                  {
                                    "additionalProperties": false,
                                    "type": "object",
                                    "required": [
                                      "type"
                                    ],
                                    "properties": {
                                      "type": {
                                        "description": "Relaunch the ad (duplicate + delete original). Only valid at ad level.",
                                        "type": "string",
                                        "enum": [
                                          "relaunch"
                                        ]
                                      },
                                      "params": {
                                        "$comment": "json-value",
                                        "description": "Arbitrary JSON value with nested arrays and objects."
                                      }
                                    }
                                  },
                                  {
                                    "additionalProperties": false,
                                    "type": "object",
                                    "required": [
                                      "type"
                                    ],
                                    "properties": {
                                      "type": {
                                        "description": "Send a notification but do not mutate anything on Meta.",
                                        "type": "string",
                                        "enum": [
                                          "notify_only"
                                        ]
                                      },
                                      "params": {
                                        "$comment": "json-value",
                                        "description": "Arbitrary JSON value with nested arrays and objects."
                                      }
                                    }
                                  },
                                  {
                                    "additionalProperties": false,
                                    "type": "object",
                                    "required": [
                                      "type",
                                      "platform",
                                      "entity_level"
                                    ],
                                    "properties": {
                                      "type": {
                                        "type": "string",
                                        "enum": [
                                          "PAUSE_TOP_SPEND_CAMPAIGN"
                                        ]
                                      },
                                      "platform": {
                                        "anyOf": [
                                          {
                                            "type": "string",
                                            "enum": [
                                              "META"
                                            ]
                                          },
                                          {
                                            "type": "string",
                                            "enum": [
                                              "GOOGLE"
                                            ]
                                          },
                                          {
                                            "type": "string",
                                            "enum": [
                                              "TIKTOK"
                                            ]
                                          },
                                          {
                                            "type": "string",
                                            "enum": [
                                              "TABOOLA"
                                            ]
                                          },
                                          {
                                            "type": "string",
                                            "enum": [
                                              "LINKEDIN"
                                            ]
                                          }
                                        ]
                                      },
                                      "entity_level": {
                                        "type": "string",
                                        "enum": [
                                          "campaign"
                                        ]
                                      }
                                    }
                                  },
                                  {
                                    "additionalProperties": false,
                                    "type": "object",
                                    "required": [
                                      "type",
                                      "platform",
                                      "entity_level",
                                      "pct"
                                    ],
                                    "properties": {
                                      "type": {
                                        "anyOf": [
                                          {
                                            "type": "string",
                                            "enum": [
                                              "INCREASE_BUDGET_PCT"
                                            ]
                                          },
                                          {
                                            "type": "string",
                                            "enum": [
                                              "DECREASE_BUDGET_PCT"
                                            ]
                                          }
                                        ]
                                      },
                                      "platform": {
                                        "anyOf": [
                                          {
                                            "type": "string",
                                            "enum": [
                                              "META"
                                            ]
                                          },
                                          {
                                            "type": "string",
                                            "enum": [
                                              "GOOGLE"
                                            ]
                                          },
                                          {
                                            "type": "string",
                                            "enum": [
                                              "TIKTOK"
                                            ]
                                          },
                                          {
                                            "type": "string",
                                            "enum": [
                                              "TABOOLA"
                                            ]
                                          },
                                          {
                                            "type": "string",
                                            "enum": [
                                              "LINKEDIN"
                                            ]
                                          }
                                        ]
                                      },
                                      "entity_level": {
                                        "type": "string",
                                        "enum": [
                                          "campaign"
                                        ]
                                      },
                                      "pct": {
                                        "minimum": 1,
                                        "maximum": 100,
                                        "type": "number"
                                      }
                                    }
                                  },
                                  {
                                    "additionalProperties": false,
                                    "type": "object",
                                    "required": [
                                      "type",
                                      "channel",
                                      "message_template"
                                    ],
                                    "properties": {
                                      "type": {
                                        "type": "string",
                                        "enum": [
                                          "NOTIFY_CHANNEL"
                                        ]
                                      },
                                      "channel": {
                                        "anyOf": [
                                          {
                                            "type": "string",
                                            "enum": [
                                              "in_app"
                                            ]
                                          },
                                          {
                                            "type": "string",
                                            "enum": [
                                              "email"
                                            ]
                                          },
                                          {
                                            "type": "string",
                                            "enum": [
                                              "telegram"
                                            ]
                                          }
                                        ]
                                      },
                                      "message_template": {
                                        "minLength": 1,
                                        "maxLength": 500,
                                        "type": "string"
                                      }
                                    }
                                  }
                                ]
                              },
                              {
                                "additionalProperties": true,
                                "description": "Rule action stored before the current schema; surfaced as-is so the list stays readable.",
                                "type": "object",
                                "required": [
                                  "type"
                                ],
                                "properties": {
                                  "type": {
                                    "description": "Action discriminator as stored, including legacy spellings.",
                                    "type": "string"
                                  },
                                  "params": {
                                    "$comment": "json-value",
                                    "description": "Arbitrary JSON value with nested arrays and objects."
                                  }
                                }
                              }
                            ]
                          }
                        },
                        "schedule_type": {
                          "anyOf": [
                            {
                              "type": "string",
                              "enum": [
                                "interval"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "daily"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "daily_at_time"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "day_parting"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "custom"
                              ]
                            }
                          ]
                        },
                        "interval_minutes": {
                          "type": "integer"
                        },
                        "schedule_config": {
                          "description": "Schedule config as stored, tolerant of values written outside the strict request contract.",
                          "anyOf": [
                            {
                              "additionalProperties": false,
                              "description": "Optional schedule-specific rule configuration. `daily_at_time` uses `time`; `day_parting` uses `hours_of_day`/`days_of_week` and/or explicit `slots`.",
                              "type": "object",
                              "properties": {
                                "time": {
                                  "description": "Daily evaluation time in HH:MM format. Runtime validation enforces 00:00-23:59.",
                                  "type": "string"
                                },
                                "type": {
                                  "type": "string",
                                  "enum": [
                                    "day_parting"
                                  ]
                                },
                                "hours_of_day": {
                                  "description": "Hours of day eligible for evaluation. Runtime validation enforces non-empty integers 0-23.",
                                  "maxItems": 24,
                                  "type": "array",
                                  "items": {
                                    "type": "number"
                                  }
                                },
                                "days_of_week": {
                                  "description": "Days of week eligible for evaluation, where 0 is Sunday and 6 is Saturday.",
                                  "maxItems": 7,
                                  "type": "array",
                                  "items": {
                                    "type": "number"
                                  }
                                },
                                "slots": {
                                  "description": "Explicit day/hour evaluation slots. Runtime validation enforces non-empty valid slots.",
                                  "type": "array",
                                  "items": {
                                    "additionalProperties": false,
                                    "type": "object",
                                    "required": [
                                      "day",
                                      "hour"
                                    ],
                                    "properties": {
                                      "day": {
                                        "description": "Day of week, where 0 is Sunday and 6 is Saturday. Runtime validation enforces integer 0-6.",
                                        "type": "number"
                                      },
                                      "hour": {
                                        "description": "Hour of day in 24-hour format. Runtime validation enforces integer 0-23.",
                                        "type": "number"
                                      }
                                    }
                                  }
                                },
                                "timezone": {
                                  "minLength": 1,
                                  "maxLength": 100,
                                  "type": "string"
                                }
                              }
                            },
                            {
                              "additionalProperties": true,
                              "description": "Schedule config stored before/around the current contract; surfaced as-is.",
                              "type": "object",
                              "properties": {
                                "time": {
                                  "description": "Daily evaluation time as stored.",
                                  "type": "string"
                                },
                                "type": {
                                  "description": "Schedule discriminator as stored.",
                                  "type": "string"
                                },
                                "hours_of_day": {
                                  "description": "Hours as stored.",
                                  "type": "array",
                                  "items": {
                                    "type": "number"
                                  }
                                },
                                "days_of_week": {
                                  "description": "Days as stored.",
                                  "type": "array",
                                  "items": {
                                    "type": "number"
                                  }
                                },
                                "slots": {
                                  "description": "Day/hour slots as stored.",
                                  "type": "array",
                                  "items": {
                                    "additionalProperties": true,
                                    "type": "object",
                                    "properties": {
                                      "day": {
                                        "type": "number"
                                      },
                                      "hour": {
                                        "type": "number"
                                      }
                                    }
                                  }
                                },
                                "timezone": {
                                  "description": "Timezone as stored.",
                                  "type": "string"
                                }
                              }
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "timezone": {
                          "type": "string"
                        },
                        "cooldown_minutes": {
                          "type": "integer"
                        },
                        "max_executions_per_day": {
                          "type": "integer"
                        },
                        "budget_change_limit_pct": {
                          "anyOf": [
                            {
                              "type": "number"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "budget_daily_cap": {
                          "anyOf": [
                            {
                              "type": "number"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "notify_on_execution": {
                          "type": "boolean"
                        },
                        "notify_channels": {
                          "description": "Notify channels as stored, tolerant of values written outside the strict request contract.",
                          "anyOf": [
                            {
                              "additionalProperties": false,
                              "description": "Notification channels used when notify_on_execution is enabled.",
                              "type": "object",
                              "properties": {
                                "email": {
                                  "type": "boolean"
                                },
                                "in_app": {
                                  "type": "boolean"
                                },
                                "telegram": {
                                  "type": "boolean"
                                }
                              }
                            },
                            {
                              "additionalProperties": true,
                              "description": "Notify channels stored before/around the current contract; surfaced as-is.",
                              "type": "object",
                              "properties": {
                                "email": {
                                  "type": "boolean"
                                },
                                "in_app": {
                                  "type": "boolean"
                                },
                                "telegram": {
                                  "type": "boolean"
                                }
                              }
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "platforms": {
                          "type": "array",
                          "items": {
                            "minLength": 1,
                            "maxLength": 40,
                            "type": "string"
                          }
                        },
                        "priority": {
                          "type": "integer"
                        },
                        "template_id": {
                          "anyOf": [
                            {
                              "format": "uuid",
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "last_evaluated_at": {
                          "anyOf": [
                            {
                              "format": "date-time",
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "last_executed_at": {
                          "anyOf": [
                            {
                              "format": "date-time",
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "execution_count": {
                          "type": "integer"
                        },
                        "error_count": {
                          "type": "integer"
                        },
                        "last_error": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "auto_paused_at": {
                          "anyOf": [
                            {
                              "format": "date-time",
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "auto_pause_reason": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "cb_reset_after": {
                          "anyOf": [
                            {
                              "format": "date-time",
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "created_at": {
                          "format": "date-time",
                          "type": "string"
                        },
                        "updated_at": {
                          "format": "date-time",
                          "type": "string"
                        }
                      }
                    },
                    {
                      "type": "object",
                      "properties": {
                        "execution_total": {
                          "type": "integer"
                        },
                        "created_by_name": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "created_by_email": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "integer"
                    },
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "details": {
                      "type": "array",
                      "items": {
                        "additionalProperties": false,
                        "type": "object",
                        "required": [
                          "code",
                          "field",
                          "message"
                        ],
                        "properties": {
                          "code": {
                            "type": "string"
                          },
                          "field": {
                            "type": "string"
                          },
                          "message": {
                            "type": "string"
                          }
                        }
                      }
                    },
                    "validation": {
                      "type": "array",
                      "items": {
                        "additionalProperties": true,
                        "description": "AJV validation error item returned by Fastify for invalid params, querystrings, or bodies.",
                        "type": "object",
                        "properties": {
                          "instancePath": {
                            "type": "string"
                          },
                          "schemaPath": {
                            "type": "string"
                          },
                          "keyword": {
                            "type": "string"
                          },
                          "params": {
                            "type": "object",
                            "additionalProperties": {
                              "$comment": "json-value",
                              "description": "Arbitrary JSON value with nested arrays and objects."
                            }
                          },
                          "message": {
                            "type": "string"
                          }
                        }
                      }
                    },
                    "validationContext": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "integer"
                    },
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "integer"
                    },
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      },
      "put": {
        "operationId": "updateAutomationRule",
        "summary": "Update automation rule",
        "tags": [
          "rules"
        ],
        "description": "Updates an existing automation rule with the provided fields. Resets error state on update.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "properties": {
                  "name": {
                    "minLength": 1,
                    "type": "string"
                  },
                  "description": {
                    "anyOf": [
                      {
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "entity_level": {
                    "anyOf": [
                      {
                        "type": "string",
                        "enum": [
                          "campaign"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "adset"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "ad"
                        ]
                      }
                    ]
                  },
                  "ad_account_ids": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  },
                  "entity_filter": {
                    "anyOf": [
                      {
                        "additionalProperties": false,
                        "description": "Optional entity filters applied before condition evaluation.",
                        "type": "object",
                        "properties": {
                          "name_contains": {
                            "description": "Case-insensitive substring that must be present in the entity name.",
                            "minLength": 1,
                            "maxLength": 200,
                            "type": "string"
                          },
                          "name_not_contains": {
                            "description": "Case-insensitive substring that must not be present in the entity name.",
                            "minLength": 1,
                            "maxLength": 200,
                            "type": "string"
                          },
                          "status_in": {
                            "description": "Entity statuses to include. Route validation checks whether each status is allowed for the selected entity level.",
                            "minItems": 1,
                            "maxItems": 20,
                            "type": "array",
                            "items": {
                              "minLength": 1,
                              "maxLength": 80,
                              "type": "string"
                            }
                          },
                          "account_mode": {
                            "description": "Ad-account scope intent. \"selected\" means the rule must be restricted to ad_account_ids; combined with an empty ad_account_ids the evaluator matches no entities (it does NOT silently fall back to all accounts). \"all\" (or omitted) evaluates every accessible account.",
                            "anyOf": [
                              {
                                "type": "string",
                                "enum": [
                                  "all"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "selected"
                                ]
                              }
                            ]
                          }
                        }
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "condition_logic": {
                    "anyOf": [
                      {
                        "type": "string",
                        "enum": [
                          "AND"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "OR"
                        ]
                      }
                    ]
                  },
                  "conditions": {
                    "description": "Ordered list of conditions combined via `condition_logic` (AND/OR).",
                    "type": "array",
                    "items": {
                      "anyOf": [
                        {
                          "additionalProperties": false,
                          "description": "Single metric threshold evaluated against entity insights.",
                          "type": "object",
                          "required": [
                            "metric",
                            "operator",
                            "time_range",
                            "value"
                          ],
                          "properties": {
                            "metric": {
                              "description": "Metric key (platform metric, derived metric, or action-type KPI from action_types_canonical).",
                              "minLength": 1,
                              "type": "string"
                            },
                            "operator": {
                              "description": "Comparison operator. `between`/`not_between` require both `value` and `value2`; `increased_pct`/`decreased_pct` compare the current `time_range` against the immediately preceding period of equal duration.",
                              "anyOf": [
                                {
                                  "type": "string",
                                  "enum": [
                                    "gt"
                                  ]
                                },
                                {
                                  "type": "string",
                                  "enum": [
                                    "lt"
                                  ]
                                },
                                {
                                  "type": "string",
                                  "enum": [
                                    "gte"
                                  ]
                                },
                                {
                                  "type": "string",
                                  "enum": [
                                    "lte"
                                  ]
                                },
                                {
                                  "type": "string",
                                  "enum": [
                                    "eq"
                                  ]
                                },
                                {
                                  "type": "string",
                                  "enum": [
                                    "neq"
                                  ]
                                },
                                {
                                  "type": "string",
                                  "enum": [
                                    "between"
                                  ]
                                },
                                {
                                  "type": "string",
                                  "enum": [
                                    "not_between"
                                  ]
                                },
                                {
                                  "type": "string",
                                  "enum": [
                                    "increased_pct"
                                  ]
                                },
                                {
                                  "type": "string",
                                  "enum": [
                                    "decreased_pct"
                                  ]
                                }
                              ]
                            },
                            "time_range": {
                              "description": "Time window over which the metric is aggregated.",
                              "anyOf": [
                                {
                                  "type": "string",
                                  "enum": [
                                    "today"
                                  ]
                                },
                                {
                                  "type": "string",
                                  "enum": [
                                    "yesterday"
                                  ]
                                },
                                {
                                  "type": "string",
                                  "enum": [
                                    "last_3d"
                                  ]
                                },
                                {
                                  "type": "string",
                                  "enum": [
                                    "last_7d"
                                  ]
                                },
                                {
                                  "type": "string",
                                  "enum": [
                                    "last_14d"
                                  ]
                                },
                                {
                                  "type": "string",
                                  "enum": [
                                    "last_30d"
                                  ]
                                }
                              ]
                            },
                            "value": {
                              "description": "Primary threshold. Coerced to Number at evaluation time.",
                              "anyOf": [
                                {
                                  "type": "number"
                                },
                                {
                                  "type": "string"
                                }
                              ]
                            },
                            "value2": {
                              "description": "Secondary threshold (required for `between` / `not_between`).",
                              "anyOf": [
                                {
                                  "type": "number"
                                },
                                {
                                  "type": "string"
                                }
                              ]
                            },
                            "trend_window": {
                              "description": "Time window over which the metric is aggregated.",
                              "anyOf": [
                                {
                                  "type": "string",
                                  "enum": [
                                    "today"
                                  ]
                                },
                                {
                                  "type": "string",
                                  "enum": [
                                    "yesterday"
                                  ]
                                },
                                {
                                  "type": "string",
                                  "enum": [
                                    "last_3d"
                                  ]
                                },
                                {
                                  "type": "string",
                                  "enum": [
                                    "last_7d"
                                  ]
                                },
                                {
                                  "type": "string",
                                  "enum": [
                                    "last_14d"
                                  ]
                                },
                                {
                                  "type": "string",
                                  "enum": [
                                    "last_30d"
                                  ]
                                }
                              ]
                            }
                          }
                        },
                        {
                          "additionalProperties": false,
                          "description": "Account-level comparison across two advertising platforms, or between one platform and a literal.",
                          "type": "object",
                          "required": [
                            "type",
                            "left",
                            "operator",
                            "right"
                          ],
                          "properties": {
                            "type": {
                              "type": "string",
                              "enum": [
                                "cross_platform_comparison"
                              ]
                            },
                            "left": {
                              "anyOf": [
                                {
                                  "additionalProperties": false,
                                  "type": "object",
                                  "required": [
                                    "type",
                                    "platform",
                                    "metric"
                                  ],
                                  "properties": {
                                    "type": {
                                      "type": "string",
                                      "enum": [
                                        "platform_metric"
                                      ]
                                    },
                                    "platform": {
                                      "anyOf": [
                                        {
                                          "type": "string",
                                          "enum": [
                                            "META"
                                          ]
                                        },
                                        {
                                          "type": "string",
                                          "enum": [
                                            "GOOGLE"
                                          ]
                                        },
                                        {
                                          "type": "string",
                                          "enum": [
                                            "TIKTOK"
                                          ]
                                        },
                                        {
                                          "type": "string",
                                          "enum": [
                                            "TABOOLA"
                                          ]
                                        },
                                        {
                                          "type": "string",
                                          "enum": [
                                            "LINKEDIN"
                                          ]
                                        }
                                      ]
                                    },
                                    "metric": {
                                      "anyOf": [
                                        {
                                          "type": "string",
                                          "enum": [
                                            "spend"
                                          ]
                                        },
                                        {
                                          "type": "string",
                                          "enum": [
                                            "spend_pct"
                                          ]
                                        },
                                        {
                                          "type": "string",
                                          "enum": [
                                            "impressions"
                                          ]
                                        },
                                        {
                                          "type": "string",
                                          "enum": [
                                            "clicks"
                                          ]
                                        },
                                        {
                                          "type": "string",
                                          "enum": [
                                            "ctr"
                                          ]
                                        },
                                        {
                                          "type": "string",
                                          "enum": [
                                            "cpc"
                                          ]
                                        },
                                        {
                                          "type": "string",
                                          "enum": [
                                            "cpm"
                                          ]
                                        },
                                        {
                                          "type": "string",
                                          "enum": [
                                            "purchases"
                                          ]
                                        },
                                        {
                                          "type": "string",
                                          "enum": [
                                            "purchase_value"
                                          ]
                                        },
                                        {
                                          "type": "string",
                                          "enum": [
                                            "conversions"
                                          ]
                                        },
                                        {
                                          "type": "string",
                                          "enum": [
                                            "roas"
                                          ]
                                        },
                                        {
                                          "type": "string",
                                          "enum": [
                                            "cpa"
                                          ]
                                        },
                                        {
                                          "type": "string",
                                          "enum": [
                                            "cpl"
                                          ]
                                        }
                                      ]
                                    },
                                    "level": {
                                      "type": "string",
                                      "enum": [
                                        "account"
                                      ]
                                    },
                                    "timeframe_days": {
                                      "minimum": 1,
                                      "maximum": 90,
                                      "type": "integer"
                                    },
                                    "multiplier": {
                                      "minimum": 0,
                                      "type": "number"
                                    }
                                  }
                                },
                                {
                                  "additionalProperties": false,
                                  "type": "object",
                                  "required": [
                                    "type",
                                    "value"
                                  ],
                                  "properties": {
                                    "type": {
                                      "type": "string",
                                      "enum": [
                                        "literal"
                                      ]
                                    },
                                    "value": {
                                      "type": "number"
                                    }
                                  }
                                }
                              ]
                            },
                            "operator": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "enum": [
                                    "greater_than"
                                  ]
                                },
                                {
                                  "type": "string",
                                  "enum": [
                                    "less_than"
                                  ]
                                },
                                {
                                  "type": "string",
                                  "enum": [
                                    "greater_or_equal"
                                  ]
                                },
                                {
                                  "type": "string",
                                  "enum": [
                                    "less_or_equal"
                                  ]
                                },
                                {
                                  "type": "string",
                                  "enum": [
                                    "equal"
                                  ]
                                }
                              ]
                            },
                            "right": {
                              "anyOf": [
                                {
                                  "additionalProperties": false,
                                  "type": "object",
                                  "required": [
                                    "type",
                                    "platform",
                                    "metric"
                                  ],
                                  "properties": {
                                    "type": {
                                      "type": "string",
                                      "enum": [
                                        "platform_metric"
                                      ]
                                    },
                                    "platform": {
                                      "anyOf": [
                                        {
                                          "type": "string",
                                          "enum": [
                                            "META"
                                          ]
                                        },
                                        {
                                          "type": "string",
                                          "enum": [
                                            "GOOGLE"
                                          ]
                                        },
                                        {
                                          "type": "string",
                                          "enum": [
                                            "TIKTOK"
                                          ]
                                        },
                                        {
                                          "type": "string",
                                          "enum": [
                                            "TABOOLA"
                                          ]
                                        },
                                        {
                                          "type": "string",
                                          "enum": [
                                            "LINKEDIN"
                                          ]
                                        }
                                      ]
                                    },
                                    "metric": {
                                      "anyOf": [
                                        {
                                          "type": "string",
                                          "enum": [
                                            "spend"
                                          ]
                                        },
                                        {
                                          "type": "string",
                                          "enum": [
                                            "spend_pct"
                                          ]
                                        },
                                        {
                                          "type": "string",
                                          "enum": [
                                            "impressions"
                                          ]
                                        },
                                        {
                                          "type": "string",
                                          "enum": [
                                            "clicks"
                                          ]
                                        },
                                        {
                                          "type": "string",
                                          "enum": [
                                            "ctr"
                                          ]
                                        },
                                        {
                                          "type": "string",
                                          "enum": [
                                            "cpc"
                                          ]
                                        },
                                        {
                                          "type": "string",
                                          "enum": [
                                            "cpm"
                                          ]
                                        },
                                        {
                                          "type": "string",
                                          "enum": [
                                            "purchases"
                                          ]
                                        },
                                        {
                                          "type": "string",
                                          "enum": [
                                            "purchase_value"
                                          ]
                                        },
                                        {
                                          "type": "string",
                                          "enum": [
                                            "conversions"
                                          ]
                                        },
                                        {
                                          "type": "string",
                                          "enum": [
                                            "roas"
                                          ]
                                        },
                                        {
                                          "type": "string",
                                          "enum": [
                                            "cpa"
                                          ]
                                        },
                                        {
                                          "type": "string",
                                          "enum": [
                                            "cpl"
                                          ]
                                        }
                                      ]
                                    },
                                    "level": {
                                      "type": "string",
                                      "enum": [
                                        "account"
                                      ]
                                    },
                                    "timeframe_days": {
                                      "minimum": 1,
                                      "maximum": 90,
                                      "type": "integer"
                                    },
                                    "multiplier": {
                                      "minimum": 0,
                                      "type": "number"
                                    }
                                  }
                                },
                                {
                                  "additionalProperties": false,
                                  "type": "object",
                                  "required": [
                                    "type",
                                    "value"
                                  ],
                                  "properties": {
                                    "type": {
                                      "type": "string",
                                      "enum": [
                                        "literal"
                                      ]
                                    },
                                    "value": {
                                      "type": "number"
                                    }
                                  }
                                }
                              ]
                            }
                          }
                        }
                      ]
                    }
                  },
                  "actions": {
                    "description": "Ordered list of actions applied to each matched entity.",
                    "type": "array",
                    "items": {
                      "description": "Automation rule action. Discriminated on `type`. See RuleActionType in src/sqs/types/messages.ts.",
                      "anyOf": [
                        {
                          "additionalProperties": false,
                          "type": "object",
                          "required": [
                            "type"
                          ],
                          "properties": {
                            "type": {
                              "description": "Pause the matched entity (campaign/adset/ad).",
                              "type": "string",
                              "enum": [
                                "pause"
                              ]
                            },
                            "params": {
                              "$comment": "json-value",
                              "description": "Arbitrary JSON value with nested arrays and objects."
                            }
                          }
                        },
                        {
                          "additionalProperties": false,
                          "type": "object",
                          "required": [
                            "type"
                          ],
                          "properties": {
                            "type": {
                              "description": "Activate the matched entity (campaign/adset/ad).",
                              "type": "string",
                              "enum": [
                                "activate"
                              ]
                            },
                            "params": {
                              "$comment": "json-value",
                              "description": "Arbitrary JSON value with nested arrays and objects."
                            }
                          }
                        },
                        {
                          "additionalProperties": false,
                          "type": "object",
                          "required": [
                            "type"
                          ],
                          "properties": {
                            "type": {
                              "description": "Increase campaign/adset budget by `params.percentage` percent.",
                              "type": "string",
                              "enum": [
                                "increase_budget_pct"
                              ]
                            },
                            "params": {
                              "additionalProperties": false,
                              "type": "object",
                              "properties": {
                                "percentage": {
                                  "description": "Percent increase in [1, 1000] (defaults to 20 if omitted at runtime). 0 is rejected because a 0% change is a no-op and the worker clamps it to 1 anyway — the schema makes that contract explicit. The ceiling is deliberately far above 100: doubling or tripling a budget is ordinary media buying, and the old 100 cap (borrowed from the decrease action, where >100% is meaningless) made the rules list unserializable for anyone who had scaled a budget by more.",
                                  "minimum": 1,
                                  "maximum": 1000,
                                  "type": "number"
                                },
                                "pct": {
                                  "description": "Legacy template alias for `percentage`; accepted for seeded rule templates.",
                                  "minimum": 1,
                                  "maximum": 1000,
                                  "type": "number"
                                }
                              }
                            }
                          }
                        },
                        {
                          "additionalProperties": false,
                          "type": "object",
                          "required": [
                            "type"
                          ],
                          "properties": {
                            "type": {
                              "description": "Decrease campaign/adset budget by `params.percentage` percent.",
                              "type": "string",
                              "enum": [
                                "decrease_budget_pct"
                              ]
                            },
                            "params": {
                              "additionalProperties": false,
                              "type": "object",
                              "properties": {
                                "percentage": {
                                  "description": "Percent change in [1, 100] (defaults to 20 if omitted at runtime). 0 is rejected because a 0% change is a no-op and the worker clamps it to 1 anyway — the schema makes that contract explicit.",
                                  "minimum": 1,
                                  "maximum": 100,
                                  "type": "number"
                                },
                                "pct": {
                                  "description": "Legacy template alias for `percentage`; accepted for seeded rule templates.",
                                  "minimum": 1,
                                  "maximum": 100,
                                  "type": "number"
                                }
                              }
                            }
                          }
                        },
                        {
                          "additionalProperties": false,
                          "type": "object",
                          "required": [
                            "type"
                          ],
                          "properties": {
                            "type": {
                              "description": "Relaunch the ad (duplicate + delete original). Only valid at ad level.",
                              "type": "string",
                              "enum": [
                                "relaunch"
                              ]
                            },
                            "params": {
                              "$comment": "json-value",
                              "description": "Arbitrary JSON value with nested arrays and objects."
                            }
                          }
                        },
                        {
                          "additionalProperties": false,
                          "type": "object",
                          "required": [
                            "type"
                          ],
                          "properties": {
                            "type": {
                              "description": "Send a notification but do not mutate anything on Meta.",
                              "type": "string",
                              "enum": [
                                "notify_only"
                              ]
                            },
                            "params": {
                              "$comment": "json-value",
                              "description": "Arbitrary JSON value with nested arrays and objects."
                            }
                          }
                        },
                        {
                          "additionalProperties": false,
                          "type": "object",
                          "required": [
                            "type",
                            "platform",
                            "entity_level"
                          ],
                          "properties": {
                            "type": {
                              "type": "string",
                              "enum": [
                                "PAUSE_TOP_SPEND_CAMPAIGN"
                              ]
                            },
                            "platform": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "enum": [
                                    "META"
                                  ]
                                },
                                {
                                  "type": "string",
                                  "enum": [
                                    "GOOGLE"
                                  ]
                                },
                                {
                                  "type": "string",
                                  "enum": [
                                    "TIKTOK"
                                  ]
                                },
                                {
                                  "type": "string",
                                  "enum": [
                                    "TABOOLA"
                                  ]
                                },
                                {
                                  "type": "string",
                                  "enum": [
                                    "LINKEDIN"
                                  ]
                                }
                              ]
                            },
                            "entity_level": {
                              "type": "string",
                              "enum": [
                                "campaign"
                              ]
                            }
                          }
                        },
                        {
                          "additionalProperties": false,
                          "type": "object",
                          "required": [
                            "type",
                            "platform",
                            "entity_level",
                            "pct"
                          ],
                          "properties": {
                            "type": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "enum": [
                                    "INCREASE_BUDGET_PCT"
                                  ]
                                },
                                {
                                  "type": "string",
                                  "enum": [
                                    "DECREASE_BUDGET_PCT"
                                  ]
                                }
                              ]
                            },
                            "platform": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "enum": [
                                    "META"
                                  ]
                                },
                                {
                                  "type": "string",
                                  "enum": [
                                    "GOOGLE"
                                  ]
                                },
                                {
                                  "type": "string",
                                  "enum": [
                                    "TIKTOK"
                                  ]
                                },
                                {
                                  "type": "string",
                                  "enum": [
                                    "TABOOLA"
                                  ]
                                },
                                {
                                  "type": "string",
                                  "enum": [
                                    "LINKEDIN"
                                  ]
                                }
                              ]
                            },
                            "entity_level": {
                              "type": "string",
                              "enum": [
                                "campaign"
                              ]
                            },
                            "pct": {
                              "minimum": 1,
                              "maximum": 100,
                              "type": "number"
                            }
                          }
                        },
                        {
                          "additionalProperties": false,
                          "type": "object",
                          "required": [
                            "type",
                            "channel",
                            "message_template"
                          ],
                          "properties": {
                            "type": {
                              "type": "string",
                              "enum": [
                                "NOTIFY_CHANNEL"
                              ]
                            },
                            "channel": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "enum": [
                                    "in_app"
                                  ]
                                },
                                {
                                  "type": "string",
                                  "enum": [
                                    "email"
                                  ]
                                },
                                {
                                  "type": "string",
                                  "enum": [
                                    "telegram"
                                  ]
                                }
                              ]
                            },
                            "message_template": {
                              "minLength": 1,
                              "maxLength": 500,
                              "type": "string"
                            }
                          }
                        }
                      ]
                    }
                  },
                  "schedule_type": {
                    "anyOf": [
                      {
                        "type": "string",
                        "enum": [
                          "interval"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "daily"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "daily_at_time"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "day_parting"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "custom"
                        ]
                      }
                    ]
                  },
                  "interval_minutes": {
                    "minimum": 1,
                    "type": "integer"
                  },
                  "schedule_config": {
                    "anyOf": [
                      {
                        "additionalProperties": false,
                        "description": "Optional schedule-specific rule configuration. `daily_at_time` uses `time`; `day_parting` uses `hours_of_day`/`days_of_week` and/or explicit `slots`.",
                        "type": "object",
                        "properties": {
                          "time": {
                            "description": "Daily evaluation time in HH:MM format. Runtime validation enforces 00:00-23:59.",
                            "type": "string"
                          },
                          "type": {
                            "type": "string",
                            "enum": [
                              "day_parting"
                            ]
                          },
                          "hours_of_day": {
                            "description": "Hours of day eligible for evaluation. Runtime validation enforces non-empty integers 0-23.",
                            "maxItems": 24,
                            "type": "array",
                            "items": {
                              "type": "number"
                            }
                          },
                          "days_of_week": {
                            "description": "Days of week eligible for evaluation, where 0 is Sunday and 6 is Saturday.",
                            "maxItems": 7,
                            "type": "array",
                            "items": {
                              "type": "number"
                            }
                          },
                          "slots": {
                            "description": "Explicit day/hour evaluation slots. Runtime validation enforces non-empty valid slots.",
                            "type": "array",
                            "items": {
                              "additionalProperties": false,
                              "type": "object",
                              "required": [
                                "day",
                                "hour"
                              ],
                              "properties": {
                                "day": {
                                  "description": "Day of week, where 0 is Sunday and 6 is Saturday. Runtime validation enforces integer 0-6.",
                                  "type": "number"
                                },
                                "hour": {
                                  "description": "Hour of day in 24-hour format. Runtime validation enforces integer 0-23.",
                                  "type": "number"
                                }
                              }
                            }
                          },
                          "timezone": {
                            "minLength": 1,
                            "maxLength": 100,
                            "type": "string"
                          }
                        }
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "timezone": {
                    "type": "string"
                  },
                  "cooldown_minutes": {
                    "minimum": 0,
                    "type": "integer"
                  },
                  "max_executions_per_day": {
                    "minimum": 1,
                    "type": "integer"
                  },
                  "budget_change_limit_pct": {
                    "anyOf": [
                      {
                        "type": "number"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "budget_daily_cap": {
                    "anyOf": [
                      {
                        "type": "number"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "notify_on_execution": {
                    "type": "boolean"
                  },
                  "notify_channels": {
                    "anyOf": [
                      {
                        "additionalProperties": false,
                        "description": "Notification channels used when notify_on_execution is enabled.",
                        "type": "object",
                        "properties": {
                          "email": {
                            "type": "boolean"
                          },
                          "in_app": {
                            "type": "boolean"
                          },
                          "telegram": {
                            "type": "boolean"
                          }
                        }
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "priority": {
                    "type": "integer"
                  },
                  "platforms": {
                    "type": "array",
                    "items": {
                      "minLength": 1,
                      "maxLength": 40,
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Automation rule row as persisted in the automation_rule table.",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "description": "Automation rule row as persisted in the automation_rule table.",
                  "type": "object",
                  "required": [
                    "id",
                    "user_id",
                    "name",
                    "description",
                    "status",
                    "entity_level",
                    "ad_account_ids",
                    "entity_filter",
                    "condition_logic",
                    "conditions",
                    "actions",
                    "schedule_type",
                    "interval_minutes",
                    "schedule_config",
                    "timezone",
                    "cooldown_minutes",
                    "max_executions_per_day",
                    "budget_change_limit_pct",
                    "budget_daily_cap",
                    "notify_on_execution",
                    "notify_channels",
                    "platforms",
                    "priority",
                    "template_id",
                    "last_evaluated_at",
                    "last_executed_at",
                    "execution_count",
                    "error_count",
                    "last_error",
                    "auto_paused_at",
                    "auto_pause_reason",
                    "created_at",
                    "updated_at"
                  ],
                  "properties": {
                    "id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "user_id": {
                      "anyOf": [
                        {
                          "format": "uuid",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "created_by": {
                      "anyOf": [
                        {
                          "format": "uuid",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "name": {
                      "type": "string"
                    },
                    "description": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "status": {
                      "anyOf": [
                        {
                          "type": "string",
                          "enum": [
                            "active"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "paused"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "error"
                          ]
                        }
                      ]
                    },
                    "entity_level": {
                      "anyOf": [
                        {
                          "type": "string",
                          "enum": [
                            "campaign"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "adset"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "ad"
                          ]
                        }
                      ]
                    },
                    "ad_account_ids": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "entity_filter": {
                      "description": "Entity filter as stored, tolerant of filters written outside the strict request contract.",
                      "anyOf": [
                        {
                          "additionalProperties": false,
                          "description": "Optional entity filters applied before condition evaluation.",
                          "type": "object",
                          "properties": {
                            "name_contains": {
                              "description": "Case-insensitive substring that must be present in the entity name.",
                              "minLength": 1,
                              "maxLength": 200,
                              "type": "string"
                            },
                            "name_not_contains": {
                              "description": "Case-insensitive substring that must not be present in the entity name.",
                              "minLength": 1,
                              "maxLength": 200,
                              "type": "string"
                            },
                            "status_in": {
                              "description": "Entity statuses to include. Route validation checks whether each status is allowed for the selected entity level.",
                              "minItems": 1,
                              "maxItems": 20,
                              "type": "array",
                              "items": {
                                "minLength": 1,
                                "maxLength": 80,
                                "type": "string"
                              }
                            },
                            "account_mode": {
                              "description": "Ad-account scope intent. \"selected\" means the rule must be restricted to ad_account_ids; combined with an empty ad_account_ids the evaluator matches no entities (it does NOT silently fall back to all accounts). \"all\" (or omitted) evaluates every accessible account.",
                              "anyOf": [
                                {
                                  "type": "string",
                                  "enum": [
                                    "all"
                                  ]
                                },
                                {
                                  "type": "string",
                                  "enum": [
                                    "selected"
                                  ]
                                }
                              ]
                            }
                          }
                        },
                        {
                          "additionalProperties": true,
                          "description": "Entity filter stored before/around the current contract; surfaced as-is so the list stays readable.",
                          "type": "object",
                          "properties": {
                            "name_contains": {
                              "description": "Name filter as stored; may be empty (\"no filter\").",
                              "type": "string"
                            },
                            "name_not_contains": {
                              "description": "Negative name filter as stored; may be empty (\"no filter\").",
                              "type": "string"
                            },
                            "status_in": {
                              "description": "Statuses as stored; may be empty (\"no filter\").",
                              "type": "array",
                              "items": {
                                "type": "string"
                              }
                            },
                            "account_mode": {
                              "description": "Ad-account scope intent as stored.",
                              "type": "string"
                            }
                          }
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "condition_logic": {
                      "anyOf": [
                        {
                          "type": "string",
                          "enum": [
                            "AND"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "OR"
                          ]
                        }
                      ]
                    },
                    "conditions": {
                      "description": "Ordered list of conditions as stored, tolerant of rules written outside the request contract.",
                      "type": "array",
                      "items": {
                        "anyOf": [
                          {
                            "additionalProperties": false,
                            "description": "Single metric threshold evaluated against entity insights.",
                            "type": "object",
                            "required": [
                              "metric",
                              "operator",
                              "time_range",
                              "value"
                            ],
                            "properties": {
                              "metric": {
                                "description": "Metric key (platform metric, derived metric, or action-type KPI from action_types_canonical).",
                                "minLength": 1,
                                "type": "string"
                              },
                              "operator": {
                                "description": "Comparison operator. `between`/`not_between` require both `value` and `value2`; `increased_pct`/`decreased_pct` compare the current `time_range` against the immediately preceding period of equal duration.",
                                "anyOf": [
                                  {
                                    "type": "string",
                                    "enum": [
                                      "gt"
                                    ]
                                  },
                                  {
                                    "type": "string",
                                    "enum": [
                                      "lt"
                                    ]
                                  },
                                  {
                                    "type": "string",
                                    "enum": [
                                      "gte"
                                    ]
                                  },
                                  {
                                    "type": "string",
                                    "enum": [
                                      "lte"
                                    ]
                                  },
                                  {
                                    "type": "string",
                                    "enum": [
                                      "eq"
                                    ]
                                  },
                                  {
                                    "type": "string",
                                    "enum": [
                                      "neq"
                                    ]
                                  },
                                  {
                                    "type": "string",
                                    "enum": [
                                      "between"
                                    ]
                                  },
                                  {
                                    "type": "string",
                                    "enum": [
                                      "not_between"
                                    ]
                                  },
                                  {
                                    "type": "string",
                                    "enum": [
                                      "increased_pct"
                                    ]
                                  },
                                  {
                                    "type": "string",
                                    "enum": [
                                      "decreased_pct"
                                    ]
                                  }
                                ]
                              },
                              "time_range": {
                                "description": "Time window over which the metric is aggregated.",
                                "anyOf": [
                                  {
                                    "type": "string",
                                    "enum": [
                                      "today"
                                    ]
                                  },
                                  {
                                    "type": "string",
                                    "enum": [
                                      "yesterday"
                                    ]
                                  },
                                  {
                                    "type": "string",
                                    "enum": [
                                      "last_3d"
                                    ]
                                  },
                                  {
                                    "type": "string",
                                    "enum": [
                                      "last_7d"
                                    ]
                                  },
                                  {
                                    "type": "string",
                                    "enum": [
                                      "last_14d"
                                    ]
                                  },
                                  {
                                    "type": "string",
                                    "enum": [
                                      "last_30d"
                                    ]
                                  }
                                ]
                              },
                              "value": {
                                "description": "Primary threshold. Coerced to Number at evaluation time.",
                                "anyOf": [
                                  {
                                    "type": "number"
                                  },
                                  {
                                    "type": "string"
                                  }
                                ]
                              },
                              "value2": {
                                "description": "Secondary threshold (required for `between` / `not_between`).",
                                "anyOf": [
                                  {
                                    "type": "number"
                                  },
                                  {
                                    "type": "string"
                                  }
                                ]
                              },
                              "trend_window": {
                                "description": "Time window over which the metric is aggregated.",
                                "anyOf": [
                                  {
                                    "type": "string",
                                    "enum": [
                                      "today"
                                    ]
                                  },
                                  {
                                    "type": "string",
                                    "enum": [
                                      "yesterday"
                                    ]
                                  },
                                  {
                                    "type": "string",
                                    "enum": [
                                      "last_3d"
                                    ]
                                  },
                                  {
                                    "type": "string",
                                    "enum": [
                                      "last_7d"
                                    ]
                                  },
                                  {
                                    "type": "string",
                                    "enum": [
                                      "last_14d"
                                    ]
                                  },
                                  {
                                    "type": "string",
                                    "enum": [
                                      "last_30d"
                                    ]
                                  }
                                ]
                              }
                            }
                          },
                          {
                            "additionalProperties": false,
                            "description": "Account-level comparison across two advertising platforms, or between one platform and a literal.",
                            "type": "object",
                            "required": [
                              "type",
                              "left",
                              "operator",
                              "right"
                            ],
                            "properties": {
                              "type": {
                                "type": "string",
                                "enum": [
                                  "cross_platform_comparison"
                                ]
                              },
                              "left": {
                                "anyOf": [
                                  {
                                    "additionalProperties": false,
                                    "type": "object",
                                    "required": [
                                      "type",
                                      "platform",
                                      "metric"
                                    ],
                                    "properties": {
                                      "type": {
                                        "type": "string",
                                        "enum": [
                                          "platform_metric"
                                        ]
                                      },
                                      "platform": {
                                        "anyOf": [
                                          {
                                            "type": "string",
                                            "enum": [
                                              "META"
                                            ]
                                          },
                                          {
                                            "type": "string",
                                            "enum": [
                                              "GOOGLE"
                                            ]
                                          },
                                          {
                                            "type": "string",
                                            "enum": [
                                              "TIKTOK"
                                            ]
                                          },
                                          {
                                            "type": "string",
                                            "enum": [
                                              "TABOOLA"
                                            ]
                                          },
                                          {
                                            "type": "string",
                                            "enum": [
                                              "LINKEDIN"
                                            ]
                                          }
                                        ]
                                      },
                                      "metric": {
                                        "anyOf": [
                                          {
                                            "type": "string",
                                            "enum": [
                                              "spend"
                                            ]
                                          },
                                          {
                                            "type": "string",
                                            "enum": [
                                              "spend_pct"
                                            ]
                                          },
                                          {
                                            "type": "string",
                                            "enum": [
                                              "impressions"
                                            ]
                                          },
                                          {
                                            "type": "string",
                                            "enum": [
                                              "clicks"
                                            ]
                                          },
                                          {
                                            "type": "string",
                                            "enum": [
                                              "ctr"
                                            ]
                                          },
                                          {
                                            "type": "string",
                                            "enum": [
                                              "cpc"
                                            ]
                                          },
                                          {
                                            "type": "string",
                                            "enum": [
                                              "cpm"
                                            ]
                                          },
                                          {
                                            "type": "string",
                                            "enum": [
                                              "purchases"
                                            ]
                                          },
                                          {
                                            "type": "string",
                                            "enum": [
                                              "purchase_value"
                                            ]
                                          },
                                          {
                                            "type": "string",
                                            "enum": [
                                              "conversions"
                                            ]
                                          },
                                          {
                                            "type": "string",
                                            "enum": [
                                              "roas"
                                            ]
                                          },
                                          {
                                            "type": "string",
                                            "enum": [
                                              "cpa"
                                            ]
                                          },
                                          {
                                            "type": "string",
                                            "enum": [
                                              "cpl"
                                            ]
                                          }
                                        ]
                                      },
                                      "level": {
                                        "type": "string",
                                        "enum": [
                                          "account"
                                        ]
                                      },
                                      "timeframe_days": {
                                        "minimum": 1,
                                        "maximum": 90,
                                        "type": "integer"
                                      },
                                      "multiplier": {
                                        "minimum": 0,
                                        "type": "number"
                                      }
                                    }
                                  },
                                  {
                                    "additionalProperties": false,
                                    "type": "object",
                                    "required": [
                                      "type",
                                      "value"
                                    ],
                                    "properties": {
                                      "type": {
                                        "type": "string",
                                        "enum": [
                                          "literal"
                                        ]
                                      },
                                      "value": {
                                        "type": "number"
                                      }
                                    }
                                  }
                                ]
                              },
                              "operator": {
                                "anyOf": [
                                  {
                                    "type": "string",
                                    "enum": [
                                      "greater_than"
                                    ]
                                  },
                                  {
                                    "type": "string",
                                    "enum": [
                                      "less_than"
                                    ]
                                  },
                                  {
                                    "type": "string",
                                    "enum": [
                                      "greater_or_equal"
                                    ]
                                  },
                                  {
                                    "type": "string",
                                    "enum": [
                                      "less_or_equal"
                                    ]
                                  },
                                  {
                                    "type": "string",
                                    "enum": [
                                      "equal"
                                    ]
                                  }
                                ]
                              },
                              "right": {
                                "anyOf": [
                                  {
                                    "additionalProperties": false,
                                    "type": "object",
                                    "required": [
                                      "type",
                                      "platform",
                                      "metric"
                                    ],
                                    "properties": {
                                      "type": {
                                        "type": "string",
                                        "enum": [
                                          "platform_metric"
                                        ]
                                      },
                                      "platform": {
                                        "anyOf": [
                                          {
                                            "type": "string",
                                            "enum": [
                                              "META"
                                            ]
                                          },
                                          {
                                            "type": "string",
                                            "enum": [
                                              "GOOGLE"
                                            ]
                                          },
                                          {
                                            "type": "string",
                                            "enum": [
                                              "TIKTOK"
                                            ]
                                          },
                                          {
                                            "type": "string",
                                            "enum": [
                                              "TABOOLA"
                                            ]
                                          },
                                          {
                                            "type": "string",
                                            "enum": [
                                              "LINKEDIN"
                                            ]
                                          }
                                        ]
                                      },
                                      "metric": {
                                        "anyOf": [
                                          {
                                            "type": "string",
                                            "enum": [
                                              "spend"
                                            ]
                                          },
                                          {
                                            "type": "string",
                                            "enum": [
                                              "spend_pct"
                                            ]
                                          },
                                          {
                                            "type": "string",
                                            "enum": [
                                              "impressions"
                                            ]
                                          },
                                          {
                                            "type": "string",
                                            "enum": [
                                              "clicks"
                                            ]
                                          },
                                          {
                                            "type": "string",
                                            "enum": [
                                              "ctr"
                                            ]
                                          },
                                          {
                                            "type": "string",
                                            "enum": [
                                              "cpc"
                                            ]
                                          },
                                          {
                                            "type": "string",
                                            "enum": [
                                              "cpm"
                                            ]
                                          },
                                          {
                                            "type": "string",
                                            "enum": [
                                              "purchases"
                                            ]
                                          },
                                          {
                                            "type": "string",
                                            "enum": [
                                              "purchase_value"
                                            ]
                                          },
                                          {
                                            "type": "string",
                                            "enum": [
                                              "conversions"
                                            ]
                                          },
                                          {
                                            "type": "string",
                                            "enum": [
                                              "roas"
                                            ]
                                          },
                                          {
                                            "type": "string",
                                            "enum": [
                                              "cpa"
                                            ]
                                          },
                                          {
                                            "type": "string",
                                            "enum": [
                                              "cpl"
                                            ]
                                          }
                                        ]
                                      },
                                      "level": {
                                        "type": "string",
                                        "enum": [
                                          "account"
                                        ]
                                      },
                                      "timeframe_days": {
                                        "minimum": 1,
                                        "maximum": 90,
                                        "type": "integer"
                                      },
                                      "multiplier": {
                                        "minimum": 0,
                                        "type": "number"
                                      }
                                    }
                                  },
                                  {
                                    "additionalProperties": false,
                                    "type": "object",
                                    "required": [
                                      "type",
                                      "value"
                                    ],
                                    "properties": {
                                      "type": {
                                        "type": "string",
                                        "enum": [
                                          "literal"
                                        ]
                                      },
                                      "value": {
                                        "type": "number"
                                      }
                                    }
                                  }
                                ]
                              }
                            }
                          },
                          {
                            "additionalProperties": true,
                            "description": "Rule condition stored without the full current contract; surfaced as-is so the list stays readable.",
                            "type": "object",
                            "properties": {
                              "metric": {
                                "description": "Metric key as stored.",
                                "type": "string"
                              },
                              "operator": {
                                "description": "Comparison operator as stored.",
                                "type": "string"
                              },
                              "time_range": {
                                "description": "Time window as stored; absent means the evaluator default (`today`).",
                                "type": "string"
                              }
                            }
                          }
                        ]
                      }
                    },
                    "actions": {
                      "description": "Ordered list of actions as stored, tolerant of rules written before the current schema.",
                      "type": "array",
                      "items": {
                        "anyOf": [
                          {
                            "description": "Automation rule action. Discriminated on `type`. See RuleActionType in src/sqs/types/messages.ts.",
                            "anyOf": [
                              {
                                "additionalProperties": false,
                                "type": "object",
                                "required": [
                                  "type"
                                ],
                                "properties": {
                                  "type": {
                                    "description": "Pause the matched entity (campaign/adset/ad).",
                                    "type": "string",
                                    "enum": [
                                      "pause"
                                    ]
                                  },
                                  "params": {
                                    "$comment": "json-value",
                                    "description": "Arbitrary JSON value with nested arrays and objects."
                                  }
                                }
                              },
                              {
                                "additionalProperties": false,
                                "type": "object",
                                "required": [
                                  "type"
                                ],
                                "properties": {
                                  "type": {
                                    "description": "Activate the matched entity (campaign/adset/ad).",
                                    "type": "string",
                                    "enum": [
                                      "activate"
                                    ]
                                  },
                                  "params": {
                                    "$comment": "json-value",
                                    "description": "Arbitrary JSON value with nested arrays and objects."
                                  }
                                }
                              },
                              {
                                "additionalProperties": false,
                                "type": "object",
                                "required": [
                                  "type"
                                ],
                                "properties": {
                                  "type": {
                                    "description": "Increase campaign/adset budget by `params.percentage` percent.",
                                    "type": "string",
                                    "enum": [
                                      "increase_budget_pct"
                                    ]
                                  },
                                  "params": {
                                    "additionalProperties": false,
                                    "type": "object",
                                    "properties": {
                                      "percentage": {
                                        "description": "Percent increase in [1, 1000] (defaults to 20 if omitted at runtime). 0 is rejected because a 0% change is a no-op and the worker clamps it to 1 anyway — the schema makes that contract explicit. The ceiling is deliberately far above 100: doubling or tripling a budget is ordinary media buying, and the old 100 cap (borrowed from the decrease action, where >100% is meaningless) made the rules list unserializable for anyone who had scaled a budget by more.",
                                        "minimum": 1,
                                        "maximum": 1000,
                                        "type": "number"
                                      },
                                      "pct": {
                                        "description": "Legacy template alias for `percentage`; accepted for seeded rule templates.",
                                        "minimum": 1,
                                        "maximum": 1000,
                                        "type": "number"
                                      }
                                    }
                                  }
                                }
                              },
                              {
                                "additionalProperties": false,
                                "type": "object",
                                "required": [
                                  "type"
                                ],
                                "properties": {
                                  "type": {
                                    "description": "Decrease campaign/adset budget by `params.percentage` percent.",
                                    "type": "string",
                                    "enum": [
                                      "decrease_budget_pct"
                                    ]
                                  },
                                  "params": {
                                    "additionalProperties": false,
                                    "type": "object",
                                    "properties": {
                                      "percentage": {
                                        "description": "Percent change in [1, 100] (defaults to 20 if omitted at runtime). 0 is rejected because a 0% change is a no-op and the worker clamps it to 1 anyway — the schema makes that contract explicit.",
                                        "minimum": 1,
                                        "maximum": 100,
                                        "type": "number"
                                      },
                                      "pct": {
                                        "description": "Legacy template alias for `percentage`; accepted for seeded rule templates.",
                                        "minimum": 1,
                                        "maximum": 100,
                                        "type": "number"
                                      }
                                    }
                                  }
                                }
                              },
                              {
                                "additionalProperties": false,
                                "type": "object",
                                "required": [
                                  "type"
                                ],
                                "properties": {
                                  "type": {
                                    "description": "Relaunch the ad (duplicate + delete original). Only valid at ad level.",
                                    "type": "string",
                                    "enum": [
                                      "relaunch"
                                    ]
                                  },
                                  "params": {
                                    "$comment": "json-value",
                                    "description": "Arbitrary JSON value with nested arrays and objects."
                                  }
                                }
                              },
                              {
                                "additionalProperties": false,
                                "type": "object",
                                "required": [
                                  "type"
                                ],
                                "properties": {
                                  "type": {
                                    "description": "Send a notification but do not mutate anything on Meta.",
                                    "type": "string",
                                    "enum": [
                                      "notify_only"
                                    ]
                                  },
                                  "params": {
                                    "$comment": "json-value",
                                    "description": "Arbitrary JSON value with nested arrays and objects."
                                  }
                                }
                              },
                              {
                                "additionalProperties": false,
                                "type": "object",
                                "required": [
                                  "type",
                                  "platform",
                                  "entity_level"
                                ],
                                "properties": {
                                  "type": {
                                    "type": "string",
                                    "enum": [
                                      "PAUSE_TOP_SPEND_CAMPAIGN"
                                    ]
                                  },
                                  "platform": {
                                    "anyOf": [
                                      {
                                        "type": "string",
                                        "enum": [
                                          "META"
                                        ]
                                      },
                                      {
                                        "type": "string",
                                        "enum": [
                                          "GOOGLE"
                                        ]
                                      },
                                      {
                                        "type": "string",
                                        "enum": [
                                          "TIKTOK"
                                        ]
                                      },
                                      {
                                        "type": "string",
                                        "enum": [
                                          "TABOOLA"
                                        ]
                                      },
                                      {
                                        "type": "string",
                                        "enum": [
                                          "LINKEDIN"
                                        ]
                                      }
                                    ]
                                  },
                                  "entity_level": {
                                    "type": "string",
                                    "enum": [
                                      "campaign"
                                    ]
                                  }
                                }
                              },
                              {
                                "additionalProperties": false,
                                "type": "object",
                                "required": [
                                  "type",
                                  "platform",
                                  "entity_level",
                                  "pct"
                                ],
                                "properties": {
                                  "type": {
                                    "anyOf": [
                                      {
                                        "type": "string",
                                        "enum": [
                                          "INCREASE_BUDGET_PCT"
                                        ]
                                      },
                                      {
                                        "type": "string",
                                        "enum": [
                                          "DECREASE_BUDGET_PCT"
                                        ]
                                      }
                                    ]
                                  },
                                  "platform": {
                                    "anyOf": [
                                      {
                                        "type": "string",
                                        "enum": [
                                          "META"
                                        ]
                                      },
                                      {
                                        "type": "string",
                                        "enum": [
                                          "GOOGLE"
                                        ]
                                      },
                                      {
                                        "type": "string",
                                        "enum": [
                                          "TIKTOK"
                                        ]
                                      },
                                      {
                                        "type": "string",
                                        "enum": [
                                          "TABOOLA"
                                        ]
                                      },
                                      {
                                        "type": "string",
                                        "enum": [
                                          "LINKEDIN"
                                        ]
                                      }
                                    ]
                                  },
                                  "entity_level": {
                                    "type": "string",
                                    "enum": [
                                      "campaign"
                                    ]
                                  },
                                  "pct": {
                                    "minimum": 1,
                                    "maximum": 100,
                                    "type": "number"
                                  }
                                }
                              },
                              {
                                "additionalProperties": false,
                                "type": "object",
                                "required": [
                                  "type",
                                  "channel",
                                  "message_template"
                                ],
                                "properties": {
                                  "type": {
                                    "type": "string",
                                    "enum": [
                                      "NOTIFY_CHANNEL"
                                    ]
                                  },
                                  "channel": {
                                    "anyOf": [
                                      {
                                        "type": "string",
                                        "enum": [
                                          "in_app"
                                        ]
                                      },
                                      {
                                        "type": "string",
                                        "enum": [
                                          "email"
                                        ]
                                      },
                                      {
                                        "type": "string",
                                        "enum": [
                                          "telegram"
                                        ]
                                      }
                                    ]
                                  },
                                  "message_template": {
                                    "minLength": 1,
                                    "maxLength": 500,
                                    "type": "string"
                                  }
                                }
                              }
                            ]
                          },
                          {
                            "additionalProperties": true,
                            "description": "Rule action stored before the current schema; surfaced as-is so the list stays readable.",
                            "type": "object",
                            "required": [
                              "type"
                            ],
                            "properties": {
                              "type": {
                                "description": "Action discriminator as stored, including legacy spellings.",
                                "type": "string"
                              },
                              "params": {
                                "$comment": "json-value",
                                "description": "Arbitrary JSON value with nested arrays and objects."
                              }
                            }
                          }
                        ]
                      }
                    },
                    "schedule_type": {
                      "anyOf": [
                        {
                          "type": "string",
                          "enum": [
                            "interval"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "daily"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "daily_at_time"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "day_parting"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "custom"
                          ]
                        }
                      ]
                    },
                    "interval_minutes": {
                      "type": "integer"
                    },
                    "schedule_config": {
                      "description": "Schedule config as stored, tolerant of values written outside the strict request contract.",
                      "anyOf": [
                        {
                          "additionalProperties": false,
                          "description": "Optional schedule-specific rule configuration. `daily_at_time` uses `time`; `day_parting` uses `hours_of_day`/`days_of_week` and/or explicit `slots`.",
                          "type": "object",
                          "properties": {
                            "time": {
                              "description": "Daily evaluation time in HH:MM format. Runtime validation enforces 00:00-23:59.",
                              "type": "string"
                            },
                            "type": {
                              "type": "string",
                              "enum": [
                                "day_parting"
                              ]
                            },
                            "hours_of_day": {
                              "description": "Hours of day eligible for evaluation. Runtime validation enforces non-empty integers 0-23.",
                              "maxItems": 24,
                              "type": "array",
                              "items": {
                                "type": "number"
                              }
                            },
                            "days_of_week": {
                              "description": "Days of week eligible for evaluation, where 0 is Sunday and 6 is Saturday.",
                              "maxItems": 7,
                              "type": "array",
                              "items": {
                                "type": "number"
                              }
                            },
                            "slots": {
                              "description": "Explicit day/hour evaluation slots. Runtime validation enforces non-empty valid slots.",
                              "type": "array",
                              "items": {
                                "additionalProperties": false,
                                "type": "object",
                                "required": [
                                  "day",
                                  "hour"
                                ],
                                "properties": {
                                  "day": {
                                    "description": "Day of week, where 0 is Sunday and 6 is Saturday. Runtime validation enforces integer 0-6.",
                                    "type": "number"
                                  },
                                  "hour": {
                                    "description": "Hour of day in 24-hour format. Runtime validation enforces integer 0-23.",
                                    "type": "number"
                                  }
                                }
                              }
                            },
                            "timezone": {
                              "minLength": 1,
                              "maxLength": 100,
                              "type": "string"
                            }
                          }
                        },
                        {
                          "additionalProperties": true,
                          "description": "Schedule config stored before/around the current contract; surfaced as-is.",
                          "type": "object",
                          "properties": {
                            "time": {
                              "description": "Daily evaluation time as stored.",
                              "type": "string"
                            },
                            "type": {
                              "description": "Schedule discriminator as stored.",
                              "type": "string"
                            },
                            "hours_of_day": {
                              "description": "Hours as stored.",
                              "type": "array",
                              "items": {
                                "type": "number"
                              }
                            },
                            "days_of_week": {
                              "description": "Days as stored.",
                              "type": "array",
                              "items": {
                                "type": "number"
                              }
                            },
                            "slots": {
                              "description": "Day/hour slots as stored.",
                              "type": "array",
                              "items": {
                                "additionalProperties": true,
                                "type": "object",
                                "properties": {
                                  "day": {
                                    "type": "number"
                                  },
                                  "hour": {
                                    "type": "number"
                                  }
                                }
                              }
                            },
                            "timezone": {
                              "description": "Timezone as stored.",
                              "type": "string"
                            }
                          }
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "timezone": {
                      "type": "string"
                    },
                    "cooldown_minutes": {
                      "type": "integer"
                    },
                    "max_executions_per_day": {
                      "type": "integer"
                    },
                    "budget_change_limit_pct": {
                      "anyOf": [
                        {
                          "type": "number"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "budget_daily_cap": {
                      "anyOf": [
                        {
                          "type": "number"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "notify_on_execution": {
                      "type": "boolean"
                    },
                    "notify_channels": {
                      "description": "Notify channels as stored, tolerant of values written outside the strict request contract.",
                      "anyOf": [
                        {
                          "additionalProperties": false,
                          "description": "Notification channels used when notify_on_execution is enabled.",
                          "type": "object",
                          "properties": {
                            "email": {
                              "type": "boolean"
                            },
                            "in_app": {
                              "type": "boolean"
                            },
                            "telegram": {
                              "type": "boolean"
                            }
                          }
                        },
                        {
                          "additionalProperties": true,
                          "description": "Notify channels stored before/around the current contract; surfaced as-is.",
                          "type": "object",
                          "properties": {
                            "email": {
                              "type": "boolean"
                            },
                            "in_app": {
                              "type": "boolean"
                            },
                            "telegram": {
                              "type": "boolean"
                            }
                          }
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "platforms": {
                      "type": "array",
                      "items": {
                        "minLength": 1,
                        "maxLength": 40,
                        "type": "string"
                      }
                    },
                    "priority": {
                      "type": "integer"
                    },
                    "template_id": {
                      "anyOf": [
                        {
                          "format": "uuid",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "last_evaluated_at": {
                      "anyOf": [
                        {
                          "format": "date-time",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "last_executed_at": {
                      "anyOf": [
                        {
                          "format": "date-time",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "execution_count": {
                      "type": "integer"
                    },
                    "error_count": {
                      "type": "integer"
                    },
                    "last_error": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "auto_paused_at": {
                      "anyOf": [
                        {
                          "format": "date-time",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "auto_pause_reason": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "cb_reset_after": {
                      "anyOf": [
                        {
                          "format": "date-time",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "created_at": {
                      "format": "date-time",
                      "type": "string"
                    },
                    "updated_at": {
                      "format": "date-time",
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "integer"
                    },
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "details": {
                      "type": "array",
                      "items": {
                        "additionalProperties": false,
                        "type": "object",
                        "required": [
                          "code",
                          "field",
                          "message"
                        ],
                        "properties": {
                          "code": {
                            "type": "string"
                          },
                          "field": {
                            "type": "string"
                          },
                          "message": {
                            "type": "string"
                          }
                        }
                      }
                    },
                    "validation": {
                      "type": "array",
                      "items": {
                        "additionalProperties": true,
                        "description": "AJV validation error item returned by Fastify for invalid params, querystrings, or bodies.",
                        "type": "object",
                        "properties": {
                          "instancePath": {
                            "type": "string"
                          },
                          "schemaPath": {
                            "type": "string"
                          },
                          "keyword": {
                            "type": "string"
                          },
                          "params": {
                            "type": "object",
                            "additionalProperties": {
                              "$comment": "json-value",
                              "description": "Arbitrary JSON value with nested arrays and objects."
                            }
                          },
                          "message": {
                            "type": "string"
                          }
                        }
                      }
                    },
                    "validationContext": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "integer"
                    },
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "integer"
                    },
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "integer"
                    },
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      },
      "delete": {
        "operationId": "deleteAutomationRule",
        "summary": "Delete automation rule",
        "tags": [
          "rules"
        ],
        "description": "Permanently deletes an automation rule by ID.",
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "success"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "integer"
                    },
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "details": {
                      "type": "array",
                      "items": {
                        "additionalProperties": false,
                        "type": "object",
                        "required": [
                          "code",
                          "field",
                          "message"
                        ],
                        "properties": {
                          "code": {
                            "type": "string"
                          },
                          "field": {
                            "type": "string"
                          },
                          "message": {
                            "type": "string"
                          }
                        }
                      }
                    },
                    "validation": {
                      "type": "array",
                      "items": {
                        "additionalProperties": true,
                        "description": "AJV validation error item returned by Fastify for invalid params, querystrings, or bodies.",
                        "type": "object",
                        "properties": {
                          "instancePath": {
                            "type": "string"
                          },
                          "schemaPath": {
                            "type": "string"
                          },
                          "keyword": {
                            "type": "string"
                          },
                          "params": {
                            "type": "object",
                            "additionalProperties": {
                              "$comment": "json-value",
                              "description": "Arbitrary JSON value with nested arrays and objects."
                            }
                          },
                          "message": {
                            "type": "string"
                          }
                        }
                      }
                    },
                    "validationContext": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "integer"
                    },
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "integer"
                    },
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/rules/{id}/toggle": {
      "post": {
        "operationId": "toggleAutomationRule",
        "summary": "Toggle automation rule status",
        "tags": [
          "rules"
        ],
        "description": "Toggles a rule between active and paused states. Resets error state when activating.",
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Automation rule row as persisted in the automation_rule table.",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "description": "Automation rule row as persisted in the automation_rule table.",
                  "type": "object",
                  "required": [
                    "id",
                    "user_id",
                    "name",
                    "description",
                    "status",
                    "entity_level",
                    "ad_account_ids",
                    "entity_filter",
                    "condition_logic",
                    "conditions",
                    "actions",
                    "schedule_type",
                    "interval_minutes",
                    "schedule_config",
                    "timezone",
                    "cooldown_minutes",
                    "max_executions_per_day",
                    "budget_change_limit_pct",
                    "budget_daily_cap",
                    "notify_on_execution",
                    "notify_channels",
                    "platforms",
                    "priority",
                    "template_id",
                    "last_evaluated_at",
                    "last_executed_at",
                    "execution_count",
                    "error_count",
                    "last_error",
                    "auto_paused_at",
                    "auto_pause_reason",
                    "created_at",
                    "updated_at"
                  ],
                  "properties": {
                    "id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "user_id": {
                      "anyOf": [
                        {
                          "format": "uuid",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "created_by": {
                      "anyOf": [
                        {
                          "format": "uuid",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "name": {
                      "type": "string"
                    },
                    "description": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "status": {
                      "anyOf": [
                        {
                          "type": "string",
                          "enum": [
                            "active"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "paused"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "error"
                          ]
                        }
                      ]
                    },
                    "entity_level": {
                      "anyOf": [
                        {
                          "type": "string",
                          "enum": [
                            "campaign"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "adset"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "ad"
                          ]
                        }
                      ]
                    },
                    "ad_account_ids": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "entity_filter": {
                      "description": "Entity filter as stored, tolerant of filters written outside the strict request contract.",
                      "anyOf": [
                        {
                          "additionalProperties": false,
                          "description": "Optional entity filters applied before condition evaluation.",
                          "type": "object",
                          "properties": {
                            "name_contains": {
                              "description": "Case-insensitive substring that must be present in the entity name.",
                              "minLength": 1,
                              "maxLength": 200,
                              "type": "string"
                            },
                            "name_not_contains": {
                              "description": "Case-insensitive substring that must not be present in the entity name.",
                              "minLength": 1,
                              "maxLength": 200,
                              "type": "string"
                            },
                            "status_in": {
                              "description": "Entity statuses to include. Route validation checks whether each status is allowed for the selected entity level.",
                              "minItems": 1,
                              "maxItems": 20,
                              "type": "array",
                              "items": {
                                "minLength": 1,
                                "maxLength": 80,
                                "type": "string"
                              }
                            },
                            "account_mode": {
                              "description": "Ad-account scope intent. \"selected\" means the rule must be restricted to ad_account_ids; combined with an empty ad_account_ids the evaluator matches no entities (it does NOT silently fall back to all accounts). \"all\" (or omitted) evaluates every accessible account.",
                              "anyOf": [
                                {
                                  "type": "string",
                                  "enum": [
                                    "all"
                                  ]
                                },
                                {
                                  "type": "string",
                                  "enum": [
                                    "selected"
                                  ]
                                }
                              ]
                            }
                          }
                        },
                        {
                          "additionalProperties": true,
                          "description": "Entity filter stored before/around the current contract; surfaced as-is so the list stays readable.",
                          "type": "object",
                          "properties": {
                            "name_contains": {
                              "description": "Name filter as stored; may be empty (\"no filter\").",
                              "type": "string"
                            },
                            "name_not_contains": {
                              "description": "Negative name filter as stored; may be empty (\"no filter\").",
                              "type": "string"
                            },
                            "status_in": {
                              "description": "Statuses as stored; may be empty (\"no filter\").",
                              "type": "array",
                              "items": {
                                "type": "string"
                              }
                            },
                            "account_mode": {
                              "description": "Ad-account scope intent as stored.",
                              "type": "string"
                            }
                          }
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "condition_logic": {
                      "anyOf": [
                        {
                          "type": "string",
                          "enum": [
                            "AND"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "OR"
                          ]
                        }
                      ]
                    },
                    "conditions": {
                      "description": "Ordered list of conditions as stored, tolerant of rules written outside the request contract.",
                      "type": "array",
                      "items": {
                        "anyOf": [
                          {
                            "additionalProperties": false,
                            "description": "Single metric threshold evaluated against entity insights.",
                            "type": "object",
                            "required": [
                              "metric",
                              "operator",
                              "time_range",
                              "value"
                            ],
                            "properties": {
                              "metric": {
                                "description": "Metric key (platform metric, derived metric, or action-type KPI from action_types_canonical).",
                                "minLength": 1,
                                "type": "string"
                              },
                              "operator": {
                                "description": "Comparison operator. `between`/`not_between` require both `value` and `value2`; `increased_pct`/`decreased_pct` compare the current `time_range` against the immediately preceding period of equal duration.",
                                "anyOf": [
                                  {
                                    "type": "string",
                                    "enum": [
                                      "gt"
                                    ]
                                  },
                                  {
                                    "type": "string",
                                    "enum": [
                                      "lt"
                                    ]
                                  },
                                  {
                                    "type": "string",
                                    "enum": [
                                      "gte"
                                    ]
                                  },
                                  {
                                    "type": "string",
                                    "enum": [
                                      "lte"
                                    ]
                                  },
                                  {
                                    "type": "string",
                                    "enum": [
                                      "eq"
                                    ]
                                  },
                                  {
                                    "type": "string",
                                    "enum": [
                                      "neq"
                                    ]
                                  },
                                  {
                                    "type": "string",
                                    "enum": [
                                      "between"
                                    ]
                                  },
                                  {
                                    "type": "string",
                                    "enum": [
                                      "not_between"
                                    ]
                                  },
                                  {
                                    "type": "string",
                                    "enum": [
                                      "increased_pct"
                                    ]
                                  },
                                  {
                                    "type": "string",
                                    "enum": [
                                      "decreased_pct"
                                    ]
                                  }
                                ]
                              },
                              "time_range": {
                                "description": "Time window over which the metric is aggregated.",
                                "anyOf": [
                                  {
                                    "type": "string",
                                    "enum": [
                                      "today"
                                    ]
                                  },
                                  {
                                    "type": "string",
                                    "enum": [
                                      "yesterday"
                                    ]
                                  },
                                  {
                                    "type": "string",
                                    "enum": [
                                      "last_3d"
                                    ]
                                  },
                                  {
                                    "type": "string",
                                    "enum": [
                                      "last_7d"
                                    ]
                                  },
                                  {
                                    "type": "string",
                                    "enum": [
                                      "last_14d"
                                    ]
                                  },
                                  {
                                    "type": "string",
                                    "enum": [
                                      "last_30d"
                                    ]
                                  }
                                ]
                              },
                              "value": {
                                "description": "Primary threshold. Coerced to Number at evaluation time.",
                                "anyOf": [
                                  {
                                    "type": "number"
                                  },
                                  {
                                    "type": "string"
                                  }
                                ]
                              },
                              "value2": {
                                "description": "Secondary threshold (required for `between` / `not_between`).",
                                "anyOf": [
                                  {
                                    "type": "number"
                                  },
                                  {
                                    "type": "string"
                                  }
                                ]
                              },
                              "trend_window": {
                                "description": "Time window over which the metric is aggregated.",
                                "anyOf": [
                                  {
                                    "type": "string",
                                    "enum": [
                                      "today"
                                    ]
                                  },
                                  {
                                    "type": "string",
                                    "enum": [
                                      "yesterday"
                                    ]
                                  },
                                  {
                                    "type": "string",
                                    "enum": [
                                      "last_3d"
                                    ]
                                  },
                                  {
                                    "type": "string",
                                    "enum": [
                                      "last_7d"
                                    ]
                                  },
                                  {
                                    "type": "string",
                                    "enum": [
                                      "last_14d"
                                    ]
                                  },
                                  {
                                    "type": "string",
                                    "enum": [
                                      "last_30d"
                                    ]
                                  }
                                ]
                              }
                            }
                          },
                          {
                            "additionalProperties": false,
                            "description": "Account-level comparison across two advertising platforms, or between one platform and a literal.",
                            "type": "object",
                            "required": [
                              "type",
                              "left",
                              "operator",
                              "right"
                            ],
                            "properties": {
                              "type": {
                                "type": "string",
                                "enum": [
                                  "cross_platform_comparison"
                                ]
                              },
                              "left": {
                                "anyOf": [
                                  {
                                    "additionalProperties": false,
                                    "type": "object",
                                    "required": [
                                      "type",
                                      "platform",
                                      "metric"
                                    ],
                                    "properties": {
                                      "type": {
                                        "type": "string",
                                        "enum": [
                                          "platform_metric"
                                        ]
                                      },
                                      "platform": {
                                        "anyOf": [
                                          {
                                            "type": "string",
                                            "enum": [
                                              "META"
                                            ]
                                          },
                                          {
                                            "type": "string",
                                            "enum": [
                                              "GOOGLE"
                                            ]
                                          },
                                          {
                                            "type": "string",
                                            "enum": [
                                              "TIKTOK"
                                            ]
                                          },
                                          {
                                            "type": "string",
                                            "enum": [
                                              "TABOOLA"
                                            ]
                                          },
                                          {
                                            "type": "string",
                                            "enum": [
                                              "LINKEDIN"
                                            ]
                                          }
                                        ]
                                      },
                                      "metric": {
                                        "anyOf": [
                                          {
                                            "type": "string",
                                            "enum": [
                                              "spend"
                                            ]
                                          },
                                          {
                                            "type": "string",
                                            "enum": [
                                              "spend_pct"
                                            ]
                                          },
                                          {
                                            "type": "string",
                                            "enum": [
                                              "impressions"
                                            ]
                                          },
                                          {
                                            "type": "string",
                                            "enum": [
                                              "clicks"
                                            ]
                                          },
                                          {
                                            "type": "string",
                                            "enum": [
                                              "ctr"
                                            ]
                                          },
                                          {
                                            "type": "string",
                                            "enum": [
                                              "cpc"
                                            ]
                                          },
                                          {
                                            "type": "string",
                                            "enum": [
                                              "cpm"
                                            ]
                                          },
                                          {
                                            "type": "string",
                                            "enum": [
                                              "purchases"
                                            ]
                                          },
                                          {
                                            "type": "string",
                                            "enum": [
                                              "purchase_value"
                                            ]
                                          },
                                          {
                                            "type": "string",
                                            "enum": [
                                              "conversions"
                                            ]
                                          },
                                          {
                                            "type": "string",
                                            "enum": [
                                              "roas"
                                            ]
                                          },
                                          {
                                            "type": "string",
                                            "enum": [
                                              "cpa"
                                            ]
                                          },
                                          {
                                            "type": "string",
                                            "enum": [
                                              "cpl"
                                            ]
                                          }
                                        ]
                                      },
                                      "level": {
                                        "type": "string",
                                        "enum": [
                                          "account"
                                        ]
                                      },
                                      "timeframe_days": {
                                        "minimum": 1,
                                        "maximum": 90,
                                        "type": "integer"
                                      },
                                      "multiplier": {
                                        "minimum": 0,
                                        "type": "number"
                                      }
                                    }
                                  },
                                  {
                                    "additionalProperties": false,
                                    "type": "object",
                                    "required": [
                                      "type",
                                      "value"
                                    ],
                                    "properties": {
                                      "type": {
                                        "type": "string",
                                        "enum": [
                                          "literal"
                                        ]
                                      },
                                      "value": {
                                        "type": "number"
                                      }
                                    }
                                  }
                                ]
                              },
                              "operator": {
                                "anyOf": [
                                  {
                                    "type": "string",
                                    "enum": [
                                      "greater_than"
                                    ]
                                  },
                                  {
                                    "type": "string",
                                    "enum": [
                                      "less_than"
                                    ]
                                  },
                                  {
                                    "type": "string",
                                    "enum": [
                                      "greater_or_equal"
                                    ]
                                  },
                                  {
                                    "type": "string",
                                    "enum": [
                                      "less_or_equal"
                                    ]
                                  },
                                  {
                                    "type": "string",
                                    "enum": [
                                      "equal"
                                    ]
                                  }
                                ]
                              },
                              "right": {
                                "anyOf": [
                                  {
                                    "additionalProperties": false,
                                    "type": "object",
                                    "required": [
                                      "type",
                                      "platform",
                                      "metric"
                                    ],
                                    "properties": {
                                      "type": {
                                        "type": "string",
                                        "enum": [
                                          "platform_metric"
                                        ]
                                      },
                                      "platform": {
                                        "anyOf": [
                                          {
                                            "type": "string",
                                            "enum": [
                                              "META"
                                            ]
                                          },
                                          {
                                            "type": "string",
                                            "enum": [
                                              "GOOGLE"
                                            ]
                                          },
                                          {
                                            "type": "string",
                                            "enum": [
                                              "TIKTOK"
                                            ]
                                          },
                                          {
                                            "type": "string",
                                            "enum": [
                                              "TABOOLA"
                                            ]
                                          },
                                          {
                                            "type": "string",
                                            "enum": [
                                              "LINKEDIN"
                                            ]
                                          }
                                        ]
                                      },
                                      "metric": {
                                        "anyOf": [
                                          {
                                            "type": "string",
                                            "enum": [
                                              "spend"
                                            ]
                                          },
                                          {
                                            "type": "string",
                                            "enum": [
                                              "spend_pct"
                                            ]
                                          },
                                          {
                                            "type": "string",
                                            "enum": [
                                              "impressions"
                                            ]
                                          },
                                          {
                                            "type": "string",
                                            "enum": [
                                              "clicks"
                                            ]
                                          },
                                          {
                                            "type": "string",
                                            "enum": [
                                              "ctr"
                                            ]
                                          },
                                          {
                                            "type": "string",
                                            "enum": [
                                              "cpc"
                                            ]
                                          },
                                          {
                                            "type": "string",
                                            "enum": [
                                              "cpm"
                                            ]
                                          },
                                          {
                                            "type": "string",
                                            "enum": [
                                              "purchases"
                                            ]
                                          },
                                          {
                                            "type": "string",
                                            "enum": [
                                              "purchase_value"
                                            ]
                                          },
                                          {
                                            "type": "string",
                                            "enum": [
                                              "conversions"
                                            ]
                                          },
                                          {
                                            "type": "string",
                                            "enum": [
                                              "roas"
                                            ]
                                          },
                                          {
                                            "type": "string",
                                            "enum": [
                                              "cpa"
                                            ]
                                          },
                                          {
                                            "type": "string",
                                            "enum": [
                                              "cpl"
                                            ]
                                          }
                                        ]
                                      },
                                      "level": {
                                        "type": "string",
                                        "enum": [
                                          "account"
                                        ]
                                      },
                                      "timeframe_days": {
                                        "minimum": 1,
                                        "maximum": 90,
                                        "type": "integer"
                                      },
                                      "multiplier": {
                                        "minimum": 0,
                                        "type": "number"
                                      }
                                    }
                                  },
                                  {
                                    "additionalProperties": false,
                                    "type": "object",
                                    "required": [
                                      "type",
                                      "value"
                                    ],
                                    "properties": {
                                      "type": {
                                        "type": "string",
                                        "enum": [
                                          "literal"
                                        ]
                                      },
                                      "value": {
                                        "type": "number"
                                      }
                                    }
                                  }
                                ]
                              }
                            }
                          },
                          {
                            "additionalProperties": true,
                            "description": "Rule condition stored without the full current contract; surfaced as-is so the list stays readable.",
                            "type": "object",
                            "properties": {
                              "metric": {
                                "description": "Metric key as stored.",
                                "type": "string"
                              },
                              "operator": {
                                "description": "Comparison operator as stored.",
                                "type": "string"
                              },
                              "time_range": {
                                "description": "Time window as stored; absent means the evaluator default (`today`).",
                                "type": "string"
                              }
                            }
                          }
                        ]
                      }
                    },
                    "actions": {
                      "description": "Ordered list of actions as stored, tolerant of rules written before the current schema.",
                      "type": "array",
                      "items": {
                        "anyOf": [
                          {
                            "description": "Automation rule action. Discriminated on `type`. See RuleActionType in src/sqs/types/messages.ts.",
                            "anyOf": [
                              {
                                "additionalProperties": false,
                                "type": "object",
                                "required": [
                                  "type"
                                ],
                                "properties": {
                                  "type": {
                                    "description": "Pause the matched entity (campaign/adset/ad).",
                                    "type": "string",
                                    "enum": [
                                      "pause"
                                    ]
                                  },
                                  "params": {
                                    "$comment": "json-value",
                                    "description": "Arbitrary JSON value with nested arrays and objects."
                                  }
                                }
                              },
                              {
                                "additionalProperties": false,
                                "type": "object",
                                "required": [
                                  "type"
                                ],
                                "properties": {
                                  "type": {
                                    "description": "Activate the matched entity (campaign/adset/ad).",
                                    "type": "string",
                                    "enum": [
                                      "activate"
                                    ]
                                  },
                                  "params": {
                                    "$comment": "json-value",
                                    "description": "Arbitrary JSON value with nested arrays and objects."
                                  }
                                }
                              },
                              {
                                "additionalProperties": false,
                                "type": "object",
                                "required": [
                                  "type"
                                ],
                                "properties": {
                                  "type": {
                                    "description": "Increase campaign/adset budget by `params.percentage` percent.",
                                    "type": "string",
                                    "enum": [
                                      "increase_budget_pct"
                                    ]
                                  },
                                  "params": {
                                    "additionalProperties": false,
                                    "type": "object",
                                    "properties": {
                                      "percentage": {
                                        "description": "Percent increase in [1, 1000] (defaults to 20 if omitted at runtime). 0 is rejected because a 0% change is a no-op and the worker clamps it to 1 anyway — the schema makes that contract explicit. The ceiling is deliberately far above 100: doubling or tripling a budget is ordinary media buying, and the old 100 cap (borrowed from the decrease action, where >100% is meaningless) made the rules list unserializable for anyone who had scaled a budget by more.",
                                        "minimum": 1,
                                        "maximum": 1000,
                                        "type": "number"
                                      },
                                      "pct": {
                                        "description": "Legacy template alias for `percentage`; accepted for seeded rule templates.",
                                        "minimum": 1,
                                        "maximum": 1000,
                                        "type": "number"
                                      }
                                    }
                                  }
                                }
                              },
                              {
                                "additionalProperties": false,
                                "type": "object",
                                "required": [
                                  "type"
                                ],
                                "properties": {
                                  "type": {
                                    "description": "Decrease campaign/adset budget by `params.percentage` percent.",
                                    "type": "string",
                                    "enum": [
                                      "decrease_budget_pct"
                                    ]
                                  },
                                  "params": {
                                    "additionalProperties": false,
                                    "type": "object",
                                    "properties": {
                                      "percentage": {
                                        "description": "Percent change in [1, 100] (defaults to 20 if omitted at runtime). 0 is rejected because a 0% change is a no-op and the worker clamps it to 1 anyway — the schema makes that contract explicit.",
                                        "minimum": 1,
                                        "maximum": 100,
                                        "type": "number"
                                      },
                                      "pct": {
                                        "description": "Legacy template alias for `percentage`; accepted for seeded rule templates.",
                                        "minimum": 1,
                                        "maximum": 100,
                                        "type": "number"
                                      }
                                    }
                                  }
                                }
                              },
                              {
                                "additionalProperties": false,
                                "type": "object",
                                "required": [
                                  "type"
                                ],
                                "properties": {
                                  "type": {
                                    "description": "Relaunch the ad (duplicate + delete original). Only valid at ad level.",
                                    "type": "string",
                                    "enum": [
                                      "relaunch"
                                    ]
                                  },
                                  "params": {
                                    "$comment": "json-value",
                                    "description": "Arbitrary JSON value with nested arrays and objects."
                                  }
                                }
                              },
                              {
                                "additionalProperties": false,
                                "type": "object",
                                "required": [
                                  "type"
                                ],
                                "properties": {
                                  "type": {
                                    "description": "Send a notification but do not mutate anything on Meta.",
                                    "type": "string",
                                    "enum": [
                                      "notify_only"
                                    ]
                                  },
                                  "params": {
                                    "$comment": "json-value",
                                    "description": "Arbitrary JSON value with nested arrays and objects."
                                  }
                                }
                              },
                              {
                                "additionalProperties": false,
                                "type": "object",
                                "required": [
                                  "type",
                                  "platform",
                                  "entity_level"
                                ],
                                "properties": {
                                  "type": {
                                    "type": "string",
                                    "enum": [
                                      "PAUSE_TOP_SPEND_CAMPAIGN"
                                    ]
                                  },
                                  "platform": {
                                    "anyOf": [
                                      {
                                        "type": "string",
                                        "enum": [
                                          "META"
                                        ]
                                      },
                                      {
                                        "type": "string",
                                        "enum": [
                                          "GOOGLE"
                                        ]
                                      },
                                      {
                                        "type": "string",
                                        "enum": [
                                          "TIKTOK"
                                        ]
                                      },
                                      {
                                        "type": "string",
                                        "enum": [
                                          "TABOOLA"
                                        ]
                                      },
                                      {
                                        "type": "string",
                                        "enum": [
                                          "LINKEDIN"
                                        ]
                                      }
                                    ]
                                  },
                                  "entity_level": {
                                    "type": "string",
                                    "enum": [
                                      "campaign"
                                    ]
                                  }
                                }
                              },
                              {
                                "additionalProperties": false,
                                "type": "object",
                                "required": [
                                  "type",
                                  "platform",
                                  "entity_level",
                                  "pct"
                                ],
                                "properties": {
                                  "type": {
                                    "anyOf": [
                                      {
                                        "type": "string",
                                        "enum": [
                                          "INCREASE_BUDGET_PCT"
                                        ]
                                      },
                                      {
                                        "type": "string",
                                        "enum": [
                                          "DECREASE_BUDGET_PCT"
                                        ]
                                      }
                                    ]
                                  },
                                  "platform": {
                                    "anyOf": [
                                      {
                                        "type": "string",
                                        "enum": [
                                          "META"
                                        ]
                                      },
                                      {
                                        "type": "string",
                                        "enum": [
                                          "GOOGLE"
                                        ]
                                      },
                                      {
                                        "type": "string",
                                        "enum": [
                                          "TIKTOK"
                                        ]
                                      },
                                      {
                                        "type": "string",
                                        "enum": [
                                          "TABOOLA"
                                        ]
                                      },
                                      {
                                        "type": "string",
                                        "enum": [
                                          "LINKEDIN"
                                        ]
                                      }
                                    ]
                                  },
                                  "entity_level": {
                                    "type": "string",
                                    "enum": [
                                      "campaign"
                                    ]
                                  },
                                  "pct": {
                                    "minimum": 1,
                                    "maximum": 100,
                                    "type": "number"
                                  }
                                }
                              },
                              {
                                "additionalProperties": false,
                                "type": "object",
                                "required": [
                                  "type",
                                  "channel",
                                  "message_template"
                                ],
                                "properties": {
                                  "type": {
                                    "type": "string",
                                    "enum": [
                                      "NOTIFY_CHANNEL"
                                    ]
                                  },
                                  "channel": {
                                    "anyOf": [
                                      {
                                        "type": "string",
                                        "enum": [
                                          "in_app"
                                        ]
                                      },
                                      {
                                        "type": "string",
                                        "enum": [
                                          "email"
                                        ]
                                      },
                                      {
                                        "type": "string",
                                        "enum": [
                                          "telegram"
                                        ]
                                      }
                                    ]
                                  },
                                  "message_template": {
                                    "minLength": 1,
                                    "maxLength": 500,
                                    "type": "string"
                                  }
                                }
                              }
                            ]
                          },
                          {
                            "additionalProperties": true,
                            "description": "Rule action stored before the current schema; surfaced as-is so the list stays readable.",
                            "type": "object",
                            "required": [
                              "type"
                            ],
                            "properties": {
                              "type": {
                                "description": "Action discriminator as stored, including legacy spellings.",
                                "type": "string"
                              },
                              "params": {
                                "$comment": "json-value",
                                "description": "Arbitrary JSON value with nested arrays and objects."
                              }
                            }
                          }
                        ]
                      }
                    },
                    "schedule_type": {
                      "anyOf": [
                        {
                          "type": "string",
                          "enum": [
                            "interval"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "daily"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "daily_at_time"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "day_parting"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "custom"
                          ]
                        }
                      ]
                    },
                    "interval_minutes": {
                      "type": "integer"
                    },
                    "schedule_config": {
                      "description": "Schedule config as stored, tolerant of values written outside the strict request contract.",
                      "anyOf": [
                        {
                          "additionalProperties": false,
                          "description": "Optional schedule-specific rule configuration. `daily_at_time` uses `time`; `day_parting` uses `hours_of_day`/`days_of_week` and/or explicit `slots`.",
                          "type": "object",
                          "properties": {
                            "time": {
                              "description": "Daily evaluation time in HH:MM format. Runtime validation enforces 00:00-23:59.",
                              "type": "string"
                            },
                            "type": {
                              "type": "string",
                              "enum": [
                                "day_parting"
                              ]
                            },
                            "hours_of_day": {
                              "description": "Hours of day eligible for evaluation. Runtime validation enforces non-empty integers 0-23.",
                              "maxItems": 24,
                              "type": "array",
                              "items": {
                                "type": "number"
                              }
                            },
                            "days_of_week": {
                              "description": "Days of week eligible for evaluation, where 0 is Sunday and 6 is Saturday.",
                              "maxItems": 7,
                              "type": "array",
                              "items": {
                                "type": "number"
                              }
                            },
                            "slots": {
                              "description": "Explicit day/hour evaluation slots. Runtime validation enforces non-empty valid slots.",
                              "type": "array",
                              "items": {
                                "additionalProperties": false,
                                "type": "object",
                                "required": [
                                  "day",
                                  "hour"
                                ],
                                "properties": {
                                  "day": {
                                    "description": "Day of week, where 0 is Sunday and 6 is Saturday. Runtime validation enforces integer 0-6.",
                                    "type": "number"
                                  },
                                  "hour": {
                                    "description": "Hour of day in 24-hour format. Runtime validation enforces integer 0-23.",
                                    "type": "number"
                                  }
                                }
                              }
                            },
                            "timezone": {
                              "minLength": 1,
                              "maxLength": 100,
                              "type": "string"
                            }
                          }
                        },
                        {
                          "additionalProperties": true,
                          "description": "Schedule config stored before/around the current contract; surfaced as-is.",
                          "type": "object",
                          "properties": {
                            "time": {
                              "description": "Daily evaluation time as stored.",
                              "type": "string"
                            },
                            "type": {
                              "description": "Schedule discriminator as stored.",
                              "type": "string"
                            },
                            "hours_of_day": {
                              "description": "Hours as stored.",
                              "type": "array",
                              "items": {
                                "type": "number"
                              }
                            },
                            "days_of_week": {
                              "description": "Days as stored.",
                              "type": "array",
                              "items": {
                                "type": "number"
                              }
                            },
                            "slots": {
                              "description": "Day/hour slots as stored.",
                              "type": "array",
                              "items": {
                                "additionalProperties": true,
                                "type": "object",
                                "properties": {
                                  "day": {
                                    "type": "number"
                                  },
                                  "hour": {
                                    "type": "number"
                                  }
                                }
                              }
                            },
                            "timezone": {
                              "description": "Timezone as stored.",
                              "type": "string"
                            }
                          }
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "timezone": {
                      "type": "string"
                    },
                    "cooldown_minutes": {
                      "type": "integer"
                    },
                    "max_executions_per_day": {
                      "type": "integer"
                    },
                    "budget_change_limit_pct": {
                      "anyOf": [
                        {
                          "type": "number"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "budget_daily_cap": {
                      "anyOf": [
                        {
                          "type": "number"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "notify_on_execution": {
                      "type": "boolean"
                    },
                    "notify_channels": {
                      "description": "Notify channels as stored, tolerant of values written outside the strict request contract.",
                      "anyOf": [
                        {
                          "additionalProperties": false,
                          "description": "Notification channels used when notify_on_execution is enabled.",
                          "type": "object",
                          "properties": {
                            "email": {
                              "type": "boolean"
                            },
                            "in_app": {
                              "type": "boolean"
                            },
                            "telegram": {
                              "type": "boolean"
                            }
                          }
                        },
                        {
                          "additionalProperties": true,
                          "description": "Notify channels stored before/around the current contract; surfaced as-is.",
                          "type": "object",
                          "properties": {
                            "email": {
                              "type": "boolean"
                            },
                            "in_app": {
                              "type": "boolean"
                            },
                            "telegram": {
                              "type": "boolean"
                            }
                          }
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "platforms": {
                      "type": "array",
                      "items": {
                        "minLength": 1,
                        "maxLength": 40,
                        "type": "string"
                      }
                    },
                    "priority": {
                      "type": "integer"
                    },
                    "template_id": {
                      "anyOf": [
                        {
                          "format": "uuid",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "last_evaluated_at": {
                      "anyOf": [
                        {
                          "format": "date-time",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "last_executed_at": {
                      "anyOf": [
                        {
                          "format": "date-time",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "execution_count": {
                      "type": "integer"
                    },
                    "error_count": {
                      "type": "integer"
                    },
                    "last_error": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "auto_paused_at": {
                      "anyOf": [
                        {
                          "format": "date-time",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "auto_pause_reason": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "cb_reset_after": {
                      "anyOf": [
                        {
                          "format": "date-time",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "created_at": {
                      "format": "date-time",
                      "type": "string"
                    },
                    "updated_at": {
                      "format": "date-time",
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "integer"
                    },
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "details": {
                      "type": "array",
                      "items": {
                        "additionalProperties": false,
                        "type": "object",
                        "required": [
                          "code",
                          "field",
                          "message"
                        ],
                        "properties": {
                          "code": {
                            "type": "string"
                          },
                          "field": {
                            "type": "string"
                          },
                          "message": {
                            "type": "string"
                          }
                        }
                      }
                    },
                    "validation": {
                      "type": "array",
                      "items": {
                        "additionalProperties": true,
                        "description": "AJV validation error item returned by Fastify for invalid params, querystrings, or bodies.",
                        "type": "object",
                        "properties": {
                          "instancePath": {
                            "type": "string"
                          },
                          "schemaPath": {
                            "type": "string"
                          },
                          "keyword": {
                            "type": "string"
                          },
                          "params": {
                            "type": "object",
                            "additionalProperties": {
                              "$comment": "json-value",
                              "description": "Arbitrary JSON value with nested arrays and objects."
                            }
                          },
                          "message": {
                            "type": "string"
                          }
                        }
                      }
                    },
                    "validationContext": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "integer"
                    },
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "integer"
                    },
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/rules/{id}/duplicate": {
      "post": {
        "operationId": "duplicateAutomationRule",
        "summary": "Duplicate automation rule",
        "tags": [
          "rules"
        ],
        "description": "Creates a copy of an existing rule in paused state with the same configuration. The copy is created in the destination workspace: send x-team-id or activate a team scope, otherwise the request fails with 400 and code SCOPE_TEAM_REQUIRED.",
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          },
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "header",
            "name": "x-team-id",
            "required": false,
            "description": "Destination workspace team id."
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "201": {
            "description": "Automation rule row as persisted in the automation_rule table.",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "description": "Automation rule row as persisted in the automation_rule table.",
                  "type": "object",
                  "required": [
                    "id",
                    "user_id",
                    "name",
                    "description",
                    "status",
                    "entity_level",
                    "ad_account_ids",
                    "entity_filter",
                    "condition_logic",
                    "conditions",
                    "actions",
                    "schedule_type",
                    "interval_minutes",
                    "schedule_config",
                    "timezone",
                    "cooldown_minutes",
                    "max_executions_per_day",
                    "budget_change_limit_pct",
                    "budget_daily_cap",
                    "notify_on_execution",
                    "notify_channels",
                    "platforms",
                    "priority",
                    "template_id",
                    "last_evaluated_at",
                    "last_executed_at",
                    "execution_count",
                    "error_count",
                    "last_error",
                    "auto_paused_at",
                    "auto_pause_reason",
                    "created_at",
                    "updated_at"
                  ],
                  "properties": {
                    "id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "user_id": {
                      "anyOf": [
                        {
                          "format": "uuid",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "created_by": {
                      "anyOf": [
                        {
                          "format": "uuid",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "name": {
                      "type": "string"
                    },
                    "description": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "status": {
                      "anyOf": [
                        {
                          "type": "string",
                          "enum": [
                            "active"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "paused"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "error"
                          ]
                        }
                      ]
                    },
                    "entity_level": {
                      "anyOf": [
                        {
                          "type": "string",
                          "enum": [
                            "campaign"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "adset"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "ad"
                          ]
                        }
                      ]
                    },
                    "ad_account_ids": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "entity_filter": {
                      "description": "Entity filter as stored, tolerant of filters written outside the strict request contract.",
                      "anyOf": [
                        {
                          "additionalProperties": false,
                          "description": "Optional entity filters applied before condition evaluation.",
                          "type": "object",
                          "properties": {
                            "name_contains": {
                              "description": "Case-insensitive substring that must be present in the entity name.",
                              "minLength": 1,
                              "maxLength": 200,
                              "type": "string"
                            },
                            "name_not_contains": {
                              "description": "Case-insensitive substring that must not be present in the entity name.",
                              "minLength": 1,
                              "maxLength": 200,
                              "type": "string"
                            },
                            "status_in": {
                              "description": "Entity statuses to include. Route validation checks whether each status is allowed for the selected entity level.",
                              "minItems": 1,
                              "maxItems": 20,
                              "type": "array",
                              "items": {
                                "minLength": 1,
                                "maxLength": 80,
                                "type": "string"
                              }
                            },
                            "account_mode": {
                              "description": "Ad-account scope intent. \"selected\" means the rule must be restricted to ad_account_ids; combined with an empty ad_account_ids the evaluator matches no entities (it does NOT silently fall back to all accounts). \"all\" (or omitted) evaluates every accessible account.",
                              "anyOf": [
                                {
                                  "type": "string",
                                  "enum": [
                                    "all"
                                  ]
                                },
                                {
                                  "type": "string",
                                  "enum": [
                                    "selected"
                                  ]
                                }
                              ]
                            }
                          }
                        },
                        {
                          "additionalProperties": true,
                          "description": "Entity filter stored before/around the current contract; surfaced as-is so the list stays readable.",
                          "type": "object",
                          "properties": {
                            "name_contains": {
                              "description": "Name filter as stored; may be empty (\"no filter\").",
                              "type": "string"
                            },
                            "name_not_contains": {
                              "description": "Negative name filter as stored; may be empty (\"no filter\").",
                              "type": "string"
                            },
                            "status_in": {
                              "description": "Statuses as stored; may be empty (\"no filter\").",
                              "type": "array",
                              "items": {
                                "type": "string"
                              }
                            },
                            "account_mode": {
                              "description": "Ad-account scope intent as stored.",
                              "type": "string"
                            }
                          }
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "condition_logic": {
                      "anyOf": [
                        {
                          "type": "string",
                          "enum": [
                            "AND"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "OR"
                          ]
                        }
                      ]
                    },
                    "conditions": {
                      "description": "Ordered list of conditions as stored, tolerant of rules written outside the request contract.",
                      "type": "array",
                      "items": {
                        "anyOf": [
                          {
                            "additionalProperties": false,
                            "description": "Single metric threshold evaluated against entity insights.",
                            "type": "object",
                            "required": [
                              "metric",
                              "operator",
                              "time_range",
                              "value"
                            ],
                            "properties": {
                              "metric": {
                                "description": "Metric key (platform metric, derived metric, or action-type KPI from action_types_canonical).",
                                "minLength": 1,
                                "type": "string"
                              },
                              "operator": {
                                "description": "Comparison operator. `between`/`not_between` require both `value` and `value2`; `increased_pct`/`decreased_pct` compare the current `time_range` against the immediately preceding period of equal duration.",
                                "anyOf": [
                                  {
                                    "type": "string",
                                    "enum": [
                                      "gt"
                                    ]
                                  },
                                  {
                                    "type": "string",
                                    "enum": [
                                      "lt"
                                    ]
                                  },
                                  {
                                    "type": "string",
                                    "enum": [
                                      "gte"
                                    ]
                                  },
                                  {
                                    "type": "string",
                                    "enum": [
                                      "lte"
                                    ]
                                  },
                                  {
                                    "type": "string",
                                    "enum": [
                                      "eq"
                                    ]
                                  },
                                  {
                                    "type": "string",
                                    "enum": [
                                      "neq"
                                    ]
                                  },
                                  {
                                    "type": "string",
                                    "enum": [
                                      "between"
                                    ]
                                  },
                                  {
                                    "type": "string",
                                    "enum": [
                                      "not_between"
                                    ]
                                  },
                                  {
                                    "type": "string",
                                    "enum": [
                                      "increased_pct"
                                    ]
                                  },
                                  {
                                    "type": "string",
                                    "enum": [
                                      "decreased_pct"
                                    ]
                                  }
                                ]
                              },
                              "time_range": {
                                "description": "Time window over which the metric is aggregated.",
                                "anyOf": [
                                  {
                                    "type": "string",
                                    "enum": [
                                      "today"
                                    ]
                                  },
                                  {
                                    "type": "string",
                                    "enum": [
                                      "yesterday"
                                    ]
                                  },
                                  {
                                    "type": "string",
                                    "enum": [
                                      "last_3d"
                                    ]
                                  },
                                  {
                                    "type": "string",
                                    "enum": [
                                      "last_7d"
                                    ]
                                  },
                                  {
                                    "type": "string",
                                    "enum": [
                                      "last_14d"
                                    ]
                                  },
                                  {
                                    "type": "string",
                                    "enum": [
                                      "last_30d"
                                    ]
                                  }
                                ]
                              },
                              "value": {
                                "description": "Primary threshold. Coerced to Number at evaluation time.",
                                "anyOf": [
                                  {
                                    "type": "number"
                                  },
                                  {
                                    "type": "string"
                                  }
                                ]
                              },
                              "value2": {
                                "description": "Secondary threshold (required for `between` / `not_between`).",
                                "anyOf": [
                                  {
                                    "type": "number"
                                  },
                                  {
                                    "type": "string"
                                  }
                                ]
                              },
                              "trend_window": {
                                "description": "Time window over which the metric is aggregated.",
                                "anyOf": [
                                  {
                                    "type": "string",
                                    "enum": [
                                      "today"
                                    ]
                                  },
                                  {
                                    "type": "string",
                                    "enum": [
                                      "yesterday"
                                    ]
                                  },
                                  {
                                    "type": "string",
                                    "enum": [
                                      "last_3d"
                                    ]
                                  },
                                  {
                                    "type": "string",
                                    "enum": [
                                      "last_7d"
                                    ]
                                  },
                                  {
                                    "type": "string",
                                    "enum": [
                                      "last_14d"
                                    ]
                                  },
                                  {
                                    "type": "string",
                                    "enum": [
                                      "last_30d"
                                    ]
                                  }
                                ]
                              }
                            }
                          },
                          {
                            "additionalProperties": false,
                            "description": "Account-level comparison across two advertising platforms, or between one platform and a literal.",
                            "type": "object",
                            "required": [
                              "type",
                              "left",
                              "operator",
                              "right"
                            ],
                            "properties": {
                              "type": {
                                "type": "string",
                                "enum": [
                                  "cross_platform_comparison"
                                ]
                              },
                              "left": {
                                "anyOf": [
                                  {
                                    "additionalProperties": false,
                                    "type": "object",
                                    "required": [
                                      "type",
                                      "platform",
                                      "metric"
                                    ],
                                    "properties": {
                                      "type": {
                                        "type": "string",
                                        "enum": [
                                          "platform_metric"
                                        ]
                                      },
                                      "platform": {
                                        "anyOf": [
                                          {
                                            "type": "string",
                                            "enum": [
                                              "META"
                                            ]
                                          },
                                          {
                                            "type": "string",
                                            "enum": [
                                              "GOOGLE"
                                            ]
                                          },
                                          {
                                            "type": "string",
                                            "enum": [
                                              "TIKTOK"
                                            ]
                                          },
                                          {
                                            "type": "string",
                                            "enum": [
                                              "TABOOLA"
                                            ]
                                          },
                                          {
                                            "type": "string",
                                            "enum": [
                                              "LINKEDIN"
                                            ]
                                          }
                                        ]
                                      },
                                      "metric": {
                                        "anyOf": [
                                          {
                                            "type": "string",
                                            "enum": [
                                              "spend"
                                            ]
                                          },
                                          {
                                            "type": "string",
                                            "enum": [
                                              "spend_pct"
                                            ]
                                          },
                                          {
                                            "type": "string",
                                            "enum": [
                                              "impressions"
                                            ]
                                          },
                                          {
                                            "type": "string",
                                            "enum": [
                                              "clicks"
                                            ]
                                          },
                                          {
                                            "type": "string",
                                            "enum": [
                                              "ctr"
                                            ]
                                          },
                                          {
                                            "type": "string",
                                            "enum": [
                                              "cpc"
                                            ]
                                          },
                                          {
                                            "type": "string",
                                            "enum": [
                                              "cpm"
                                            ]
                                          },
                                          {
                                            "type": "string",
                                            "enum": [
                                              "purchases"
                                            ]
                                          },
                                          {
                                            "type": "string",
                                            "enum": [
                                              "purchase_value"
                                            ]
                                          },
                                          {
                                            "type": "string",
                                            "enum": [
                                              "conversions"
                                            ]
                                          },
                                          {
                                            "type": "string",
                                            "enum": [
                                              "roas"
                                            ]
                                          },
                                          {
                                            "type": "string",
                                            "enum": [
                                              "cpa"
                                            ]
                                          },
                                          {
                                            "type": "string",
                                            "enum": [
                                              "cpl"
                                            ]
                                          }
                                        ]
                                      },
                                      "level": {
                                        "type": "string",
                                        "enum": [
                                          "account"
                                        ]
                                      },
                                      "timeframe_days": {
                                        "minimum": 1,
                                        "maximum": 90,
                                        "type": "integer"
                                      },
                                      "multiplier": {
                                        "minimum": 0,
                                        "type": "number"
                                      }
                                    }
                                  },
                                  {
                                    "additionalProperties": false,
                                    "type": "object",
                                    "required": [
                                      "type",
                                      "value"
                                    ],
                                    "properties": {
                                      "type": {
                                        "type": "string",
                                        "enum": [
                                          "literal"
                                        ]
                                      },
                                      "value": {
                                        "type": "number"
                                      }
                                    }
                                  }
                                ]
                              },
                              "operator": {
                                "anyOf": [
                                  {
                                    "type": "string",
                                    "enum": [
                                      "greater_than"
                                    ]
                                  },
                                  {
                                    "type": "string",
                                    "enum": [
                                      "less_than"
                                    ]
                                  },
                                  {
                                    "type": "string",
                                    "enum": [
                                      "greater_or_equal"
                                    ]
                                  },
                                  {
                                    "type": "string",
                                    "enum": [
                                      "less_or_equal"
                                    ]
                                  },
                                  {
                                    "type": "string",
                                    "enum": [
                                      "equal"
                                    ]
                                  }
                                ]
                              },
                              "right": {
                                "anyOf": [
                                  {
                                    "additionalProperties": false,
                                    "type": "object",
                                    "required": [
                                      "type",
                                      "platform",
                                      "metric"
                                    ],
                                    "properties": {
                                      "type": {
                                        "type": "string",
                                        "enum": [
                                          "platform_metric"
                                        ]
                                      },
                                      "platform": {
                                        "anyOf": [
                                          {
                                            "type": "string",
                                            "enum": [
                                              "META"
                                            ]
                                          },
                                          {
                                            "type": "string",
                                            "enum": [
                                              "GOOGLE"
                                            ]
                                          },
                                          {
                                            "type": "string",
                                            "enum": [
                                              "TIKTOK"
                                            ]
                                          },
                                          {
                                            "type": "string",
                                            "enum": [
                                              "TABOOLA"
                                            ]
                                          },
                                          {
                                            "type": "string",
                                            "enum": [
                                              "LINKEDIN"
                                            ]
                                          }
                                        ]
                                      },
                                      "metric": {
                                        "anyOf": [
                                          {
                                            "type": "string",
                                            "enum": [
                                              "spend"
                                            ]
                                          },
                                          {
                                            "type": "string",
                                            "enum": [
                                              "spend_pct"
                                            ]
                                          },
                                          {
                                            "type": "string",
                                            "enum": [
                                              "impressions"
                                            ]
                                          },
                                          {
                                            "type": "string",
                                            "enum": [
                                              "clicks"
                                            ]
                                          },
                                          {
                                            "type": "string",
                                            "enum": [
                                              "ctr"
                                            ]
                                          },
                                          {
                                            "type": "string",
                                            "enum": [
                                              "cpc"
                                            ]
                                          },
                                          {
                                            "type": "string",
                                            "enum": [
                                              "cpm"
                                            ]
                                          },
                                          {
                                            "type": "string",
                                            "enum": [
                                              "purchases"
                                            ]
                                          },
                                          {
                                            "type": "string",
                                            "enum": [
                                              "purchase_value"
                                            ]
                                          },
                                          {
                                            "type": "string",
                                            "enum": [
                                              "conversions"
                                            ]
                                          },
                                          {
                                            "type": "string",
                                            "enum": [
                                              "roas"
                                            ]
                                          },
                                          {
                                            "type": "string",
                                            "enum": [
                                              "cpa"
                                            ]
                                          },
                                          {
                                            "type": "string",
                                            "enum": [
                                              "cpl"
                                            ]
                                          }
                                        ]
                                      },
                                      "level": {
                                        "type": "string",
                                        "enum": [
                                          "account"
                                        ]
                                      },
                                      "timeframe_days": {
                                        "minimum": 1,
                                        "maximum": 90,
                                        "type": "integer"
                                      },
                                      "multiplier": {
                                        "minimum": 0,
                                        "type": "number"
                                      }
                                    }
                                  },
                                  {
                                    "additionalProperties": false,
                                    "type": "object",
                                    "required": [
                                      "type",
                                      "value"
                                    ],
                                    "properties": {
                                      "type": {
                                        "type": "string",
                                        "enum": [
                                          "literal"
                                        ]
                                      },
                                      "value": {
                                        "type": "number"
                                      }
                                    }
                                  }
                                ]
                              }
                            }
                          },
                          {
                            "additionalProperties": true,
                            "description": "Rule condition stored without the full current contract; surfaced as-is so the list stays readable.",
                            "type": "object",
                            "properties": {
                              "metric": {
                                "description": "Metric key as stored.",
                                "type": "string"
                              },
                              "operator": {
                                "description": "Comparison operator as stored.",
                                "type": "string"
                              },
                              "time_range": {
                                "description": "Time window as stored; absent means the evaluator default (`today`).",
                                "type": "string"
                              }
                            }
                          }
                        ]
                      }
                    },
                    "actions": {
                      "description": "Ordered list of actions as stored, tolerant of rules written before the current schema.",
                      "type": "array",
                      "items": {
                        "anyOf": [
                          {
                            "description": "Automation rule action. Discriminated on `type`. See RuleActionType in src/sqs/types/messages.ts.",
                            "anyOf": [
                              {
                                "additionalProperties": false,
                                "type": "object",
                                "required": [
                                  "type"
                                ],
                                "properties": {
                                  "type": {
                                    "description": "Pause the matched entity (campaign/adset/ad).",
                                    "type": "string",
                                    "enum": [
                                      "pause"
                                    ]
                                  },
                                  "params": {
                                    "$comment": "json-value",
                                    "description": "Arbitrary JSON value with nested arrays and objects."
                                  }
                                }
                              },
                              {
                                "additionalProperties": false,
                                "type": "object",
                                "required": [
                                  "type"
                                ],
                                "properties": {
                                  "type": {
                                    "description": "Activate the matched entity (campaign/adset/ad).",
                                    "type": "string",
                                    "enum": [
                                      "activate"
                                    ]
                                  },
                                  "params": {
                                    "$comment": "json-value",
                                    "description": "Arbitrary JSON value with nested arrays and objects."
                                  }
                                }
                              },
                              {
                                "additionalProperties": false,
                                "type": "object",
                                "required": [
                                  "type"
                                ],
                                "properties": {
                                  "type": {
                                    "description": "Increase campaign/adset budget by `params.percentage` percent.",
                                    "type": "string",
                                    "enum": [
                                      "increase_budget_pct"
                                    ]
                                  },
                                  "params": {
                                    "additionalProperties": false,
                                    "type": "object",
                                    "properties": {
                                      "percentage": {
                                        "description": "Percent increase in [1, 1000] (defaults to 20 if omitted at runtime). 0 is rejected because a 0% change is a no-op and the worker clamps it to 1 anyway — the schema makes that contract explicit. The ceiling is deliberately far above 100: doubling or tripling a budget is ordinary media buying, and the old 100 cap (borrowed from the decrease action, where >100% is meaningless) made the rules list unserializable for anyone who had scaled a budget by more.",
                                        "minimum": 1,
                                        "maximum": 1000,
                                        "type": "number"
                                      },
                                      "pct": {
                                        "description": "Legacy template alias for `percentage`; accepted for seeded rule templates.",
                                        "minimum": 1,
                                        "maximum": 1000,
                                        "type": "number"
                                      }
                                    }
                                  }
                                }
                              },
                              {
                                "additionalProperties": false,
                                "type": "object",
                                "required": [
                                  "type"
                                ],
                                "properties": {
                                  "type": {
                                    "description": "Decrease campaign/adset budget by `params.percentage` percent.",
                                    "type": "string",
                                    "enum": [
                                      "decrease_budget_pct"
                                    ]
                                  },
                                  "params": {
                                    "additionalProperties": false,
                                    "type": "object",
                                    "properties": {
                                      "percentage": {
                                        "description": "Percent change in [1, 100] (defaults to 20 if omitted at runtime). 0 is rejected because a 0% change is a no-op and the worker clamps it to 1 anyway — the schema makes that contract explicit.",
                                        "minimum": 1,
                                        "maximum": 100,
                                        "type": "number"
                                      },
                                      "pct": {
                                        "description": "Legacy template alias for `percentage`; accepted for seeded rule templates.",
                                        "minimum": 1,
                                        "maximum": 100,
                                        "type": "number"
                                      }
                                    }
                                  }
                                }
                              },
                              {
                                "additionalProperties": false,
                                "type": "object",
                                "required": [
                                  "type"
                                ],
                                "properties": {
                                  "type": {
                                    "description": "Relaunch the ad (duplicate + delete original). Only valid at ad level.",
                                    "type": "string",
                                    "enum": [
                                      "relaunch"
                                    ]
                                  },
                                  "params": {
                                    "$comment": "json-value",
                                    "description": "Arbitrary JSON value with nested arrays and objects."
                                  }
                                }
                              },
                              {
                                "additionalProperties": false,
                                "type": "object",
                                "required": [
                                  "type"
                                ],
                                "properties": {
                                  "type": {
                                    "description": "Send a notification but do not mutate anything on Meta.",
                                    "type": "string",
                                    "enum": [
                                      "notify_only"
                                    ]
                                  },
                                  "params": {
                                    "$comment": "json-value",
                                    "description": "Arbitrary JSON value with nested arrays and objects."
                                  }
                                }
                              },
                              {
                                "additionalProperties": false,
                                "type": "object",
                                "required": [
                                  "type",
                                  "platform",
                                  "entity_level"
                                ],
                                "properties": {
                                  "type": {
                                    "type": "string",
                                    "enum": [
                                      "PAUSE_TOP_SPEND_CAMPAIGN"
                                    ]
                                  },
                                  "platform": {
                                    "anyOf": [
                                      {
                                        "type": "string",
                                        "enum": [
                                          "META"
                                        ]
                                      },
                                      {
                                        "type": "string",
                                        "enum": [
                                          "GOOGLE"
                                        ]
                                      },
                                      {
                                        "type": "string",
                                        "enum": [
                                          "TIKTOK"
                                        ]
                                      },
                                      {
                                        "type": "string",
                                        "enum": [
                                          "TABOOLA"
                                        ]
                                      },
                                      {
                                        "type": "string",
                                        "enum": [
                                          "LINKEDIN"
                                        ]
                                      }
                                    ]
                                  },
                                  "entity_level": {
                                    "type": "string",
                                    "enum": [
                                      "campaign"
                                    ]
                                  }
                                }
                              },
                              {
                                "additionalProperties": false,
                                "type": "object",
                                "required": [
                                  "type",
                                  "platform",
                                  "entity_level",
                                  "pct"
                                ],
                                "properties": {
                                  "type": {
                                    "anyOf": [
                                      {
                                        "type": "string",
                                        "enum": [
                                          "INCREASE_BUDGET_PCT"
                                        ]
                                      },
                                      {
                                        "type": "string",
                                        "enum": [
                                          "DECREASE_BUDGET_PCT"
                                        ]
                                      }
                                    ]
                                  },
                                  "platform": {
                                    "anyOf": [
                                      {
                                        "type": "string",
                                        "enum": [
                                          "META"
                                        ]
                                      },
                                      {
                                        "type": "string",
                                        "enum": [
                                          "GOOGLE"
                                        ]
                                      },
                                      {
                                        "type": "string",
                                        "enum": [
                                          "TIKTOK"
                                        ]
                                      },
                                      {
                                        "type": "string",
                                        "enum": [
                                          "TABOOLA"
                                        ]
                                      },
                                      {
                                        "type": "string",
                                        "enum": [
                                          "LINKEDIN"
                                        ]
                                      }
                                    ]
                                  },
                                  "entity_level": {
                                    "type": "string",
                                    "enum": [
                                      "campaign"
                                    ]
                                  },
                                  "pct": {
                                    "minimum": 1,
                                    "maximum": 100,
                                    "type": "number"
                                  }
                                }
                              },
                              {
                                "additionalProperties": false,
                                "type": "object",
                                "required": [
                                  "type",
                                  "channel",
                                  "message_template"
                                ],
                                "properties": {
                                  "type": {
                                    "type": "string",
                                    "enum": [
                                      "NOTIFY_CHANNEL"
                                    ]
                                  },
                                  "channel": {
                                    "anyOf": [
                                      {
                                        "type": "string",
                                        "enum": [
                                          "in_app"
                                        ]
                                      },
                                      {
                                        "type": "string",
                                        "enum": [
                                          "email"
                                        ]
                                      },
                                      {
                                        "type": "string",
                                        "enum": [
                                          "telegram"
                                        ]
                                      }
                                    ]
                                  },
                                  "message_template": {
                                    "minLength": 1,
                                    "maxLength": 500,
                                    "type": "string"
                                  }
                                }
                              }
                            ]
                          },
                          {
                            "additionalProperties": true,
                            "description": "Rule action stored before the current schema; surfaced as-is so the list stays readable.",
                            "type": "object",
                            "required": [
                              "type"
                            ],
                            "properties": {
                              "type": {
                                "description": "Action discriminator as stored, including legacy spellings.",
                                "type": "string"
                              },
                              "params": {
                                "$comment": "json-value",
                                "description": "Arbitrary JSON value with nested arrays and objects."
                              }
                            }
                          }
                        ]
                      }
                    },
                    "schedule_type": {
                      "anyOf": [
                        {
                          "type": "string",
                          "enum": [
                            "interval"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "daily"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "daily_at_time"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "day_parting"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "custom"
                          ]
                        }
                      ]
                    },
                    "interval_minutes": {
                      "type": "integer"
                    },
                    "schedule_config": {
                      "description": "Schedule config as stored, tolerant of values written outside the strict request contract.",
                      "anyOf": [
                        {
                          "additionalProperties": false,
                          "description": "Optional schedule-specific rule configuration. `daily_at_time` uses `time`; `day_parting` uses `hours_of_day`/`days_of_week` and/or explicit `slots`.",
                          "type": "object",
                          "properties": {
                            "time": {
                              "description": "Daily evaluation time in HH:MM format. Runtime validation enforces 00:00-23:59.",
                              "type": "string"
                            },
                            "type": {
                              "type": "string",
                              "enum": [
                                "day_parting"
                              ]
                            },
                            "hours_of_day": {
                              "description": "Hours of day eligible for evaluation. Runtime validation enforces non-empty integers 0-23.",
                              "maxItems": 24,
                              "type": "array",
                              "items": {
                                "type": "number"
                              }
                            },
                            "days_of_week": {
                              "description": "Days of week eligible for evaluation, where 0 is Sunday and 6 is Saturday.",
                              "maxItems": 7,
                              "type": "array",
                              "items": {
                                "type": "number"
                              }
                            },
                            "slots": {
                              "description": "Explicit day/hour evaluation slots. Runtime validation enforces non-empty valid slots.",
                              "type": "array",
                              "items": {
                                "additionalProperties": false,
                                "type": "object",
                                "required": [
                                  "day",
                                  "hour"
                                ],
                                "properties": {
                                  "day": {
                                    "description": "Day of week, where 0 is Sunday and 6 is Saturday. Runtime validation enforces integer 0-6.",
                                    "type": "number"
                                  },
                                  "hour": {
                                    "description": "Hour of day in 24-hour format. Runtime validation enforces integer 0-23.",
                                    "type": "number"
                                  }
                                }
                              }
                            },
                            "timezone": {
                              "minLength": 1,
                              "maxLength": 100,
                              "type": "string"
                            }
                          }
                        },
                        {
                          "additionalProperties": true,
                          "description": "Schedule config stored before/around the current contract; surfaced as-is.",
                          "type": "object",
                          "properties": {
                            "time": {
                              "description": "Daily evaluation time as stored.",
                              "type": "string"
                            },
                            "type": {
                              "description": "Schedule discriminator as stored.",
                              "type": "string"
                            },
                            "hours_of_day": {
                              "description": "Hours as stored.",
                              "type": "array",
                              "items": {
                                "type": "number"
                              }
                            },
                            "days_of_week": {
                              "description": "Days as stored.",
                              "type": "array",
                              "items": {
                                "type": "number"
                              }
                            },
                            "slots": {
                              "description": "Day/hour slots as stored.",
                              "type": "array",
                              "items": {
                                "additionalProperties": true,
                                "type": "object",
                                "properties": {
                                  "day": {
                                    "type": "number"
                                  },
                                  "hour": {
                                    "type": "number"
                                  }
                                }
                              }
                            },
                            "timezone": {
                              "description": "Timezone as stored.",
                              "type": "string"
                            }
                          }
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "timezone": {
                      "type": "string"
                    },
                    "cooldown_minutes": {
                      "type": "integer"
                    },
                    "max_executions_per_day": {
                      "type": "integer"
                    },
                    "budget_change_limit_pct": {
                      "anyOf": [
                        {
                          "type": "number"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "budget_daily_cap": {
                      "anyOf": [
                        {
                          "type": "number"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "notify_on_execution": {
                      "type": "boolean"
                    },
                    "notify_channels": {
                      "description": "Notify channels as stored, tolerant of values written outside the strict request contract.",
                      "anyOf": [
                        {
                          "additionalProperties": false,
                          "description": "Notification channels used when notify_on_execution is enabled.",
                          "type": "object",
                          "properties": {
                            "email": {
                              "type": "boolean"
                            },
                            "in_app": {
                              "type": "boolean"
                            },
                            "telegram": {
                              "type": "boolean"
                            }
                          }
                        },
                        {
                          "additionalProperties": true,
                          "description": "Notify channels stored before/around the current contract; surfaced as-is.",
                          "type": "object",
                          "properties": {
                            "email": {
                              "type": "boolean"
                            },
                            "in_app": {
                              "type": "boolean"
                            },
                            "telegram": {
                              "type": "boolean"
                            }
                          }
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "platforms": {
                      "type": "array",
                      "items": {
                        "minLength": 1,
                        "maxLength": 40,
                        "type": "string"
                      }
                    },
                    "priority": {
                      "type": "integer"
                    },
                    "template_id": {
                      "anyOf": [
                        {
                          "format": "uuid",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "last_evaluated_at": {
                      "anyOf": [
                        {
                          "format": "date-time",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "last_executed_at": {
                      "anyOf": [
                        {
                          "format": "date-time",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "execution_count": {
                      "type": "integer"
                    },
                    "error_count": {
                      "type": "integer"
                    },
                    "last_error": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "auto_paused_at": {
                      "anyOf": [
                        {
                          "format": "date-time",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "auto_pause_reason": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "cb_reset_after": {
                      "anyOf": [
                        {
                          "format": "date-time",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "created_at": {
                      "format": "date-time",
                      "type": "string"
                    },
                    "updated_at": {
                      "format": "date-time",
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "integer"
                    },
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "details": {
                      "type": "array",
                      "items": {
                        "additionalProperties": false,
                        "type": "object",
                        "required": [
                          "code",
                          "field",
                          "message"
                        ],
                        "properties": {
                          "code": {
                            "type": "string"
                          },
                          "field": {
                            "type": "string"
                          },
                          "message": {
                            "type": "string"
                          }
                        }
                      }
                    },
                    "validation": {
                      "type": "array",
                      "items": {
                        "additionalProperties": true,
                        "description": "AJV validation error item returned by Fastify for invalid params, querystrings, or bodies.",
                        "type": "object",
                        "properties": {
                          "instancePath": {
                            "type": "string"
                          },
                          "schemaPath": {
                            "type": "string"
                          },
                          "keyword": {
                            "type": "string"
                          },
                          "params": {
                            "type": "object",
                            "additionalProperties": {
                              "$comment": "json-value",
                              "description": "Arbitrary JSON value with nested arrays and objects."
                            }
                          },
                          "message": {
                            "type": "string"
                          }
                        }
                      }
                    },
                    "validationContext": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "integer"
                    },
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "integer"
                    },
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "integer"
                    },
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/rules/{id}/executions": {
      "get": {
        "operationId": "listRuleExecutions",
        "summary": "List rule executions",
        "tags": [
          "rules"
        ],
        "description": "Returns a paginated list of execution history for a specific automation rule.",
        "parameters": [
          {
            "schema": {
              "minimum": 1,
              "type": "integer"
            },
            "in": "query",
            "name": "page",
            "required": false
          },
          {
            "schema": {
              "minimum": 1,
              "maximum": 100,
              "type": "integer"
            },
            "in": "query",
            "name": "page_size",
            "required": false
          },
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "items",
                    "total",
                    "page",
                    "page_size"
                  ],
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "additionalProperties": true,
                        "description": "Row from automation_rule_execution.",
                        "type": "object",
                        "required": [
                          "id",
                          "rule_id",
                          "status",
                          "entities_evaluated",
                          "entities_matched",
                          "entities_acted",
                          "entities_skipped",
                          "entities_errored",
                          "details",
                          "error_message",
                          "started_at",
                          "completed_at",
                          "duration_ms",
                          "metrics_snapshot"
                        ],
                        "properties": {
                          "id": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "rule_id": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "status": {
                            "anyOf": [
                              {
                                "type": "string",
                                "enum": [
                                  "evaluated"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "executed"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "skipped"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "error"
                                ]
                              }
                            ]
                          },
                          "entities_evaluated": {
                            "type": "integer"
                          },
                          "entities_matched": {
                            "type": "integer"
                          },
                          "entities_acted": {
                            "type": "integer"
                          },
                          "entities_skipped": {
                            "type": "integer"
                          },
                          "entities_errored": {
                            "type": "integer"
                          },
                          "details": {
                            "anyOf": [
                              {
                                "$comment": "json-value",
                                "description": "Arbitrary JSON value with nested arrays and objects."
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "error_message": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "started_at": {
                            "format": "date-time",
                            "type": "string"
                          },
                          "completed_at": {
                            "anyOf": [
                              {
                                "format": "date-time",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "duration_ms": {
                            "anyOf": [
                              {
                                "type": "integer"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "metrics_snapshot": {
                            "anyOf": [
                              {
                                "$comment": "json-value",
                                "description": "Arbitrary JSON value with nested arrays and objects."
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "matched_count": {
                            "type": "integer"
                          },
                          "actions_applied": {
                            "type": "integer"
                          },
                          "error": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "trigger": {
                            "type": "string"
                          }
                        }
                      }
                    },
                    "total": {
                      "type": "integer"
                    },
                    "page": {
                      "type": "integer"
                    },
                    "page_size": {
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "integer"
                    },
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "details": {
                      "type": "array",
                      "items": {
                        "additionalProperties": false,
                        "type": "object",
                        "required": [
                          "code",
                          "field",
                          "message"
                        ],
                        "properties": {
                          "code": {
                            "type": "string"
                          },
                          "field": {
                            "type": "string"
                          },
                          "message": {
                            "type": "string"
                          }
                        }
                      }
                    },
                    "validation": {
                      "type": "array",
                      "items": {
                        "additionalProperties": true,
                        "description": "AJV validation error item returned by Fastify for invalid params, querystrings, or bodies.",
                        "type": "object",
                        "properties": {
                          "instancePath": {
                            "type": "string"
                          },
                          "schemaPath": {
                            "type": "string"
                          },
                          "keyword": {
                            "type": "string"
                          },
                          "params": {
                            "type": "object",
                            "additionalProperties": {
                              "$comment": "json-value",
                              "description": "Arbitrary JSON value with nested arrays and objects."
                            }
                          },
                          "message": {
                            "type": "string"
                          }
                        }
                      }
                    },
                    "validationContext": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "integer"
                    },
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "integer"
                    },
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/rules/preview": {
      "post": {
        "operationId": "previewAutomationRule",
        "summary": "Preview rule evaluation (dry-run)",
        "tags": [
          "rules"
        ],
        "description": "Performs a dry-run evaluation of a rule. Can preview an existing rule by ID or evaluate inline conditions without persisting.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "properties": {
                  "rule_id": {
                    "format": "uuid",
                    "type": "string"
                  },
                  "entity_level": {
                    "anyOf": [
                      {
                        "type": "string",
                        "enum": [
                          "campaign"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "adset"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "ad"
                        ]
                      }
                    ]
                  },
                  "ad_account_ids": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  },
                  "entity_filter": {
                    "anyOf": [
                      {
                        "additionalProperties": false,
                        "description": "Optional entity filters applied before condition evaluation.",
                        "type": "object",
                        "properties": {
                          "name_contains": {
                            "description": "Case-insensitive substring that must be present in the entity name.",
                            "minLength": 1,
                            "maxLength": 200,
                            "type": "string"
                          },
                          "name_not_contains": {
                            "description": "Case-insensitive substring that must not be present in the entity name.",
                            "minLength": 1,
                            "maxLength": 200,
                            "type": "string"
                          },
                          "status_in": {
                            "description": "Entity statuses to include. Route validation checks whether each status is allowed for the selected entity level.",
                            "minItems": 1,
                            "maxItems": 20,
                            "type": "array",
                            "items": {
                              "minLength": 1,
                              "maxLength": 80,
                              "type": "string"
                            }
                          },
                          "account_mode": {
                            "description": "Ad-account scope intent. \"selected\" means the rule must be restricted to ad_account_ids; combined with an empty ad_account_ids the evaluator matches no entities (it does NOT silently fall back to all accounts). \"all\" (or omitted) evaluates every accessible account.",
                            "anyOf": [
                              {
                                "type": "string",
                                "enum": [
                                  "all"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "selected"
                                ]
                              }
                            ]
                          }
                        }
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "condition_logic": {
                    "anyOf": [
                      {
                        "type": "string",
                        "enum": [
                          "AND"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "OR"
                        ]
                      }
                    ]
                  },
                  "conditions": {
                    "description": "Ordered list of conditions combined via `condition_logic` (AND/OR).",
                    "type": "array",
                    "items": {
                      "anyOf": [
                        {
                          "additionalProperties": false,
                          "description": "Single metric threshold evaluated against entity insights.",
                          "type": "object",
                          "required": [
                            "metric",
                            "operator",
                            "time_range",
                            "value"
                          ],
                          "properties": {
                            "metric": {
                              "description": "Metric key (platform metric, derived metric, or action-type KPI from action_types_canonical).",
                              "minLength": 1,
                              "type": "string"
                            },
                            "operator": {
                              "description": "Comparison operator. `between`/`not_between` require both `value` and `value2`; `increased_pct`/`decreased_pct` compare the current `time_range` against the immediately preceding period of equal duration.",
                              "anyOf": [
                                {
                                  "type": "string",
                                  "enum": [
                                    "gt"
                                  ]
                                },
                                {
                                  "type": "string",
                                  "enum": [
                                    "lt"
                                  ]
                                },
                                {
                                  "type": "string",
                                  "enum": [
                                    "gte"
                                  ]
                                },
                                {
                                  "type": "string",
                                  "enum": [
                                    "lte"
                                  ]
                                },
                                {
                                  "type": "string",
                                  "enum": [
                                    "eq"
                                  ]
                                },
                                {
                                  "type": "string",
                                  "enum": [
                                    "neq"
                                  ]
                                },
                                {
                                  "type": "string",
                                  "enum": [
                                    "between"
                                  ]
                                },
                                {
                                  "type": "string",
                                  "enum": [
                                    "not_between"
                                  ]
                                },
                                {
                                  "type": "string",
                                  "enum": [
                                    "increased_pct"
                                  ]
                                },
                                {
                                  "type": "string",
                                  "enum": [
                                    "decreased_pct"
                                  ]
                                }
                              ]
                            },
                            "time_range": {
                              "description": "Time window over which the metric is aggregated.",
                              "anyOf": [
                                {
                                  "type": "string",
                                  "enum": [
                                    "today"
                                  ]
                                },
                                {
                                  "type": "string",
                                  "enum": [
                                    "yesterday"
                                  ]
                                },
                                {
                                  "type": "string",
                                  "enum": [
                                    "last_3d"
                                  ]
                                },
                                {
                                  "type": "string",
                                  "enum": [
                                    "last_7d"
                                  ]
                                },
                                {
                                  "type": "string",
                                  "enum": [
                                    "last_14d"
                                  ]
                                },
                                {
                                  "type": "string",
                                  "enum": [
                                    "last_30d"
                                  ]
                                }
                              ]
                            },
                            "value": {
                              "description": "Primary threshold. Coerced to Number at evaluation time.",
                              "anyOf": [
                                {
                                  "type": "number"
                                },
                                {
                                  "type": "string"
                                }
                              ]
                            },
                            "value2": {
                              "description": "Secondary threshold (required for `between` / `not_between`).",
                              "anyOf": [
                                {
                                  "type": "number"
                                },
                                {
                                  "type": "string"
                                }
                              ]
                            },
                            "trend_window": {
                              "description": "Time window over which the metric is aggregated.",
                              "anyOf": [
                                {
                                  "type": "string",
                                  "enum": [
                                    "today"
                                  ]
                                },
                                {
                                  "type": "string",
                                  "enum": [
                                    "yesterday"
                                  ]
                                },
                                {
                                  "type": "string",
                                  "enum": [
                                    "last_3d"
                                  ]
                                },
                                {
                                  "type": "string",
                                  "enum": [
                                    "last_7d"
                                  ]
                                },
                                {
                                  "type": "string",
                                  "enum": [
                                    "last_14d"
                                  ]
                                },
                                {
                                  "type": "string",
                                  "enum": [
                                    "last_30d"
                                  ]
                                }
                              ]
                            }
                          }
                        },
                        {
                          "additionalProperties": false,
                          "description": "Account-level comparison across two advertising platforms, or between one platform and a literal.",
                          "type": "object",
                          "required": [
                            "type",
                            "left",
                            "operator",
                            "right"
                          ],
                          "properties": {
                            "type": {
                              "type": "string",
                              "enum": [
                                "cross_platform_comparison"
                              ]
                            },
                            "left": {
                              "anyOf": [
                                {
                                  "additionalProperties": false,
                                  "type": "object",
                                  "required": [
                                    "type",
                                    "platform",
                                    "metric"
                                  ],
                                  "properties": {
                                    "type": {
                                      "type": "string",
                                      "enum": [
                                        "platform_metric"
                                      ]
                                    },
                                    "platform": {
                                      "anyOf": [
                                        {
                                          "type": "string",
                                          "enum": [
                                            "META"
                                          ]
                                        },
                                        {
                                          "type": "string",
                                          "enum": [
                                            "GOOGLE"
                                          ]
                                        },
                                        {
                                          "type": "string",
                                          "enum": [
                                            "TIKTOK"
                                          ]
                                        },
                                        {
                                          "type": "string",
                                          "enum": [
                                            "TABOOLA"
                                          ]
                                        },
                                        {
                                          "type": "string",
                                          "enum": [
                                            "LINKEDIN"
                                          ]
                                        }
                                      ]
                                    },
                                    "metric": {
                                      "anyOf": [
                                        {
                                          "type": "string",
                                          "enum": [
                                            "spend"
                                          ]
                                        },
                                        {
                                          "type": "string",
                                          "enum": [
                                            "spend_pct"
                                          ]
                                        },
                                        {
                                          "type": "string",
                                          "enum": [
                                            "impressions"
                                          ]
                                        },
                                        {
                                          "type": "string",
                                          "enum": [
                                            "clicks"
                                          ]
                                        },
                                        {
                                          "type": "string",
                                          "enum": [
                                            "ctr"
                                          ]
                                        },
                                        {
                                          "type": "string",
                                          "enum": [
                                            "cpc"
                                          ]
                                        },
                                        {
                                          "type": "string",
                                          "enum": [
                                            "cpm"
                                          ]
                                        },
                                        {
                                          "type": "string",
                                          "enum": [
                                            "purchases"
                                          ]
                                        },
                                        {
                                          "type": "string",
                                          "enum": [
                                            "purchase_value"
                                          ]
                                        },
                                        {
                                          "type": "string",
                                          "enum": [
                                            "conversions"
                                          ]
                                        },
                                        {
                                          "type": "string",
                                          "enum": [
                                            "roas"
                                          ]
                                        },
                                        {
                                          "type": "string",
                                          "enum": [
                                            "cpa"
                                          ]
                                        },
                                        {
                                          "type": "string",
                                          "enum": [
                                            "cpl"
                                          ]
                                        }
                                      ]
                                    },
                                    "level": {
                                      "type": "string",
                                      "enum": [
                                        "account"
                                      ]
                                    },
                                    "timeframe_days": {
                                      "minimum": 1,
                                      "maximum": 90,
                                      "type": "integer"
                                    },
                                    "multiplier": {
                                      "minimum": 0,
                                      "type": "number"
                                    }
                                  }
                                },
                                {
                                  "additionalProperties": false,
                                  "type": "object",
                                  "required": [
                                    "type",
                                    "value"
                                  ],
                                  "properties": {
                                    "type": {
                                      "type": "string",
                                      "enum": [
                                        "literal"
                                      ]
                                    },
                                    "value": {
                                      "type": "number"
                                    }
                                  }
                                }
                              ]
                            },
                            "operator": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "enum": [
                                    "greater_than"
                                  ]
                                },
                                {
                                  "type": "string",
                                  "enum": [
                                    "less_than"
                                  ]
                                },
                                {
                                  "type": "string",
                                  "enum": [
                                    "greater_or_equal"
                                  ]
                                },
                                {
                                  "type": "string",
                                  "enum": [
                                    "less_or_equal"
                                  ]
                                },
                                {
                                  "type": "string",
                                  "enum": [
                                    "equal"
                                  ]
                                }
                              ]
                            },
                            "right": {
                              "anyOf": [
                                {
                                  "additionalProperties": false,
                                  "type": "object",
                                  "required": [
                                    "type",
                                    "platform",
                                    "metric"
                                  ],
                                  "properties": {
                                    "type": {
                                      "type": "string",
                                      "enum": [
                                        "platform_metric"
                                      ]
                                    },
                                    "platform": {
                                      "anyOf": [
                                        {
                                          "type": "string",
                                          "enum": [
                                            "META"
                                          ]
                                        },
                                        {
                                          "type": "string",
                                          "enum": [
                                            "GOOGLE"
                                          ]
                                        },
                                        {
                                          "type": "string",
                                          "enum": [
                                            "TIKTOK"
                                          ]
                                        },
                                        {
                                          "type": "string",
                                          "enum": [
                                            "TABOOLA"
                                          ]
                                        },
                                        {
                                          "type": "string",
                                          "enum": [
                                            "LINKEDIN"
                                          ]
                                        }
                                      ]
                                    },
                                    "metric": {
                                      "anyOf": [
                                        {
                                          "type": "string",
                                          "enum": [
                                            "spend"
                                          ]
                                        },
                                        {
                                          "type": "string",
                                          "enum": [
                                            "spend_pct"
                                          ]
                                        },
                                        {
                                          "type": "string",
                                          "enum": [
                                            "impressions"
                                          ]
                                        },
                                        {
                                          "type": "string",
                                          "enum": [
                                            "clicks"
                                          ]
                                        },
                                        {
                                          "type": "string",
                                          "enum": [
                                            "ctr"
                                          ]
                                        },
                                        {
                                          "type": "string",
                                          "enum": [
                                            "cpc"
                                          ]
                                        },
                                        {
                                          "type": "string",
                                          "enum": [
                                            "cpm"
                                          ]
                                        },
                                        {
                                          "type": "string",
                                          "enum": [
                                            "purchases"
                                          ]
                                        },
                                        {
                                          "type": "string",
                                          "enum": [
                                            "purchase_value"
                                          ]
                                        },
                                        {
                                          "type": "string",
                                          "enum": [
                                            "conversions"
                                          ]
                                        },
                                        {
                                          "type": "string",
                                          "enum": [
                                            "roas"
                                          ]
                                        },
                                        {
                                          "type": "string",
                                          "enum": [
                                            "cpa"
                                          ]
                                        },
                                        {
                                          "type": "string",
                                          "enum": [
                                            "cpl"
                                          ]
                                        }
                                      ]
                                    },
                                    "level": {
                                      "type": "string",
                                      "enum": [
                                        "account"
                                      ]
                                    },
                                    "timeframe_days": {
                                      "minimum": 1,
                                      "maximum": 90,
                                      "type": "integer"
                                    },
                                    "multiplier": {
                                      "minimum": 0,
                                      "type": "number"
                                    }
                                  }
                                },
                                {
                                  "additionalProperties": false,
                                  "type": "object",
                                  "required": [
                                    "type",
                                    "value"
                                  ],
                                  "properties": {
                                    "type": {
                                      "type": "string",
                                      "enum": [
                                        "literal"
                                      ]
                                    },
                                    "value": {
                                      "type": "number"
                                    }
                                  }
                                }
                              ]
                            }
                          }
                        }
                      ]
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Dry-run evaluator output. Envelope is stable; matched_entities content varies by entity_level (campaign/adset/ad).",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "description": "Dry-run evaluator output. Envelope is stable; matched_entities content varies by entity_level (campaign/adset/ad).",
                  "type": "object",
                  "required": [
                    "entities_acted",
                    "entities_evaluated",
                    "entities_matched",
                    "entities_skipped",
                    "matched_entities"
                  ],
                  "properties": {
                    "entities_acted": {
                      "description": "Entities that would have an action applied.",
                      "type": "integer"
                    },
                    "entities_evaluated": {
                      "description": "Total entities considered by the evaluator.",
                      "type": "integer"
                    },
                    "entities_matched": {
                      "description": "Entities matching all rule conditions.",
                      "type": "integer"
                    },
                    "entities_skipped": {
                      "description": "Entities skipped (already acted on, filters, etc).",
                      "type": "integer"
                    },
                    "matched_entities": {
                      "type": "array",
                      "items": {
                        "additionalProperties": true,
                        "type": "object",
                        "required": [
                          "entity_id",
                          "entity_name",
                          "entity_status",
                          "ad_account_id",
                          "metrics"
                        ],
                        "properties": {
                          "entity_id": {
                            "type": "string"
                          },
                          "entity_name": {
                            "type": "string"
                          },
                          "entity_status": {
                            "type": "string"
                          },
                          "ad_account_id": {
                            "type": "string"
                          },
                          "metrics": {
                            "description": "KPIs evaluated for this entity (key → numeric value).",
                            "type": "object",
                            "additionalProperties": {
                              "type": "number"
                            }
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "integer"
                    },
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "details": {
                      "type": "array",
                      "items": {
                        "additionalProperties": false,
                        "type": "object",
                        "required": [
                          "code",
                          "field",
                          "message"
                        ],
                        "properties": {
                          "code": {
                            "type": "string"
                          },
                          "field": {
                            "type": "string"
                          },
                          "message": {
                            "type": "string"
                          }
                        }
                      }
                    },
                    "validation": {
                      "type": "array",
                      "items": {
                        "additionalProperties": true,
                        "description": "AJV validation error item returned by Fastify for invalid params, querystrings, or bodies.",
                        "type": "object",
                        "properties": {
                          "instancePath": {
                            "type": "string"
                          },
                          "schemaPath": {
                            "type": "string"
                          },
                          "keyword": {
                            "type": "string"
                          },
                          "params": {
                            "type": "object",
                            "additionalProperties": {
                              "$comment": "json-value",
                              "description": "Arbitrary JSON value with nested arrays and objects."
                            }
                          },
                          "message": {
                            "type": "string"
                          }
                        }
                      }
                    },
                    "validationContext": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "integer"
                    },
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "integer"
                    },
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "integer"
                    },
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/search": {
      "get": {
        "operationId": "getApiV1Search",
        "summary": "Universal search",
        "tags": [
          "search"
        ],
        "description": "Search across campaigns, ad sets, and ads for the command palette",
        "parameters": [
          {
            "schema": {
              "minLength": 2,
              "maxLength": 200,
              "type": "string"
            },
            "in": "query",
            "name": "q",
            "required": true
          },
          {
            "schema": {
              "type": "array",
              "items": {
                "anyOf": [
                  {
                    "type": "string",
                    "enum": [
                      "campaign"
                    ]
                  },
                  {
                    "type": "string",
                    "enum": [
                      "adSet"
                    ]
                  },
                  {
                    "type": "string",
                    "enum": [
                      "ad"
                    ]
                  }
                ]
              }
            },
            "in": "query",
            "name": "kinds",
            "required": false
          },
          {
            "schema": {
              "minimum": 1,
              "maximum": 20,
              "default": 5,
              "type": "integer"
            },
            "in": "query",
            "name": "limit",
            "required": false
          }
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "results",
                    "meta"
                  ],
                  "properties": {
                    "results": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "id",
                          "name",
                          "status",
                          "entityKind",
                          "parentId",
                          "parentName",
                          "accountId",
                          "accountName",
                          "deepLink"
                        ],
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "name": {
                            "type": "string"
                          },
                          "status": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "entityKind": {
                            "type": "string"
                          },
                          "parentId": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "parentName": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "accountId": {
                            "type": "string"
                          },
                          "accountName": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "deepLink": {
                            "type": "string"
                          }
                        }
                      }
                    },
                    "meta": {
                      "type": "object",
                      "required": [
                        "elapsedMs",
                        "totalCount"
                      ],
                      "properties": {
                        "elapsedMs": {
                          "type": "number"
                        },
                        "totalCount": {
                          "type": "integer"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/seasonal-patterns": {
      "get": {
        "operationId": "getApiV1SeasonalPatterns",
        "summary": "List seasonal performance patterns",
        "tags": [
          "seasonal-patterns"
        ],
        "description": "Returns detected seasonal peaks and data-quality information for the accessible team scope.",
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "account_id",
            "required": false
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "metric",
            "required": false
          },
          {
            "schema": {
              "type": "number"
            },
            "in": "query",
            "name": "limit",
            "required": false
          }
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "dataQualityScore",
                    "detectedPeaks",
                    "insufficientData",
                    "minimumDataDays",
                    "upcomingPeaks"
                  ],
                  "properties": {
                    "dataQualityScore": {
                      "type": "integer"
                    },
                    "detectedPeaks": {
                      "type": "array",
                      "items": {
                        "additionalProperties": false,
                        "type": "object",
                        "required": [
                          "id",
                          "team_id",
                          "session_id",
                          "ad_account_id",
                          "metric",
                          "period_label",
                          "period_start_mmdd",
                          "period_end_mmdd",
                          "avg_change_pct",
                          "confidence",
                          "data_points",
                          "last_computed_at"
                        ],
                        "properties": {
                          "id": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "team_id": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "session_id": {
                            "anyOf": [
                              {
                                "format": "uuid",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "ad_account_id": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "metric": {
                            "type": "string"
                          },
                          "period_label": {
                            "type": "string"
                          },
                          "period_start_mmdd": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "period_end_mmdd": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "avg_change_pct": {
                            "anyOf": [
                              {
                                "anyOf": [
                                  {
                                    "type": "number"
                                  },
                                  {
                                    "type": "string"
                                  }
                                ]
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "confidence": {
                            "type": "string"
                          },
                          "data_points": {
                            "type": "integer"
                          },
                          "last_computed_at": {
                            "format": "date-time",
                            "type": "string"
                          }
                        }
                      }
                    },
                    "insufficientData": {
                      "type": "boolean"
                    },
                    "minimumDataDays": {
                      "type": "integer"
                    },
                    "upcomingPeaks": {
                      "type": "array",
                      "items": {
                        "additionalProperties": false,
                        "type": "object",
                        "required": [
                          "id",
                          "team_id",
                          "session_id",
                          "ad_account_id",
                          "metric",
                          "period_label",
                          "period_start_mmdd",
                          "period_end_mmdd",
                          "avg_change_pct",
                          "confidence",
                          "data_points",
                          "last_computed_at"
                        ],
                        "properties": {
                          "id": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "team_id": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "session_id": {
                            "anyOf": [
                              {
                                "format": "uuid",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "ad_account_id": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "metric": {
                            "type": "string"
                          },
                          "period_label": {
                            "type": "string"
                          },
                          "period_start_mmdd": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "period_end_mmdd": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "avg_change_pct": {
                            "anyOf": [
                              {
                                "anyOf": [
                                  {
                                    "type": "number"
                                  },
                                  {
                                    "type": "string"
                                  }
                                ]
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "confidence": {
                            "type": "string"
                          },
                          "data_points": {
                            "type": "integer"
                          },
                          "last_computed_at": {
                            "format": "date-time",
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "error_code": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/seasonal-patterns/compute": {
      "post": {
        "operationId": "postApiV1SeasonalPatternsCompute",
        "summary": "Compute seasonal performance patterns",
        "tags": [
          "seasonal-patterns"
        ],
        "description": "Computes and stores seasonal performance patterns from historical campaign daily insights.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "dataDays",
                    "insufficientData",
                    "items"
                  ],
                  "properties": {
                    "dataDays": {
                      "type": "integer"
                    },
                    "insufficientData": {
                      "type": "boolean"
                    },
                    "items": {
                      "type": "array",
                      "items": {
                        "additionalProperties": false,
                        "type": "object",
                        "required": [
                          "id",
                          "team_id",
                          "session_id",
                          "ad_account_id",
                          "metric",
                          "period_label",
                          "period_start_mmdd",
                          "period_end_mmdd",
                          "avg_change_pct",
                          "confidence",
                          "data_points",
                          "last_computed_at"
                        ],
                        "properties": {
                          "id": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "team_id": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "session_id": {
                            "anyOf": [
                              {
                                "format": "uuid",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "ad_account_id": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "metric": {
                            "type": "string"
                          },
                          "period_label": {
                            "type": "string"
                          },
                          "period_start_mmdd": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "period_end_mmdd": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "avg_change_pct": {
                            "anyOf": [
                              {
                                "anyOf": [
                                  {
                                    "type": "number"
                                  },
                                  {
                                    "type": "string"
                                  }
                                ]
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "confidence": {
                            "type": "string"
                          },
                          "data_points": {
                            "type": "integer"
                          },
                          "last_computed_at": {
                            "format": "date-time",
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "error_code": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/market-intelligence/seasonal-patterns": {
      "get": {
        "operationId": "getApiV1MarketIntelligenceSeasonalPatterns",
        "summary": "List seasonal performance patterns by market-intelligence alias",
        "tags": [
          "seasonal-patterns"
        ],
        "description": "Legacy alias returning detected seasonal peaks and data-quality information.",
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "account_id",
            "required": false
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "metric",
            "required": false
          },
          {
            "schema": {
              "type": "number"
            },
            "in": "query",
            "name": "limit",
            "required": false
          }
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "dataQualityScore",
                    "detectedPeaks",
                    "insufficientData",
                    "minimumDataDays",
                    "upcomingPeaks"
                  ],
                  "properties": {
                    "dataQualityScore": {
                      "type": "integer"
                    },
                    "detectedPeaks": {
                      "type": "array",
                      "items": {
                        "additionalProperties": false,
                        "type": "object",
                        "required": [
                          "id",
                          "team_id",
                          "session_id",
                          "ad_account_id",
                          "metric",
                          "period_label",
                          "period_start_mmdd",
                          "period_end_mmdd",
                          "avg_change_pct",
                          "confidence",
                          "data_points",
                          "last_computed_at"
                        ],
                        "properties": {
                          "id": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "team_id": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "session_id": {
                            "anyOf": [
                              {
                                "format": "uuid",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "ad_account_id": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "metric": {
                            "type": "string"
                          },
                          "period_label": {
                            "type": "string"
                          },
                          "period_start_mmdd": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "period_end_mmdd": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "avg_change_pct": {
                            "anyOf": [
                              {
                                "anyOf": [
                                  {
                                    "type": "number"
                                  },
                                  {
                                    "type": "string"
                                  }
                                ]
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "confidence": {
                            "type": "string"
                          },
                          "data_points": {
                            "type": "integer"
                          },
                          "last_computed_at": {
                            "format": "date-time",
                            "type": "string"
                          }
                        }
                      }
                    },
                    "insufficientData": {
                      "type": "boolean"
                    },
                    "minimumDataDays": {
                      "type": "integer"
                    },
                    "upcomingPeaks": {
                      "type": "array",
                      "items": {
                        "additionalProperties": false,
                        "type": "object",
                        "required": [
                          "id",
                          "team_id",
                          "session_id",
                          "ad_account_id",
                          "metric",
                          "period_label",
                          "period_start_mmdd",
                          "period_end_mmdd",
                          "avg_change_pct",
                          "confidence",
                          "data_points",
                          "last_computed_at"
                        ],
                        "properties": {
                          "id": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "team_id": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "session_id": {
                            "anyOf": [
                              {
                                "format": "uuid",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "ad_account_id": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "metric": {
                            "type": "string"
                          },
                          "period_label": {
                            "type": "string"
                          },
                          "period_start_mmdd": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "period_end_mmdd": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "avg_change_pct": {
                            "anyOf": [
                              {
                                "anyOf": [
                                  {
                                    "type": "number"
                                  },
                                  {
                                    "type": "string"
                                  }
                                ]
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "confidence": {
                            "type": "string"
                          },
                          "data_points": {
                            "type": "integer"
                          },
                          "last_computed_at": {
                            "format": "date-time",
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "error_code": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/market-intelligence/seasonal-patterns/compute": {
      "post": {
        "operationId": "postApiV1MarketIntelligenceSeasonalPatternsCompute",
        "summary": "Compute seasonal patterns by market-intelligence alias",
        "tags": [
          "seasonal-patterns"
        ],
        "description": "Legacy alias that computes and stores seasonal performance patterns.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "dataDays",
                    "insufficientData",
                    "items"
                  ],
                  "properties": {
                    "dataDays": {
                      "type": "integer"
                    },
                    "insufficientData": {
                      "type": "boolean"
                    },
                    "items": {
                      "type": "array",
                      "items": {
                        "additionalProperties": false,
                        "type": "object",
                        "required": [
                          "id",
                          "team_id",
                          "session_id",
                          "ad_account_id",
                          "metric",
                          "period_label",
                          "period_start_mmdd",
                          "period_end_mmdd",
                          "avg_change_pct",
                          "confidence",
                          "data_points",
                          "last_computed_at"
                        ],
                        "properties": {
                          "id": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "team_id": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "session_id": {
                            "anyOf": [
                              {
                                "format": "uuid",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "ad_account_id": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "metric": {
                            "type": "string"
                          },
                          "period_label": {
                            "type": "string"
                          },
                          "period_start_mmdd": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "period_end_mmdd": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "avg_change_pct": {
                            "anyOf": [
                              {
                                "anyOf": [
                                  {
                                    "type": "number"
                                  },
                                  {
                                    "type": "string"
                                  }
                                ]
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "confidence": {
                            "type": "string"
                          },
                          "data_points": {
                            "type": "integer"
                          },
                          "last_computed_at": {
                            "format": "date-time",
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "error_code": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/business-users": {
      "get": {
        "operationId": "getApiV1BusinessUsers",
        "summary": "Get business users for a business",
        "tags": [
          "permissions"
        ],
        "description": "Returns a list of human business users (excluding SYSTEM users) for the given Business Manager ID.",
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "business_id",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "items"
                  ],
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "id",
                          "name",
                          "email",
                          "role"
                        ],
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "name": {
                            "type": "string"
                          },
                          "email": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "role": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/ad-accounts/share-permissions": {
      "post": {
        "operationId": "postApiV1AdAccountsSharePermissions",
        "summary": "Share ad account permissions with business users",
        "tags": [
          "permissions"
        ],
        "description": "Assigns the specified permission level on one or more ad accounts to one or more business users.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "ad_account_ids",
                  "business_user_ids",
                  "business_id",
                  "permission_level"
                ],
                "properties": {
                  "ad_account_ids": {
                    "minItems": 1,
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  },
                  "business_user_ids": {
                    "minItems": 1,
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  },
                  "business_id": {
                    "type": "string"
                  },
                  "permission_level": {
                    "anyOf": [
                      {
                        "type": "string",
                        "enum": [
                          "FULL"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "ADVERTISE"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "ANALYZE"
                        ]
                      }
                    ]
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "results",
                    "total_success",
                    "total_failed"
                  ],
                  "properties": {
                    "results": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "asset_id",
                          "business_user_id",
                          "status"
                        ],
                        "properties": {
                          "asset_id": {
                            "type": "string"
                          },
                          "business_user_id": {
                            "type": "string"
                          },
                          "status": {
                            "anyOf": [
                              {
                                "type": "string",
                                "enum": [
                                  "SUCCESS"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "FAILED"
                                ]
                              }
                            ]
                          },
                          "error": {
                            "type": "string"
                          }
                        }
                      }
                    },
                    "total_success": {
                      "type": "integer"
                    },
                    "total_failed": {
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/fan-pages/share-permissions": {
      "post": {
        "operationId": "postApiV1FanPagesSharePermissions",
        "summary": "Share fan page permissions with business users",
        "tags": [
          "permissions"
        ],
        "description": "Assigns the specified permission level on one or more fan pages to one or more business users.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "fan_page_ids",
                  "business_user_ids",
                  "business_id",
                  "permission_level"
                ],
                "properties": {
                  "fan_page_ids": {
                    "minItems": 1,
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  },
                  "business_user_ids": {
                    "minItems": 1,
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  },
                  "business_id": {
                    "type": "string"
                  },
                  "permission_level": {
                    "anyOf": [
                      {
                        "type": "string",
                        "enum": [
                          "FULL"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "ADVERTISE"
                        ]
                      }
                    ]
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "results",
                    "total_success",
                    "total_failed"
                  ],
                  "properties": {
                    "results": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "asset_id",
                          "business_user_id",
                          "status"
                        ],
                        "properties": {
                          "asset_id": {
                            "type": "string"
                          },
                          "business_user_id": {
                            "type": "string"
                          },
                          "status": {
                            "anyOf": [
                              {
                                "type": "string",
                                "enum": [
                                  "SUCCESS"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "FAILED"
                                ]
                              }
                            ]
                          },
                          "error": {
                            "type": "string"
                          }
                        }
                      }
                    },
                    "total_success": {
                      "type": "integer"
                    },
                    "total_failed": {
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/shopify/webhooks/compliance": {
      "post": {
        "operationId": "postApiV1ShopifyWebhooksCompliance",
        "summary": "Receive Shopify compliance webhook",
        "tags": [
          "shopify"
        ],
        "description": "Verifies a Shopify GDPR compliance webhook topic from headers, stores an audit row, and queues asynchronous processing.",
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "status"
                  ],
                  "properties": {
                    "status": {
                      "type": "string",
                      "enum": [
                        "accepted"
                      ]
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ]
      }
    },
    "/api/v1/shopify/webhooks/compliance/customers-data-request": {
      "post": {
        "operationId": "postApiV1ShopifyWebhooksComplianceCustomersDataRequest",
        "summary": "Receive Shopify customers/data_request webhook",
        "tags": [
          "shopify"
        ],
        "description": "Verifies a Shopify GDPR compliance webhook for the fixed path topic, stores an audit row, and queues asynchronous processing.",
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "status"
                  ],
                  "properties": {
                    "status": {
                      "type": "string",
                      "enum": [
                        "accepted"
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ]
      }
    },
    "/api/v1/shopify/webhooks/compliance/customers-redact": {
      "post": {
        "operationId": "postApiV1ShopifyWebhooksComplianceCustomersRedact",
        "summary": "Receive Shopify customers/redact webhook",
        "tags": [
          "shopify"
        ],
        "description": "Verifies a Shopify GDPR compliance webhook for the fixed path topic, stores an audit row, and queues asynchronous processing.",
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "status"
                  ],
                  "properties": {
                    "status": {
                      "type": "string",
                      "enum": [
                        "accepted"
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ]
      }
    },
    "/api/v1/shopify/webhooks/compliance/shop-redact": {
      "post": {
        "operationId": "postApiV1ShopifyWebhooksComplianceShopRedact",
        "summary": "Receive Shopify shop/redact webhook",
        "tags": [
          "shopify"
        ],
        "description": "Verifies a Shopify GDPR compliance webhook for the fixed path topic, stores an audit row, and queues asynchronous processing.",
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "status"
                  ],
                  "properties": {
                    "status": {
                      "type": "string",
                      "enum": [
                        "accepted"
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ]
      }
    },
    "/api/v1/shopify/revenue/summary": {
      "get": {
        "operationId": "getApiV1ShopifyRevenueSummary",
        "summary": "Get Shopify revenue summary",
        "tags": [
          "shopify",
          "commerce"
        ],
        "description": "Returns date-range totals for Shopify revenue, profit, COGS, refunds, attribution counts, and average order metrics.",
        "parameters": [
          {
            "schema": {
              "format": "date",
              "type": "string"
            },
            "in": "query",
            "name": "from",
            "required": true
          },
          {
            "schema": {
              "format": "date",
              "type": "string"
            },
            "in": "query",
            "name": "to",
            "required": true
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "total_revenue",
                    "total_profit",
                    "total_cogs",
                    "total_refunds",
                    "total_orders",
                    "attributed_orders",
                    "unattributed_orders",
                    "attribution_rate_pct",
                    "avg_order_value",
                    "avg_profit_margin_pct",
                    "currency"
                  ],
                  "properties": {
                    "total_revenue": {
                      "type": "number"
                    },
                    "total_profit": {
                      "anyOf": [
                        {
                          "type": "number"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "total_cogs": {
                      "type": "number"
                    },
                    "total_refunds": {
                      "type": "number"
                    },
                    "total_orders": {
                      "type": "number"
                    },
                    "attributed_orders": {
                      "type": "number"
                    },
                    "unattributed_orders": {
                      "type": "number"
                    },
                    "attribution_rate_pct": {
                      "type": "number"
                    },
                    "avg_order_value": {
                      "type": "number"
                    },
                    "avg_profit_margin_pct": {
                      "anyOf": [
                        {
                          "type": "number"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "currency": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/shopify/revenue/by-campaign": {
      "get": {
        "operationId": "getApiV1ShopifyRevenueByCampaign",
        "summary": "Get Shopify revenue by campaign",
        "tags": [
          "shopify",
          "commerce"
        ],
        "description": "Returns campaign-level Shopify revenue, spend, ROAS, profit, margin, confidence counts, and pagination metadata.",
        "parameters": [
          {
            "schema": {
              "format": "date",
              "type": "string"
            },
            "in": "query",
            "name": "from",
            "required": true
          },
          {
            "schema": {
              "format": "date",
              "type": "string"
            },
            "in": "query",
            "name": "to",
            "required": true
          },
          {
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "enum": [
                    "revenue"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "profit"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "spend"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "orders"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "roas"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "margin"
                  ]
                }
              ]
            },
            "in": "query",
            "name": "sort_by",
            "required": false
          },
          {
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "enum": [
                    "asc"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "desc"
                  ]
                }
              ]
            },
            "in": "query",
            "name": "sort_dir",
            "required": false
          },
          {
            "schema": {
              "minimum": 1,
              "maximum": 200,
              "type": "integer"
            },
            "in": "query",
            "name": "limit",
            "required": false
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "cursor",
            "required": false
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "items",
                    "unattributed",
                    "next_cursor"
                  ],
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "campaign_id",
                          "campaign_name",
                          "revenue",
                          "spend",
                          "roas",
                          "profit",
                          "margin_pct",
                          "orders_count",
                          "units_sold",
                          "high_confidence",
                          "medium_confidence",
                          "low_confidence",
                          "currency"
                        ],
                        "properties": {
                          "campaign_id": {
                            "type": "string"
                          },
                          "campaign_name": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "revenue": {
                            "type": "number"
                          },
                          "spend": {
                            "type": "number"
                          },
                          "roas": {
                            "anyOf": [
                              {
                                "type": "number"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "profit": {
                            "anyOf": [
                              {
                                "type": "number"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "margin_pct": {
                            "anyOf": [
                              {
                                "type": "number"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "orders_count": {
                            "type": "number"
                          },
                          "units_sold": {
                            "type": "number"
                          },
                          "high_confidence": {
                            "type": "number"
                          },
                          "medium_confidence": {
                            "type": "number"
                          },
                          "low_confidence": {
                            "type": "number"
                          },
                          "currency": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          }
                        }
                      }
                    },
                    "unattributed": {
                      "type": "object",
                      "required": [
                        "revenue",
                        "orders_count",
                        "units_sold",
                        "profit"
                      ],
                      "properties": {
                        "revenue": {
                          "type": "number"
                        },
                        "orders_count": {
                          "type": "number"
                        },
                        "units_sold": {
                          "type": "number"
                        },
                        "profit": {
                          "anyOf": [
                            {
                              "type": "number"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        }
                      }
                    },
                    "next_cursor": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/shopify/revenue/trend": {
      "get": {
        "operationId": "getApiV1ShopifyRevenueTrend",
        "summary": "Get Shopify revenue trend",
        "tags": [
          "shopify",
          "commerce"
        ],
        "description": "Returns a date-bucketed Shopify revenue, profit, COGS, order-count trend and cost coverage percentages.",
        "parameters": [
          {
            "schema": {
              "format": "date",
              "type": "string"
            },
            "in": "query",
            "name": "from",
            "required": true
          },
          {
            "schema": {
              "format": "date",
              "type": "string"
            },
            "in": "query",
            "name": "to",
            "required": true
          },
          {
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "enum": [
                    "day"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "week"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "month"
                  ]
                }
              ]
            },
            "in": "query",
            "name": "granularity",
            "required": false
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "points",
                    "coverage"
                  ],
                  "properties": {
                    "points": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "date",
                          "revenue",
                          "profit",
                          "cogs",
                          "orders_count",
                          "margin_pct"
                        ],
                        "properties": {
                          "date": {
                            "type": "string"
                          },
                          "revenue": {
                            "type": "number"
                          },
                          "profit": {
                            "anyOf": [
                              {
                                "type": "number"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "cogs": {
                            "type": "number"
                          },
                          "orders_count": {
                            "type": "number"
                          },
                          "margin_pct": {
                            "anyOf": [
                              {
                                "type": "number"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          }
                        }
                      }
                    },
                    "coverage": {
                      "type": "object",
                      "required": [
                        "full_pct",
                        "partial_pct",
                        "missing_pct"
                      ],
                      "properties": {
                        "full_pct": {
                          "type": "number"
                        },
                        "partial_pct": {
                          "type": "number"
                        },
                        "missing_pct": {
                          "type": "number"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/shopify/revenue/by-product": {
      "get": {
        "operationId": "getApiV1ShopifyRevenueByProduct",
        "summary": "Get Shopify revenue by product",
        "tags": [
          "shopify",
          "commerce"
        ],
        "description": "Returns Shopify revenue, COGS, profit, margin, units, and order counts grouped by product variant.",
        "parameters": [
          {
            "schema": {
              "format": "date",
              "type": "string"
            },
            "in": "query",
            "name": "from",
            "required": true
          },
          {
            "schema": {
              "format": "date",
              "type": "string"
            },
            "in": "query",
            "name": "to",
            "required": true
          },
          {
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "enum": [
                    "profit"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "revenue"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "units"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "margin"
                  ]
                }
              ]
            },
            "in": "query",
            "name": "sort_by",
            "required": false
          },
          {
            "schema": {
              "minimum": 1,
              "maximum": 200,
              "type": "integer"
            },
            "in": "query",
            "name": "limit",
            "required": false
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "cursor",
            "required": false
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "items",
                    "next_cursor"
                  ],
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "variant_id",
                          "product_id",
                          "product_title",
                          "variant_title",
                          "sku",
                          "revenue",
                          "cogs",
                          "profit",
                          "margin_pct",
                          "units_sold",
                          "orders_count"
                        ],
                        "properties": {
                          "variant_id": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "product_id": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "product_title": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "variant_title": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "sku": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "revenue": {
                            "type": "number"
                          },
                          "cogs": {
                            "type": "number"
                          },
                          "profit": {
                            "anyOf": [
                              {
                                "type": "number"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "margin_pct": {
                            "anyOf": [
                              {
                                "type": "number"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "units_sold": {
                            "type": "number"
                          },
                          "orders_count": {
                            "type": "number"
                          }
                        }
                      }
                    },
                    "next_cursor": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/shopify/revenue/product-campaign-matrix": {
      "get": {
        "operationId": "getApiV1ShopifyRevenueProductCampaignMatrix",
        "summary": "Get Shopify product-campaign revenue matrix",
        "tags": [
          "shopify",
          "commerce"
        ],
        "description": "Returns top Shopify products with their campaign-level revenue, units, spend, and ROAS breakdown for the date range.",
        "parameters": [
          {
            "schema": {
              "format": "date",
              "type": "string"
            },
            "in": "query",
            "name": "from",
            "required": true
          },
          {
            "schema": {
              "format": "date",
              "type": "string"
            },
            "in": "query",
            "name": "to",
            "required": true
          },
          {
            "schema": {
              "minimum": 1,
              "maximum": 100,
              "type": "integer"
            },
            "in": "query",
            "name": "limit",
            "required": false
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "items"
                  ],
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "variant_master_id",
                          "product_title",
                          "variant_title",
                          "sku",
                          "total_revenue",
                          "total_units",
                          "total_profit",
                          "campaigns"
                        ],
                        "properties": {
                          "variant_master_id": {
                            "type": "string"
                          },
                          "product_title": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "variant_title": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "sku": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "total_revenue": {
                            "type": "number"
                          },
                          "total_units": {
                            "type": "number"
                          },
                          "total_profit": {
                            "anyOf": [
                              {
                                "type": "number"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "campaigns": {
                            "type": "array",
                            "items": {
                              "type": "object",
                              "required": [
                                "campaign_id",
                                "campaign_name",
                                "revenue",
                                "units_sold",
                                "spend",
                                "roas"
                              ],
                              "properties": {
                                "campaign_id": {
                                  "type": "string"
                                },
                                "campaign_name": {
                                  "anyOf": [
                                    {
                                      "type": "string"
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "revenue": {
                                  "type": "number"
                                },
                                "units_sold": {
                                  "type": "number"
                                },
                                "spend": {
                                  "type": "number"
                                },
                                "roas": {
                                  "anyOf": [
                                    {
                                      "type": "number"
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                }
                              }
                            }
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/shopify/webhooks": {
      "post": {
        "operationId": "postApiV1ShopifyWebhooks",
        "summary": "Ingest Shopify webhook",
        "tags": [
          "shopify"
        ],
        "description": "Receives Shopify webhooks, verifies the HMAC signature, normalizes the payload and stores the ingest result. Returns 200 for ignored, disabled, duplicate and accepted events so Shopify does not retry unnecessarily.",
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "status"
                  ],
                  "properties": {
                    "status": {
                      "anyOf": [
                        {
                          "type": "string",
                          "enum": [
                            "ignored"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "feature_disabled"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "duplicate"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "accepted"
                          ]
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ]
      }
    },
    "/api/v1/shopify/install-start": {
      "get": {
        "operationId": "getApiV1ShopifyInstallStart",
        "summary": "Shopify-initiated install entry point",
        "tags": [
          "shopify"
        ],
        "description": "Public entry point Shopify redirects merchants to from the App Store or Shopify admin. Validates the Shopify HMAC signature and redirects the browser to the Wevion frontend to resume the connection.",
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "shop",
            "required": true
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "hmac",
            "required": true
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "timestamp",
            "required": true
          }
        ],
        "responses": {
          "302": {
            "description": "Redirect",
            "content": {
              "application/json": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/shopify/install": {
      "post": {
        "operationId": "postApiV1ShopifyInstall",
        "summary": "Start Shopify OAuth install",
        "tags": [
          "shopify"
        ],
        "description": "Creates a Shopify OAuth install URL for the active team and requested shop domain.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "shop_domain"
                ],
                "properties": {
                  "shop_domain": {
                    "minLength": 1,
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "install_url"
                  ],
                  "properties": {
                    "install_url": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/shopify/callback": {
      "get": {
        "operationId": "getApiV1ShopifyCallback",
        "summary": "Complete Shopify OAuth callback",
        "tags": [
          "shopify"
        ],
        "description": "Validates Shopify OAuth callback parameters, completes installation, and redirects the browser to the integrations page.",
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "shop",
            "required": true
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "code",
            "required": true
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "state",
            "required": true
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "hmac",
            "required": true
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "timestamp",
            "required": true
          }
        ],
        "responses": {
          "302": {
            "description": "Browser redirect response. The target URL is sent in the Location header."
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/shopify/config": {
      "get": {
        "operationId": "getApiV1ShopifyConfig",
        "summary": "Get Shopify configuration",
        "tags": [
          "shopify"
        ],
        "description": "Returns the primary Shopify connection status, granted scopes, missing scopes, and permission health for the team.",
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "anyOf": [
                    {
                      "type": "object",
                      "required": [
                        "feature_available",
                        "id",
                        "shop_domain",
                        "store_name",
                        "install_status",
                        "token_status",
                        "connected_at",
                        "granted_scopes",
                        "required_scopes",
                        "missing_scopes",
                        "permission_healthy",
                        "last_permission_check_at"
                      ],
                      "properties": {
                        "feature_available": {
                          "type": "boolean"
                        },
                        "id": {
                          "type": "string"
                        },
                        "shop_domain": {
                          "type": "string"
                        },
                        "store_name": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "install_status": {
                          "type": "string"
                        },
                        "token_status": {
                          "type": "string"
                        },
                        "connected_at": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "granted_scopes": {
                          "type": "array",
                          "items": {
                            "type": "string"
                          }
                        },
                        "required_scopes": {
                          "type": "array",
                          "items": {
                            "type": "string"
                          }
                        },
                        "missing_scopes": {
                          "type": "array",
                          "items": {
                            "type": "string"
                          }
                        },
                        "permission_healthy": {
                          "type": "boolean"
                        },
                        "last_permission_check_at": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        }
                      }
                    },
                    {
                      "type": "null"
                    }
                  ]
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/shopify/configs": {
      "get": {
        "operationId": "getApiV1ShopifyConfigs",
        "summary": "List Shopify configurations",
        "tags": [
          "shopify"
        ],
        "description": "Returns all Shopify store connection statuses, scopes, and permission health values for the active team.",
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "required": [
                      "feature_available",
                      "id",
                      "shop_domain",
                      "store_name",
                      "install_status",
                      "token_status",
                      "connected_at",
                      "granted_scopes",
                      "required_scopes",
                      "missing_scopes",
                      "permission_healthy",
                      "last_permission_check_at"
                    ],
                    "properties": {
                      "feature_available": {
                        "type": "boolean"
                      },
                      "id": {
                        "type": "string"
                      },
                      "shop_domain": {
                        "type": "string"
                      },
                      "store_name": {
                        "anyOf": [
                          {
                            "type": "string"
                          },
                          {
                            "type": "null"
                          }
                        ]
                      },
                      "install_status": {
                        "type": "string"
                      },
                      "token_status": {
                        "type": "string"
                      },
                      "connected_at": {
                        "anyOf": [
                          {
                            "type": "string"
                          },
                          {
                            "type": "null"
                          }
                        ]
                      },
                      "granted_scopes": {
                        "type": "array",
                        "items": {
                          "type": "string"
                        }
                      },
                      "required_scopes": {
                        "type": "array",
                        "items": {
                          "type": "string"
                        }
                      },
                      "missing_scopes": {
                        "type": "array",
                        "items": {
                          "type": "string"
                        }
                      },
                      "permission_healthy": {
                        "type": "boolean"
                      },
                      "last_permission_check_at": {
                        "anyOf": [
                          {
                            "type": "string"
                          },
                          {
                            "type": "null"
                          }
                        ]
                      }
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/shopify/disconnect": {
      "post": {
        "operationId": "postApiV1ShopifyDisconnect",
        "summary": "Disconnect Shopify store",
        "tags": [
          "shopify"
        ],
        "description": "Soft-disconnects a Shopify store for the team, optionally deleting imported product data.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "properties": {
                  "config_id": {
                    "type": "string"
                  },
                  "delete_imported_products": {
                    "type": "boolean"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "success"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/shopify/shop": {
      "get": {
        "operationId": "getApiV1ShopifyShop",
        "summary": "Get Shopify shop metadata",
        "tags": [
          "shopify"
        ],
        "description": "Returns cached shop metadata for the connected Shopify store, or null when no store is connected.",
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "anyOf": [
                    {
                      "type": "object",
                      "required": [
                        "domain",
                        "name",
                        "currency",
                        "timezone",
                        "country",
                        "plan_name"
                      ],
                      "properties": {
                        "domain": {
                          "type": "string"
                        },
                        "name": {
                          "type": "string"
                        },
                        "currency": {
                          "type": "string"
                        },
                        "timezone": {
                          "type": "string"
                        },
                        "country": {
                          "type": "string"
                        },
                        "plan_name": {
                          "type": "string"
                        }
                      }
                    },
                    {
                      "type": "null"
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/shopify/health": {
      "get": {
        "operationId": "getApiV1ShopifyHealth",
        "summary": "Get Shopify connection health",
        "tags": [
          "shopify"
        ],
        "description": "Returns whether Shopify is configured, connected, permission-healthy, feature-enabled, and ready for sync.",
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "configured",
                    "connected",
                    "feature_available",
                    "permission_healthy",
                    "ready_for_sync"
                  ],
                  "properties": {
                    "configured": {
                      "type": "boolean"
                    },
                    "connected": {
                      "type": "boolean"
                    },
                    "feature_available": {
                      "type": "boolean"
                    },
                    "permission_healthy": {
                      "type": "boolean"
                    },
                    "ready_for_sync": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/shopify/overview": {
      "get": {
        "operationId": "getApiV1ShopifyOverview",
        "summary": "Get Shopify overview",
        "tags": [
          "shopify"
        ],
        "description": "Returns store connection status, latest sync metadata, attribution count, and warning count for the team.",
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "attribution_total",
                    "connected",
                    "connected_at",
                    "last_sync_completed_at",
                    "last_sync_status",
                    "last_sync_type",
                    "shop_domain",
                    "store_name",
                    "warning_count"
                  ],
                  "properties": {
                    "attribution_total": {
                      "type": "number"
                    },
                    "connected": {
                      "type": "boolean"
                    },
                    "connected_at": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "last_sync_completed_at": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "last_sync_status": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "last_sync_type": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "shop_domain": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "store_name": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "warning_count": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/shopify/coverage": {
      "get": {
        "operationId": "getApiV1ShopifyCoverage",
        "summary": "Get Shopify coverage",
        "tags": [
          "shopify"
        ],
        "description": "Returns cost coverage and attribution coverage metrics for the connected Shopify store.",
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "attribution",
                    "cost"
                  ],
                  "properties": {
                    "attribution": {
                      "type": "object",
                      "required": [
                        "attributed",
                        "confidence_breakdown",
                        "total",
                        "unattributed"
                      ],
                      "properties": {
                        "attributed": {
                          "type": "number"
                        },
                        "confidence_breakdown": {
                          "type": "object",
                          "required": [
                            "high",
                            "low",
                            "medium"
                          ],
                          "properties": {
                            "high": {
                              "type": "number"
                            },
                            "low": {
                              "type": "number"
                            },
                            "medium": {
                              "type": "number"
                            }
                          }
                        },
                        "total": {
                          "type": "number"
                        },
                        "unattributed": {
                          "type": "number"
                        }
                      }
                    },
                    "cost": {
                      "type": "object",
                      "required": [
                        "coverage_pct",
                        "orders_missing_cost",
                        "orders_with_cost",
                        "total_orders"
                      ],
                      "properties": {
                        "coverage_pct": {
                          "anyOf": [
                            {
                              "type": "number"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "orders_missing_cost": {
                          "type": "number"
                        },
                        "orders_with_cost": {
                          "type": "number"
                        },
                        "total_orders": {
                          "type": "number"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/shopify/warnings": {
      "get": {
        "operationId": "getApiV1ShopifyWarnings",
        "summary": "List Shopify warnings",
        "tags": [
          "shopify"
        ],
        "description": "Returns normalized Shopify warnings derived from configuration, token, permission, sync, attribution, and cost coverage state.",
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "required": [
                      "code",
                      "config_id",
                      "message",
                      "severity",
                      "shop_domain",
                      "store_name",
                      "suggested_action"
                    ],
                    "properties": {
                      "code": {
                        "type": "string"
                      },
                      "config_id": {
                        "type": "string"
                      },
                      "message": {
                        "type": "string"
                      },
                      "params": {
                        "type": "object",
                        "additionalProperties": {
                          "$comment": "json-value"
                        }
                      },
                      "severity": {
                        "type": "string"
                      },
                      "shop_domain": {
                        "type": "string"
                      },
                      "store_name": {
                        "anyOf": [
                          {
                            "type": "string"
                          },
                          {
                            "type": "null"
                          }
                        ]
                      },
                      "suggested_action": {
                        "type": "string"
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/shopify/cost/coverage": {
      "get": {
        "operationId": "getApiV1ShopifyCostCoverage",
        "summary": "Get commerce cost coverage",
        "tags": [
          "shopify",
          "commerce"
        ],
        "description": "Returns the latest cost coverage snapshot for orders in the team commerce catalog, including missing and covered counts.",
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "coverage_pct",
                    "orders_missing_cost",
                    "orders_with_cost",
                    "total_orders"
                  ],
                  "properties": {
                    "coverage_pct": {
                      "anyOf": [
                        {
                          "type": "number"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "orders_missing_cost": {
                      "type": "number"
                    },
                    "orders_with_cost": {
                      "type": "number"
                    },
                    "total_orders": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "apiKeyAuth": []
          }
        ]
      }
    },
    "/api/v1/shopify/cost/overrides": {
      "get": {
        "operationId": "getApiV1ShopifyCostOverrides",
        "summary": "List commerce cost overrides",
        "tags": [
          "shopify",
          "commerce"
        ],
        "description": "Returns team cost overrides with product, variant, source, and thumbnail enrichment for the commerce cost UI.",
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "required": [
                      "cost_amount",
                      "cost_currency",
                      "created_at",
                      "effective_from",
                      "effective_to",
                      "id",
                      "product_id",
                      "product_filter_id",
                      "variant_id",
                      "product_title",
                      "variant_title",
                      "image_url",
                      "variant_master_id",
                      "cdm_source_name",
                      "cdm_source_type"
                    ],
                    "properties": {
                      "cost_amount": {
                        "type": "number"
                      },
                      "cost_currency": {
                        "type": "string"
                      },
                      "created_at": {
                        "type": "string"
                      },
                      "effective_from": {
                        "anyOf": [
                          {
                            "type": "string"
                          },
                          {
                            "type": "null"
                          }
                        ]
                      },
                      "effective_to": {
                        "anyOf": [
                          {
                            "type": "string"
                          },
                          {
                            "type": "null"
                          }
                        ]
                      },
                      "id": {
                        "type": "string"
                      },
                      "product_id": {
                        "anyOf": [
                          {
                            "type": "string"
                          },
                          {
                            "type": "null"
                          }
                        ]
                      },
                      "product_filter_id": {
                        "anyOf": [
                          {
                            "type": "string"
                          },
                          {
                            "type": "null"
                          }
                        ]
                      },
                      "variant_id": {
                        "anyOf": [
                          {
                            "type": "string"
                          },
                          {
                            "type": "null"
                          }
                        ]
                      },
                      "product_title": {
                        "anyOf": [
                          {
                            "type": "string"
                          },
                          {
                            "type": "null"
                          }
                        ]
                      },
                      "variant_title": {
                        "anyOf": [
                          {
                            "type": "string"
                          },
                          {
                            "type": "null"
                          }
                        ]
                      },
                      "image_url": {
                        "anyOf": [
                          {
                            "type": "string"
                          },
                          {
                            "type": "null"
                          }
                        ]
                      },
                      "variant_master_id": {
                        "anyOf": [
                          {
                            "type": "string"
                          },
                          {
                            "type": "null"
                          }
                        ]
                      },
                      "cdm_source_name": {
                        "anyOf": [
                          {
                            "type": "string"
                          },
                          {
                            "type": "null"
                          }
                        ]
                      },
                      "cdm_source_type": {
                        "anyOf": [
                          {
                            "type": "string"
                          },
                          {
                            "type": "null"
                          }
                        ]
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "apiKeyAuth": []
          }
        ]
      },
      "post": {
        "operationId": "postApiV1ShopifyCostOverrides",
        "summary": "Create commerce cost override",
        "tags": [
          "shopify",
          "commerce"
        ],
        "description": "Creates or updates a product, variant, or team-level cost override and queues profit recomputation when needed.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "cost_amount",
                  "cost_currency"
                ],
                "properties": {
                  "cost_amount": {
                    "minimum": 0,
                    "type": "number"
                  },
                  "cost_currency": {
                    "minLength": 1,
                    "type": "string"
                  },
                  "effective_from": {
                    "format": "date",
                    "type": "string"
                  },
                  "effective_to": {
                    "format": "date",
                    "type": "string"
                  },
                  "product_id": {
                    "type": "string"
                  },
                  "variant_id": {
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "id",
                    "message"
                  ],
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "apiKeyAuth": []
          }
        ]
      }
    },
    "/api/v1/shopify/cost/cdm-variants/{id}": {
      "patch": {
        "operationId": "patchApiV1ShopifyCostCdmVariantsById",
        "summary": "Update CDM variant cost",
        "tags": [
          "shopify",
          "commerce"
        ],
        "description": "Writes a direct cost amount and currency on a CDM source variant, then refreshes affected profit snapshots.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "cost_amount",
                  "cost_currency"
                ],
                "properties": {
                  "cost_amount": {
                    "minimum": 0,
                    "type": "number"
                  },
                  "cost_currency": {
                    "minLength": 1,
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "id",
                    "message"
                  ],
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "apiKeyAuth": []
          }
        ]
      },
      "delete": {
        "operationId": "deleteApiV1ShopifyCostCdmVariantsById",
        "summary": "Clear CDM variant cost",
        "tags": [
          "shopify",
          "commerce"
        ],
        "description": "Clears the direct cost amount and currency from a CDM source variant, then refreshes affected profit snapshots.",
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "id",
                    "message"
                  ],
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "apiKeyAuth": []
          }
        ]
      }
    },
    "/api/v1/shopify/cost/overrides/{id}": {
      "delete": {
        "operationId": "deleteApiV1ShopifyCostOverridesById",
        "summary": "Delete commerce cost override",
        "tags": [
          "shopify",
          "commerce"
        ],
        "description": "Removes a team cost override and refreshes affected product or variant profit snapshots when applicable.",
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "success"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "apiKeyAuth": []
          }
        ]
      }
    },
    "/api/v1/shopify/cost/products": {
      "get": {
        "operationId": "getApiV1ShopifyCostProducts",
        "summary": "List commerce product costs",
        "tags": [
          "shopify",
          "commerce"
        ],
        "description": "Returns paginated product and variant cost resolution details, including override, source cost, effective cost, and summary coverage.",
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "q",
            "required": false
          },
          {
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "enum": [
                    "true"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "false"
                  ]
                }
              ]
            },
            "in": "query",
            "name": "has_cost",
            "required": false
          },
          {
            "schema": {
              "type": "string",
              "enum": [
                "true"
              ]
            },
            "in": "query",
            "name": "has_override",
            "required": false
          },
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "query",
            "name": "catalog_source_id",
            "required": false
          },
          {
            "schema": {
              "minimum": 1,
              "maximum": 200,
              "type": "integer"
            },
            "in": "query",
            "name": "limit",
            "required": false
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "cursor",
            "required": false
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "items",
                    "next_cursor",
                    "summary"
                  ],
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "cdm_variant_id",
                          "product_id",
                          "variant_id",
                          "variant_master_id",
                          "product_title",
                          "variant_title",
                          "sku",
                          "image_url",
                          "item_price",
                          "item_price_currency",
                          "shopify_cost",
                          "shopify_cost_currency",
                          "override_cost",
                          "override_currency",
                          "effective_cost",
                          "effective_currency",
                          "cost_source",
                          "override_id",
                          "override_age_days",
                          "source_type"
                        ],
                        "properties": {
                          "cdm_variant_id": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "product_id": {
                            "type": "string"
                          },
                          "variant_id": {
                            "type": "string"
                          },
                          "variant_master_id": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "product_title": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "variant_title": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "sku": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "image_url": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "item_price": {
                            "anyOf": [
                              {
                                "type": "number"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "item_price_currency": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "shopify_cost": {
                            "anyOf": [
                              {
                                "type": "number"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "shopify_cost_currency": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "override_cost": {
                            "anyOf": [
                              {
                                "type": "number"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "override_currency": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "effective_cost": {
                            "anyOf": [
                              {
                                "type": "number"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "effective_currency": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "cost_source": {
                            "type": "string"
                          },
                          "override_id": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "override_age_days": {
                            "anyOf": [
                              {
                                "type": "number"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "source_type": {
                            "type": "string"
                          }
                        }
                      }
                    },
                    "next_cursor": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "summary": {
                      "type": "object",
                      "required": [
                        "total_variants",
                        "with_cost",
                        "missing_cost",
                        "coverage_pct"
                      ],
                      "properties": {
                        "total_variants": {
                          "type": "number"
                        },
                        "with_cost": {
                          "type": "number"
                        },
                        "missing_cost": {
                          "type": "number"
                        },
                        "coverage_pct": {
                          "type": "number"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "apiKeyAuth": []
          }
        ]
      }
    },
    "/api/v1/shopify/cost/import-csv": {
      "post": {
        "operationId": "postApiV1ShopifyCostImportCsv",
        "summary": "Import Shopify COGS CSV",
        "tags": [
          "shopify",
          "commerce"
        ],
        "description": "Imports cost-of-goods rows from a multipart CSV upload for the connected Shopify store and returns row-level errors.",
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "imported",
                    "skipped",
                    "total_rows",
                    "errors"
                  ],
                  "properties": {
                    "imported": {
                      "type": "number"
                    },
                    "skipped": {
                      "type": "number"
                    },
                    "total_rows": {
                      "type": "number"
                    },
                    "errors": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "row",
                          "sku",
                          "reason"
                        ],
                        "properties": {
                          "row": {
                            "type": "number"
                          },
                          "sku": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "reason": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "413": {
            "description": "Payload too large",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/shopify/profit/facts": {
      "get": {
        "operationId": "getApiV1ShopifyProfitFacts",
        "summary": "Get Shopify profit facts",
        "tags": [
          "shopify",
          "commerce"
        ],
        "description": "Returns Shopify profit totals and coverage-state counts for the team, optionally scoped by date range and profit type.",
        "parameters": [
          {
            "schema": {
              "format": "date",
              "type": "string"
            },
            "in": "query",
            "name": "from",
            "required": false
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "profit_type",
            "required": false
          },
          {
            "schema": {
              "format": "date",
              "type": "string"
            },
            "in": "query",
            "name": "to",
            "required": false
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "cogs",
                    "coverage_state_counts",
                    "gross_profit",
                    "revenue",
                    "total_facts"
                  ],
                  "properties": {
                    "cogs": {
                      "type": "number"
                    },
                    "coverage_state_counts": {
                      "type": "object",
                      "additionalProperties": {
                        "type": "number"
                      }
                    },
                    "gross_profit": {
                      "type": "number"
                    },
                    "revenue": {
                      "type": "number"
                    },
                    "total_facts": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "apiKeyAuth": []
          }
        ]
      }
    },
    "/api/v1/shopify/sync/recent": {
      "post": {
        "operationId": "postApiV1ShopifySyncRecent",
        "summary": "Queue recent Shopify sync",
        "tags": [
          "shopify"
        ],
        "description": "Queues a recent Shopify bootstrap sync for the last seven days, unless another sync is already active.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "properties": {
                  "config_id": {
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "sync_log_id",
                    "message"
                  ],
                  "properties": {
                    "sync_log_id": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "Conflict - resource state prevents the operation",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "apiKeyAuth": []
          }
        ]
      }
    },
    "/api/v1/shopify/sync/latest": {
      "get": {
        "operationId": "getApiV1ShopifySyncLatest",
        "summary": "Get latest Shopify sync",
        "tags": [
          "shopify"
        ],
        "description": "Returns the latest Shopify sync log and summary for the team, or null when Shopify is unavailable or no sync exists.",
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "anyOf": [
                    {
                      "type": "object",
                      "required": [
                        "id",
                        "sync_type",
                        "status",
                        "started_at",
                        "completed_at",
                        "failure_reason",
                        "summary"
                      ],
                      "properties": {
                        "id": {
                          "type": "string"
                        },
                        "sync_type": {
                          "type": "string"
                        },
                        "status": {
                          "type": "string"
                        },
                        "started_at": {
                          "type": "string"
                        },
                        "completed_at": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "failure_reason": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "summary": {
                          "anyOf": [
                            {
                              "additionalProperties": true,
                              "type": "object",
                              "properties": {
                                "total_orders": {
                                  "type": "number"
                                },
                                "date_window_start": {
                                  "type": "string"
                                },
                                "date_window_end": {
                                  "type": "string"
                                },
                                "elapsed_ms": {
                                  "type": "number"
                                },
                                "pages_fetched": {
                                  "type": "number"
                                },
                                "error": {
                                  "type": "string"
                                }
                              }
                            },
                            {
                              "type": "null"
                            }
                          ]
                        }
                      }
                    },
                    {
                      "type": "null"
                    }
                  ]
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "apiKeyAuth": []
          }
        ]
      }
    },
    "/api/v1/shopify/sync/latest/progress": {
      "get": {
        "operationId": "getApiV1ShopifySyncLatestProgress",
        "summary": "Get latest Shopify sync progress",
        "tags": [
          "shopify"
        ],
        "description": "Returns progress rows for the latest Shopify sync log, or an empty list when Shopify is unavailable or no sync exists.",
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "required": [
                      "id",
                      "phase",
                      "status",
                      "progress_data"
                    ],
                    "properties": {
                      "id": {
                        "type": "string"
                      },
                      "phase": {
                        "type": "string"
                      },
                      "status": {
                        "type": "string"
                      },
                      "progress_data": {
                        "anyOf": [
                          {
                            "type": "object",
                            "properties": {
                              "error": {
                                "type": "string"
                              },
                              "failure_reason": {
                                "type": "string"
                              },
                              "orders": {
                                "type": "number"
                              },
                              "pages_fetched": {
                                "type": "number"
                              },
                              "total_orders": {
                                "type": "number"
                              },
                              "total_products": {
                                "type": "number"
                              },
                              "window": {
                                "type": "object",
                                "required": [
                                  "end",
                                  "start"
                                ],
                                "properties": {
                                  "end": {
                                    "type": "string"
                                  },
                                  "start": {
                                    "type": "string"
                                  }
                                }
                              }
                            }
                          },
                          {
                            "type": "null"
                          }
                        ]
                      }
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "apiKeyAuth": []
          }
        ]
      }
    },
    "/api/v1/shopify/attribution/overview": {
      "get": {
        "operationId": "getApiV1ShopifyAttributionOverview",
        "summary": "Get Shopify attribution overview",
        "tags": [
          "shopify"
        ],
        "description": "Returns total, attributed, unattributed, and confidence-level attribution counts for the connected Shopify store.",
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "attributed",
                    "high_confidence",
                    "low_confidence",
                    "medium_confidence",
                    "total",
                    "unattributed"
                  ],
                  "properties": {
                    "attributed": {
                      "type": "number"
                    },
                    "high_confidence": {
                      "type": "number"
                    },
                    "low_confidence": {
                      "type": "number"
                    },
                    "medium_confidence": {
                      "type": "number"
                    },
                    "total": {
                      "type": "number"
                    },
                    "unattributed": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "apiKeyAuth": []
          }
        ]
      }
    },
    "/api/v1/shopify/attribution/order/{orderId}": {
      "get": {
        "operationId": "getApiV1ShopifyAttributionOrderByOrderId",
        "summary": "Get Shopify order attribution",
        "tags": [
          "shopify"
        ],
        "description": "Returns attribution status, explanation, order signals, used signals, and conflicted signals for one Shopify order.",
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "in": "path",
            "name": "orderId",
            "required": true
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "anyOf": [
                    {
                      "type": "object",
                      "required": [
                        "confidence_level",
                        "engine_version",
                        "evaluated_at",
                        "explanation",
                        "match_source_type",
                        "match_status",
                        "matched_entity_id",
                        "matched_entity_type",
                        "reason_code",
                        "reason_text",
                        "signals",
                        "signals_conflicted",
                        "signals_used"
                      ],
                      "properties": {
                        "confidence_level": {
                          "type": "string"
                        },
                        "engine_version": {
                          "type": "string"
                        },
                        "evaluated_at": {
                          "type": "string"
                        },
                        "explanation": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "match_source_type": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "match_status": {
                          "type": "string"
                        },
                        "matched_entity_id": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "matched_entity_type": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "reason_code": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "reason_text": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "signals": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "required": [
                              "id",
                              "signal_key",
                              "signal_type",
                              "signal_value"
                            ],
                            "properties": {
                              "id": {
                                "type": "string"
                              },
                              "signal_key": {
                                "type": "string"
                              },
                              "signal_type": {
                                "type": "string"
                              },
                              "signal_value": {
                                "anyOf": [
                                  {
                                    "type": "string"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              }
                            }
                          }
                        },
                        "signals_conflicted": {
                          "anyOf": [
                            {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "required": [
                                  "entity_id",
                                  "entity_type",
                                  "match_reason",
                                  "match_score",
                                  "signal_type"
                                ],
                                "properties": {
                                  "entity_id": {
                                    "type": "string"
                                  },
                                  "entity_type": {
                                    "type": "string"
                                  },
                                  "match_reason": {
                                    "type": "string"
                                  },
                                  "match_score": {
                                    "type": "number"
                                  },
                                  "signal_type": {
                                    "type": "string"
                                  }
                                }
                              }
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "signals_used": {
                          "anyOf": [
                            {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "required": [
                                  "entity_id",
                                  "entity_type",
                                  "match_reason",
                                  "match_score",
                                  "signal_type"
                                ],
                                "properties": {
                                  "entity_id": {
                                    "type": "string"
                                  },
                                  "entity_type": {
                                    "type": "string"
                                  },
                                  "match_reason": {
                                    "type": "string"
                                  },
                                  "match_score": {
                                    "type": "number"
                                  },
                                  "signal_type": {
                                    "type": "string"
                                  }
                                }
                              }
                            },
                            {
                              "type": "null"
                            }
                          ]
                        }
                      }
                    },
                    {
                      "type": "null"
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "apiKeyAuth": []
          }
        ]
      }
    },
    "/api/v1/shopify/attribution/run": {
      "post": {
        "operationId": "postApiV1ShopifyAttributionRun",
        "summary": "Queue Shopify attribution run",
        "tags": [
          "shopify"
        ],
        "description": "Queues an attribution run for the connected Shopify store in the active team.",
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "message"
                  ],
                  "properties": {
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "apiKeyAuth": []
          }
        ]
      }
    },
    "/api/v1/shopify/attribution/campaigns": {
      "get": {
        "operationId": "getApiV1ShopifyAttributionCampaigns",
        "summary": "List Shopify attributed campaigns",
        "tags": [
          "shopify"
        ],
        "description": "Returns Meta campaigns with Shopify attributed order counts for the requested date range.",
        "parameters": [
          {
            "schema": {
              "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
              "type": "string"
            },
            "in": "query",
            "name": "from",
            "required": false
          },
          {
            "schema": {
              "type": "boolean"
            },
            "in": "query",
            "name": "include_all",
            "required": false
          },
          {
            "schema": {
              "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
              "type": "string"
            },
            "in": "query",
            "name": "to",
            "required": false
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "required": [
                      "campaign_id",
                      "campaign_name",
                      "orders_count"
                    ],
                    "properties": {
                      "campaign_id": {
                        "type": "string"
                      },
                      "campaign_name": {
                        "type": "string"
                      },
                      "orders_count": {
                        "type": "number"
                      },
                      "platform": {
                        "anyOf": [
                          {
                            "type": "string"
                          },
                          {
                            "type": "null"
                          }
                        ]
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "apiKeyAuth": []
          }
        ]
      }
    },
    "/api/v1/shopify/orders": {
      "get": {
        "operationId": "getApiV1ShopifyOrders",
        "summary": "List commerce orders",
        "tags": [
          "shopify",
          "commerce"
        ],
        "description": "Returns paginated Shopify and WooCommerce order rows with financial status, refund totals, source type, and attribution summary.",
        "parameters": [
          {
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "enum": [
                    "attributed"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "unattributed"
                  ]
                }
              ]
            },
            "in": "query",
            "name": "attribution_status",
            "required": false
          },
          {
            "schema": {
              "minLength": 1,
              "maxLength": 100,
              "type": "string"
            },
            "in": "query",
            "name": "campaign_id",
            "required": false
          },
          {
            "schema": {
              "minLength": 1,
              "maxLength": 1000,
              "type": "string"
            },
            "in": "query",
            "name": "campaign_ids",
            "required": false
          },
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "query",
            "name": "catalog_source_id",
            "required": false
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "cursor",
            "required": false
          },
          {
            "schema": {
              "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
              "type": "string"
            },
            "in": "query",
            "name": "date_from",
            "required": false
          },
          {
            "schema": {
              "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
              "type": "string"
            },
            "in": "query",
            "name": "date_to",
            "required": false
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "financial_status",
            "required": false
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "fulfillment_status",
            "required": false
          },
          {
            "schema": {
              "minimum": 1,
              "maximum": 200,
              "type": "number"
            },
            "in": "query",
            "name": "limit",
            "required": false
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "q",
            "required": false
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "items",
                    "next_cursor"
                  ],
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "attribution",
                          "currency",
                          "effective_financial_status",
                          "external_order_id",
                          "financial_status",
                          "fulfillment_status",
                          "id",
                          "line_items_count",
                          "net_amount",
                          "order_name",
                          "order_number",
                          "shopify_created_at",
                          "source_type",
                          "total_price",
                          "total_refunded"
                        ],
                        "properties": {
                          "attribution": {
                            "anyOf": [
                              {
                                "type": "object",
                                "required": [
                                  "attribution_method",
                                  "confidence_level",
                                  "manual_override",
                                  "match_status",
                                  "matched_entity_id",
                                  "matched_entity_name",
                                  "matched_entity_platform",
                                  "matched_entity_type"
                                ],
                                "properties": {
                                  "attribution_method": {
                                    "anyOf": [
                                      {
                                        "type": "string"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "confidence_level": {
                                    "anyOf": [
                                      {
                                        "type": "string"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "manual_override": {
                                    "type": "boolean"
                                  },
                                  "match_status": {
                                    "type": "string"
                                  },
                                  "matched_entity_id": {
                                    "anyOf": [
                                      {
                                        "type": "string"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "matched_entity_name": {
                                    "anyOf": [
                                      {
                                        "type": "string"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "matched_entity_platform": {
                                    "anyOf": [
                                      {
                                        "type": "string"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "matched_entity_type": {
                                    "anyOf": [
                                      {
                                        "type": "string"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  }
                                }
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "currency": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "effective_financial_status": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "external_order_id": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "financial_status": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "fulfillment_status": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "id": {
                            "type": "string"
                          },
                          "line_items_count": {
                            "type": "number"
                          },
                          "net_amount": {
                            "anyOf": [
                              {
                                "type": "number"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "order_name": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "order_number": {
                            "anyOf": [
                              {
                                "type": "number"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "shopify_created_at": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "source_type": {
                            "type": "string"
                          },
                          "total_price": {
                            "anyOf": [
                              {
                                "type": "number"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "total_refunded": {
                            "anyOf": [
                              {
                                "type": "number"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          }
                        }
                      }
                    },
                    "next_cursor": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "apiKeyAuth": []
          }
        ]
      }
    },
    "/api/v1/shopify/orders/pulse": {
      "get": {
        "operationId": "getApiV1ShopifyOrdersPulse",
        "summary": "Get commerce order pulse",
        "tags": [
          "shopify",
          "commerce"
        ],
        "description": "Returns lightweight team-scoped counts for refunded orders and orders awaiting fulfillment.",
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "refunded",
                    "to_fulfill"
                  ],
                  "properties": {
                    "refunded": {
                      "type": "number"
                    },
                    "to_fulfill": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "apiKeyAuth": []
          }
        ]
      }
    },
    "/api/v1/shopify/orders/{orderId}/detail": {
      "get": {
        "operationId": "getApiV1ShopifyOrdersByOrderIdDetail",
        "summary": "Get commerce order detail",
        "tags": [
          "shopify",
          "commerce"
        ],
        "description": "Returns full Shopify or WooCommerce order detail with line items, refunds, attribution, signals, profit summary, and source metadata.",
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "in": "path",
            "name": "orderId",
            "required": true
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "anyOf": [
                    {
                      "type": "object",
                      "required": [
                        "attribution",
                        "cancel_reason",
                        "cancelled_at",
                        "closed_at",
                        "connection",
                        "currency",
                        "current_total_price",
                        "effective_financial_status",
                        "external_order_id",
                        "financial_status",
                        "fulfillment_status",
                        "gateway",
                        "id",
                        "line_items",
                        "order_name",
                        "order_number",
                        "payment_gateway_names",
                        "processing_method",
                        "profit_summary",
                        "refunds",
                        "shop_domain",
                        "shopify_created_at",
                        "shopify_order_id",
                        "signals",
                        "source_type",
                        "subtotal_price",
                        "tags",
                        "total_discounts",
                        "total_price",
                        "total_refunded",
                        "total_shipping",
                        "total_tax"
                      ],
                      "properties": {
                        "attribution": {
                          "anyOf": [
                            {
                              "type": "object",
                              "required": [
                                "attribution_method",
                                "confidence_level",
                                "engine_version",
                                "explanation_text",
                                "manual_note",
                                "manual_override",
                                "match_status",
                                "matched_entity_id",
                                "matched_entity_name",
                                "matched_entity_platform",
                                "matched_entity_type",
                                "overridden_at"
                              ],
                              "properties": {
                                "attribution_method": {
                                  "anyOf": [
                                    {
                                      "type": "string"
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "confidence_level": {
                                  "anyOf": [
                                    {
                                      "type": "string"
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "engine_version": {
                                  "anyOf": [
                                    {
                                      "type": "string"
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "explanation_text": {
                                  "anyOf": [
                                    {
                                      "type": "string"
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "manual_note": {
                                  "anyOf": [
                                    {
                                      "type": "string"
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "manual_override": {
                                  "type": "boolean"
                                },
                                "match_status": {
                                  "type": "string"
                                },
                                "matched_entity_id": {
                                  "anyOf": [
                                    {
                                      "type": "string"
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "matched_entity_name": {
                                  "anyOf": [
                                    {
                                      "type": "string"
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "matched_entity_platform": {
                                  "anyOf": [
                                    {
                                      "type": "string"
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "matched_entity_type": {
                                  "anyOf": [
                                    {
                                      "type": "string"
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "overridden_at": {
                                  "anyOf": [
                                    {
                                      "type": "string"
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                }
                              }
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "cancel_reason": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "cancelled_at": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "closed_at": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "connection": {
                          "type": "object",
                          "required": [
                            "connected_at",
                            "disconnected_at",
                            "install_status",
                            "shop_domain"
                          ],
                          "properties": {
                            "connected_at": {
                              "anyOf": [
                                {
                                  "type": "string"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "disconnected_at": {
                              "anyOf": [
                                {
                                  "type": "string"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "install_status": {
                              "anyOf": [
                                {
                                  "type": "string"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "shop_domain": {
                              "anyOf": [
                                {
                                  "type": "string"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            }
                          }
                        },
                        "currency": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "current_total_price": {
                          "anyOf": [
                            {
                              "type": "number"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "effective_financial_status": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "external_order_id": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "financial_status": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "fulfillment_status": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "gateway": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "id": {
                          "type": "string"
                        },
                        "line_items": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "required": [
                              "external_product_id",
                              "external_variant_id",
                              "id",
                              "price",
                              "profit",
                              "quantity",
                              "refund_quantity",
                              "sku",
                              "title",
                              "variant_master",
                              "variant_title"
                            ],
                            "properties": {
                              "external_product_id": {
                                "anyOf": [
                                  {
                                    "type": "string"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "external_variant_id": {
                                "anyOf": [
                                  {
                                    "type": "string"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "id": {
                                "type": "string"
                              },
                              "price": {
                                "anyOf": [
                                  {
                                    "type": "number"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "profit": {
                                "anyOf": [
                                  {
                                    "type": "object",
                                    "required": [
                                      "cost_amount",
                                      "profit_margin"
                                    ],
                                    "properties": {
                                      "cost_amount": {
                                        "type": "number"
                                      },
                                      "profit_margin": {
                                        "anyOf": [
                                          {
                                            "type": "number"
                                          },
                                          {
                                            "type": "null"
                                          }
                                        ]
                                      }
                                    }
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "quantity": {
                                "type": "number"
                              },
                              "refund_quantity": {
                                "anyOf": [
                                  {
                                    "type": "number"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "sku": {
                                "anyOf": [
                                  {
                                    "type": "string"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "title": {
                                "anyOf": [
                                  {
                                    "type": "string"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "variant_master": {
                                "anyOf": [
                                  {
                                    "type": "object",
                                    "required": [
                                      "canonical_sku",
                                      "canonical_title",
                                      "id",
                                      "primary_image_url"
                                    ],
                                    "properties": {
                                      "canonical_sku": {
                                        "anyOf": [
                                          {
                                            "type": "string"
                                          },
                                          {
                                            "type": "null"
                                          }
                                        ]
                                      },
                                      "canonical_title": {
                                        "anyOf": [
                                          {
                                            "type": "string"
                                          },
                                          {
                                            "type": "null"
                                          }
                                        ]
                                      },
                                      "id": {
                                        "type": "string"
                                      },
                                      "primary_image_url": {
                                        "anyOf": [
                                          {
                                            "type": "string"
                                          },
                                          {
                                            "type": "null"
                                          }
                                        ]
                                      }
                                    }
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "variant_title": {
                                "anyOf": [
                                  {
                                    "type": "string"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              }
                            }
                          }
                        },
                        "net_amount": {
                          "anyOf": [
                            {
                              "type": "number"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "order_name": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "order_number": {
                          "anyOf": [
                            {
                              "type": "number"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "payment_gateway_names": {
                          "anyOf": [
                            {
                              "type": "array",
                              "items": {
                                "type": "string"
                              }
                            },
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "processing_method": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "profit_summary": {
                          "anyOf": [
                            {
                              "type": "object",
                              "required": [
                                "coverage_status",
                                "gross_profit",
                                "margin_percent",
                                "total_cogs",
                                "total_revenue"
                              ],
                              "properties": {
                                "coverage_status": {
                                  "type": "string"
                                },
                                "gross_profit": {
                                  "type": "number"
                                },
                                "margin_percent": {
                                  "anyOf": [
                                    {
                                      "type": "number"
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "total_cogs": {
                                  "type": "number"
                                },
                                "total_revenue": {
                                  "type": "number"
                                }
                              }
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "refunds": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "required": [
                              "amount",
                              "note",
                              "reason",
                              "shopify_created_at"
                            ],
                            "properties": {
                              "amount": {
                                "anyOf": [
                                  {
                                    "type": "number"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "note": {
                                "anyOf": [
                                  {
                                    "type": "string"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "reason": {
                                "anyOf": [
                                  {
                                    "type": "string"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "shopify_created_at": {
                                "anyOf": [
                                  {
                                    "type": "string"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              }
                            }
                          }
                        },
                        "shop_domain": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "shopify_created_at": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "shopify_order_id": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "signals": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "required": [
                              "created_at",
                              "signal_key",
                              "signal_type",
                              "signal_value"
                            ],
                            "properties": {
                              "created_at": {
                                "type": "string"
                              },
                              "signal_key": {
                                "type": "string"
                              },
                              "signal_type": {
                                "type": "string"
                              },
                              "signal_value": {
                                "anyOf": [
                                  {
                                    "type": "string"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              }
                            }
                          }
                        },
                        "source_type": {
                          "type": "string"
                        },
                        "subtotal_price": {
                          "anyOf": [
                            {
                              "type": "number"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "tags": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "total_discounts": {
                          "anyOf": [
                            {
                              "type": "number"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "total_price": {
                          "anyOf": [
                            {
                              "type": "number"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "total_refunded": {
                          "anyOf": [
                            {
                              "type": "number"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "total_shipping": {
                          "anyOf": [
                            {
                              "type": "number"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "total_tax": {
                          "anyOf": [
                            {
                              "type": "number"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        }
                      }
                    },
                    {
                      "type": "null"
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "apiKeyAuth": []
          }
        ]
      }
    },
    "/api/v1/slack-notifications/install": {
      "post": {
        "operationId": "postApiV1SlackNotificationsInstall",
        "summary": "Generate Slack OAuth install URL",
        "tags": [
          "slack-notifications"
        ],
        "description": "Creates a Slack OAuth installation URL and signed state token for the authenticated owner/admin/manager.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "installUrl",
                    "state"
                  ],
                  "properties": {
                    "installUrl": {
                      "type": "string"
                    },
                    "state": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/slack-notifications/callback": {
      "get": {
        "operationId": "getApiV1SlackNotificationsCallback",
        "summary": "Slack OAuth callback",
        "tags": [
          "slack-notifications"
        ],
        "description": "Handles the Slack OAuth callback, exchanges the authorization code, and stores the workspace installation.",
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "code",
            "required": true
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "state",
            "required": true
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "success"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/slack-notifications/test": {
      "post": {
        "operationId": "postApiV1SlackNotificationsTest",
        "summary": "Test Slack notification delivery",
        "tags": [
          "slack-notifications"
        ],
        "description": "Creates a synthetic notification occurrence and attempts to deliver it to the default Slack destination for the current user.",
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "header",
            "name": "x-team-id",
            "required": false,
            "description": "Explicit team (workspace) scope: a team.id the caller belongs to."
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "header",
            "name": "x-active-scope",
            "required": false,
            "description": "Active scope selector in `<scopeType>:<uuid>` form, e.g. `organization:<organization_id>` or `team:<team_id>`. Omit the header for the all-workspaces view."
          }
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "success",
                    "outcome"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "outcome": {
                      "type": "string"
                    },
                    "errorMessage": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/slack-notifications/destinations": {
      "get": {
        "operationId": "getApiV1SlackNotificationsDestinations",
        "summary": "List Slack destinations for current user",
        "tags": [
          "slack-notifications"
        ],
        "description": "Returns Slack destinations created from the current user installation, including default and verification flags.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "destinations"
                  ],
                  "properties": {
                    "destinations": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "id",
                          "destinationKey",
                          "destinationLabel",
                          "isDefault",
                          "isVerified"
                        ],
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "destinationKey": {
                            "type": "string"
                          },
                          "destinationLabel": {
                            "type": "string"
                          },
                          "isDefault": {
                            "type": "boolean"
                          },
                          "isVerified": {
                            "type": "boolean"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/smm/agents": {
      "get": {
        "operationId": "getApiV1SmmAgents",
        "summary": "List SMM agents for the current team",
        "tags": [
          "smm"
        ],
        "description": "Returns all SMM agents configured for the current team.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "agents"
                  ],
                  "properties": {
                    "agents": {
                      "type": "array",
                      "items": {
                        "additionalProperties": true,
                        "type": "object",
                        "required": [
                          "id",
                          "pause_reason"
                        ],
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "pause_reason": {
                            "anyOf": [
                              {
                                "type": "string",
                                "enum": [
                                  "ai_credits_exhausted"
                                ]
                              },
                              {
                                "type": "null"
                              }
                            ]
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "postApiV1SmmAgents",
        "summary": "Create an SMM agent for a social account (with sensible defaults)",
        "tags": [
          "smm"
        ],
        "description": "Creates an SMM agent for the given social account with sensible defaults and returns it.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "socialAccountId",
                  "name"
                ],
                "properties": {
                  "socialAccountId": {
                    "type": "string"
                  },
                  "name": {
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "agent"
                  ],
                  "properties": {
                    "agent": {
                      "additionalProperties": true,
                      "type": "object",
                      "required": [
                        "id",
                        "pause_reason"
                      ],
                      "properties": {
                        "id": {
                          "type": "string"
                        },
                        "pause_reason": {
                          "anyOf": [
                            {
                              "type": "string",
                              "enum": [
                                "ai_credits_exhausted"
                              ]
                            },
                            {
                              "type": "null"
                            }
                          ]
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/smm/agents/{id}": {
      "get": {
        "operationId": "getApiV1SmmAgentsById",
        "summary": "Get a single SMM agent",
        "tags": [
          "smm"
        ],
        "description": "Returns a single SMM agent by id for the current team.",
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "agent"
                  ],
                  "properties": {
                    "agent": {
                      "additionalProperties": true,
                      "type": "object",
                      "required": [
                        "id",
                        "pause_reason"
                      ],
                      "properties": {
                        "id": {
                          "type": "string"
                        },
                        "pause_reason": {
                          "anyOf": [
                            {
                              "type": "string",
                              "enum": [
                                "ai_credits_exhausted"
                              ]
                            },
                            {
                              "type": "null"
                            }
                          ]
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      },
      "patch": {
        "operationId": "patchApiV1SmmAgentsById",
        "summary": "Update an SMM agent configuration (partial)",
        "tags": [
          "smm"
        ],
        "description": "Applies a partial update to an SMM agent configuration and returns the updated agent.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string"
                  },
                  "enabled": {
                    "type": "boolean"
                  },
                  "moderation_enabled": {
                    "type": "boolean"
                  },
                  "knowledge": {
                    "type": "string"
                  },
                  "tone": {
                    "anyOf": [
                      {
                        "type": "string",
                        "enum": [
                          "balanced"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "friendly"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "professional"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "casual"
                        ]
                      }
                    ]
                  },
                  "language": {
                    "anyOf": [
                      {
                        "type": "string",
                        "enum": [
                          "auto"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "it"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "en"
                        ]
                      }
                    ]
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "agent"
                  ],
                  "properties": {
                    "agent": {
                      "additionalProperties": true,
                      "type": "object",
                      "required": [
                        "id",
                        "pause_reason"
                      ],
                      "properties": {
                        "id": {
                          "type": "string"
                        },
                        "pause_reason": {
                          "anyOf": [
                            {
                              "type": "string",
                              "enum": [
                                "ai_credits_exhausted"
                              ]
                            },
                            {
                              "type": "null"
                            }
                          ]
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      },
      "delete": {
        "operationId": "deleteApiV1SmmAgentsById",
        "summary": "Delete an SMM agent",
        "tags": [
          "smm"
        ],
        "description": "Deletes an SMM agent by id for the current team.",
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "ok"
                  ],
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/smm/agents/{id}/logs": {
      "get": {
        "operationId": "getApiV1SmmAgentsByIdLogs",
        "summary": "List recent execution attempts for an SMM agent",
        "tags": [
          "smm"
        ],
        "description": "Returns successful, failed, unsupported, and credit-paused moderation attempts for one team-owned agent.",
        "parameters": [
          {
            "schema": {
              "minimum": 1,
              "maximum": 50,
              "default": 10,
              "type": "integer"
            },
            "in": "query",
            "name": "limit",
            "required": false
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "logs"
                  ],
                  "properties": {
                    "logs": {
                      "type": "array",
                      "items": {
                        "additionalProperties": false,
                        "type": "object",
                        "required": [
                          "id",
                          "automation_id",
                          "agent_id",
                          "team_id",
                          "social_account_id",
                          "comment_external_id",
                          "action",
                          "status",
                          "outcome",
                          "error_message",
                          "credits_used",
                          "attempt_count",
                          "created_at",
                          "last_attempt_at"
                        ],
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "automation_id": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "agent_id": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "team_id": {
                            "type": "string"
                          },
                          "social_account_id": {
                            "type": "string"
                          },
                          "comment_external_id": {
                            "type": "string"
                          },
                          "action": {
                            "type": "string"
                          },
                          "status": {
                            "anyOf": [
                              {
                                "type": "string",
                                "enum": [
                                  "succeeded"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "failed"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "skipped_unsupported"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "paused_credits"
                                ]
                              }
                            ]
                          },
                          "outcome": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "error_message": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "credits_used": {
                            "anyOf": [
                              {
                                "minimum": 0,
                                "type": "integer"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "attempt_count": {
                            "minimum": 1,
                            "type": "integer"
                          },
                          "created_at": {
                            "format": "date-time",
                            "type": "string"
                          },
                          "last_attempt_at": {
                            "format": "date-time",
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/smm/analytics/overview": {
      "get": {
        "operationId": "getApiV1SmmAnalyticsOverview",
        "summary": "Aggregate analytics overview across connected Facebook/Instagram accounts",
        "tags": [
          "smm"
        ],
        "description": "Returns the aggregated analytics overview (totals + followers) for the current team.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "overview"
                  ],
                  "properties": {
                    "overview": {
                      "additionalProperties": false,
                      "type": "object",
                      "required": [
                        "comments",
                        "engagement",
                        "followers",
                        "impressions",
                        "likes",
                        "posts",
                        "reach",
                        "shares"
                      ],
                      "properties": {
                        "comments": {
                          "type": "integer"
                        },
                        "engagement": {
                          "type": "integer"
                        },
                        "followers": {
                          "type": "integer"
                        },
                        "impressions": {
                          "type": "integer"
                        },
                        "likes": {
                          "type": "integer"
                        },
                        "posts": {
                          "type": "integer"
                        },
                        "reach": {
                          "type": "integer"
                        },
                        "shares": {
                          "type": "integer"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/smm/analytics/posts": {
      "get": {
        "operationId": "getApiV1SmmAnalyticsPosts",
        "summary": "List collected per-post insights",
        "tags": [
          "smm"
        ],
        "description": "Returns the collected per-post insight snapshots for the current team.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "posts"
                  ],
                  "properties": {
                    "posts": {
                      "type": "array",
                      "items": {
                        "additionalProperties": false,
                        "type": "object",
                        "required": [
                          "accountId",
                          "collectedAt",
                          "comments",
                          "engagement",
                          "externalPostId",
                          "impressions",
                          "likes",
                          "platform",
                          "post",
                          "reach",
                          "shares"
                        ],
                        "properties": {
                          "accountId": {
                            "type": "string"
                          },
                          "collectedAt": {
                            "format": "date-time",
                            "type": "string"
                          },
                          "comments": {
                            "type": "integer"
                          },
                          "engagement": {
                            "type": "integer"
                          },
                          "externalPostId": {
                            "type": "string"
                          },
                          "impressions": {
                            "type": "integer"
                          },
                          "likes": {
                            "type": "integer"
                          },
                          "platform": {
                            "type": "string"
                          },
                          "post": {
                            "anyOf": [
                              {
                                "additionalProperties": false,
                                "type": "object",
                                "required": [
                                  "campaign",
                                  "id",
                                  "mediaType",
                                  "mediaUrl",
                                  "publishedAt",
                                  "text"
                                ],
                                "properties": {
                                  "campaign": {
                                    "anyOf": [
                                      {
                                        "type": "string"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "id": {
                                    "type": "string"
                                  },
                                  "mediaType": {
                                    "anyOf": [
                                      {
                                        "type": "string"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "mediaUrl": {
                                    "anyOf": [
                                      {
                                        "type": "string"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "publishedAt": {
                                    "anyOf": [
                                      {
                                        "format": "date-time",
                                        "type": "string"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "text": {
                                    "type": "string"
                                  }
                                }
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "reach": {
                            "type": "integer"
                          },
                          "shares": {
                            "type": "integer"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/smm/analytics/accounts": {
      "get": {
        "operationId": "getApiV1SmmAnalyticsAccounts",
        "summary": "List collected per-account insight snapshots",
        "tags": [
          "smm"
        ],
        "description": "Returns the collected per-account insight snapshots for the current team.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "accounts"
                  ],
                  "properties": {
                    "accounts": {
                      "type": "array",
                      "items": {
                        "additionalProperties": false,
                        "type": "object",
                        "required": [
                          "accountId",
                          "followers",
                          "platform",
                          "reach",
                          "snapshotDate"
                        ],
                        "properties": {
                          "accountId": {
                            "type": "string"
                          },
                          "followers": {
                            "type": "integer"
                          },
                          "platform": {
                            "type": "string"
                          },
                          "reach": {
                            "type": "integer"
                          },
                          "snapshotDate": {
                            "format": "date-time",
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/smm/analytics/collect/run": {
      "post": {
        "operationId": "postApiV1SmmAnalyticsCollectRun",
        "summary": "Run a scoped Meta analytics collection pass for the team",
        "tags": [
          "smm"
        ],
        "description": "Collects live insights only for the selected Facebook/Instagram account ids owned by the team. TikTok, YouTube and demo accounts are skipped and never reported as refreshed.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "properties": {
                  "accountIds": {
                    "maxItems": 100,
                    "uniqueItems": true,
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "result"
                  ],
                  "properties": {
                    "result": {
                      "additionalProperties": false,
                      "type": "object",
                      "required": [
                        "accounts",
                        "posts"
                      ],
                      "properties": {
                        "accounts": {
                          "minimum": 0,
                          "type": "integer"
                        },
                        "posts": {
                          "minimum": 0,
                          "type": "integer"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/smm/automations": {
      "get": {
        "operationId": "getApiV1SmmAutomations",
        "summary": "List comment automations for the current team",
        "tags": [
          "smm"
        ],
        "description": "Returns all comment automations configured for the current team, including their normalized account scopes.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "automations"
                  ],
                  "properties": {
                    "automations": {
                      "type": "array",
                      "items": {
                        "additionalProperties": false,
                        "type": "object",
                        "required": [
                          "id",
                          "team_id",
                          "social_account_ids",
                          "name",
                          "trigger_type",
                          "keywords",
                          "action_type",
                          "action_value",
                          "enabled",
                          "pause_reason",
                          "run_count",
                          "last_run_at",
                          "created_at",
                          "updated_at",
                          "deleted_at"
                        ],
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "team_id": {
                            "type": "string"
                          },
                          "social_account_ids": {
                            "type": "array",
                            "items": {
                              "type": "string"
                            }
                          },
                          "name": {
                            "type": "string"
                          },
                          "trigger_type": {
                            "anyOf": [
                              {
                                "type": "string",
                                "enum": [
                                  "comment_all"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "comment_keyword"
                                ]
                              }
                            ]
                          },
                          "keywords": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "action_type": {
                            "anyOf": [
                              {
                                "type": "string",
                                "enum": [
                                  "like"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "reply"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "hide"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "send_dm"
                                ]
                              }
                            ]
                          },
                          "action_value": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "enabled": {
                            "type": "boolean"
                          },
                          "pause_reason": {
                            "anyOf": [
                              {
                                "type": "string",
                                "enum": [
                                  "ai_credits_exhausted"
                                ]
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "run_count": {
                            "type": "integer"
                          },
                          "last_run_at": {
                            "anyOf": [
                              {
                                "format": "date-time",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "created_at": {
                            "format": "date-time",
                            "type": "string"
                          },
                          "updated_at": {
                            "anyOf": [
                              {
                                "format": "date-time",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "deleted_at": {
                            "anyOf": [
                              {
                                "format": "date-time",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "postApiV1SmmAutomations",
        "summary": "Create a comment automation",
        "tags": [
          "smm"
        ],
        "description": "Creates a new comment automation for one or more social accounts owned by the current team.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "name",
                  "social_account_ids",
                  "trigger_type",
                  "action_type"
                ],
                "properties": {
                  "name": {
                    "minLength": 1,
                    "type": "string"
                  },
                  "social_account_ids": {
                    "minItems": 1,
                    "uniqueItems": true,
                    "type": "array",
                    "items": {
                      "minLength": 1,
                      "type": "string"
                    }
                  },
                  "trigger_type": {
                    "anyOf": [
                      {
                        "type": "string",
                        "enum": [
                          "comment_all"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "comment_keyword"
                        ]
                      }
                    ]
                  },
                  "keywords": {
                    "anyOf": [
                      {
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "action_type": {
                    "anyOf": [
                      {
                        "type": "string",
                        "enum": [
                          "like"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "reply"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "hide"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "send_dm"
                        ]
                      }
                    ]
                  },
                  "action_value": {
                    "anyOf": [
                      {
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "automation"
                  ],
                  "properties": {
                    "automation": {
                      "additionalProperties": false,
                      "type": "object",
                      "required": [
                        "id",
                        "team_id",
                        "social_account_ids",
                        "name",
                        "trigger_type",
                        "keywords",
                        "action_type",
                        "action_value",
                        "enabled",
                        "pause_reason",
                        "run_count",
                        "last_run_at",
                        "created_at",
                        "updated_at",
                        "deleted_at"
                      ],
                      "properties": {
                        "id": {
                          "type": "string"
                        },
                        "team_id": {
                          "type": "string"
                        },
                        "social_account_ids": {
                          "type": "array",
                          "items": {
                            "type": "string"
                          }
                        },
                        "name": {
                          "type": "string"
                        },
                        "trigger_type": {
                          "anyOf": [
                            {
                              "type": "string",
                              "enum": [
                                "comment_all"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "comment_keyword"
                              ]
                            }
                          ]
                        },
                        "keywords": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "action_type": {
                          "anyOf": [
                            {
                              "type": "string",
                              "enum": [
                                "like"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "reply"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "hide"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "send_dm"
                              ]
                            }
                          ]
                        },
                        "action_value": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "enabled": {
                          "type": "boolean"
                        },
                        "pause_reason": {
                          "anyOf": [
                            {
                              "type": "string",
                              "enum": [
                                "ai_credits_exhausted"
                              ]
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "run_count": {
                          "type": "integer"
                        },
                        "last_run_at": {
                          "anyOf": [
                            {
                              "format": "date-time",
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "created_at": {
                          "format": "date-time",
                          "type": "string"
                        },
                        "updated_at": {
                          "anyOf": [
                            {
                              "format": "date-time",
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "deleted_at": {
                          "anyOf": [
                            {
                              "format": "date-time",
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/smm/automations/{id}": {
      "put": {
        "operationId": "putApiV1SmmAutomationsById",
        "summary": "Update a comment automation",
        "tags": [
          "smm"
        ],
        "description": "Updates an existing comment automation and, when provided, atomically replaces its team-owned account scope.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "properties": {
                  "name": {
                    "minLength": 1,
                    "type": "string"
                  },
                  "social_account_ids": {
                    "minItems": 1,
                    "uniqueItems": true,
                    "type": "array",
                    "items": {
                      "minLength": 1,
                      "type": "string"
                    }
                  },
                  "trigger_type": {
                    "anyOf": [
                      {
                        "type": "string",
                        "enum": [
                          "comment_all"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "comment_keyword"
                        ]
                      }
                    ]
                  },
                  "keywords": {
                    "anyOf": [
                      {
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "action_type": {
                    "anyOf": [
                      {
                        "type": "string",
                        "enum": [
                          "like"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "reply"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "hide"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "send_dm"
                        ]
                      }
                    ]
                  },
                  "action_value": {
                    "anyOf": [
                      {
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "enabled": {
                    "type": "boolean"
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "automation"
                  ],
                  "properties": {
                    "automation": {
                      "additionalProperties": false,
                      "type": "object",
                      "required": [
                        "id",
                        "team_id",
                        "social_account_ids",
                        "name",
                        "trigger_type",
                        "keywords",
                        "action_type",
                        "action_value",
                        "enabled",
                        "pause_reason",
                        "run_count",
                        "last_run_at",
                        "created_at",
                        "updated_at",
                        "deleted_at"
                      ],
                      "properties": {
                        "id": {
                          "type": "string"
                        },
                        "team_id": {
                          "type": "string"
                        },
                        "social_account_ids": {
                          "type": "array",
                          "items": {
                            "type": "string"
                          }
                        },
                        "name": {
                          "type": "string"
                        },
                        "trigger_type": {
                          "anyOf": [
                            {
                              "type": "string",
                              "enum": [
                                "comment_all"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "comment_keyword"
                              ]
                            }
                          ]
                        },
                        "keywords": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "action_type": {
                          "anyOf": [
                            {
                              "type": "string",
                              "enum": [
                                "like"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "reply"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "hide"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "send_dm"
                              ]
                            }
                          ]
                        },
                        "action_value": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "enabled": {
                          "type": "boolean"
                        },
                        "pause_reason": {
                          "anyOf": [
                            {
                              "type": "string",
                              "enum": [
                                "ai_credits_exhausted"
                              ]
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "run_count": {
                          "type": "integer"
                        },
                        "last_run_at": {
                          "anyOf": [
                            {
                              "format": "date-time",
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "created_at": {
                          "format": "date-time",
                          "type": "string"
                        },
                        "updated_at": {
                          "anyOf": [
                            {
                              "format": "date-time",
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "deleted_at": {
                          "anyOf": [
                            {
                              "format": "date-time",
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      },
      "delete": {
        "operationId": "deleteApiV1SmmAutomationsById",
        "summary": "Delete a comment automation",
        "tags": [
          "smm"
        ],
        "description": "Deletes a comment automation by id for the current team.",
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "ok"
                  ],
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/smm/automations/{id}/logs": {
      "get": {
        "operationId": "getApiV1SmmAutomationsByIdLogs",
        "summary": "List recent execution attempts for a comment automation",
        "tags": [
          "smm"
        ],
        "description": "Returns successful, failed, unsupported, and credit-paused attempts for one team-owned automation.",
        "parameters": [
          {
            "schema": {
              "minimum": 1,
              "maximum": 50,
              "default": 10,
              "type": "integer"
            },
            "in": "query",
            "name": "limit",
            "required": false
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "logs"
                  ],
                  "properties": {
                    "logs": {
                      "type": "array",
                      "items": {
                        "additionalProperties": false,
                        "type": "object",
                        "required": [
                          "id",
                          "automation_id",
                          "agent_id",
                          "team_id",
                          "social_account_id",
                          "comment_external_id",
                          "action",
                          "status",
                          "outcome",
                          "error_message",
                          "credits_used",
                          "attempt_count",
                          "created_at",
                          "last_attempt_at"
                        ],
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "automation_id": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "agent_id": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "team_id": {
                            "type": "string"
                          },
                          "social_account_id": {
                            "type": "string"
                          },
                          "comment_external_id": {
                            "type": "string"
                          },
                          "action": {
                            "type": "string"
                          },
                          "status": {
                            "anyOf": [
                              {
                                "type": "string",
                                "enum": [
                                  "succeeded"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "failed"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "skipped_unsupported"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "paused_credits"
                                ]
                              }
                            ]
                          },
                          "outcome": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "error_message": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "credits_used": {
                            "anyOf": [
                              {
                                "minimum": 0,
                                "type": "integer"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "attempt_count": {
                            "minimum": 1,
                            "type": "integer"
                          },
                          "created_at": {
                            "format": "date-time",
                            "type": "string"
                          },
                          "last_attempt_at": {
                            "format": "date-time",
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/smm/automations/run": {
      "post": {
        "operationId": "postApiV1SmmAutomationsRun",
        "summary": "Run all enabled automations for the current team now",
        "tags": [
          "smm"
        ],
        "description": "Triggers an on-demand evaluation of all enabled automations and returns the processed counts.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "result"
                  ],
                  "properties": {
                    "result": {
                      "additionalProperties": false,
                      "type": "object",
                      "required": [
                        "processed",
                        "actioned"
                      ],
                      "properties": {
                        "processed": {
                          "minimum": 0,
                          "type": "integer"
                        },
                        "actioned": {
                          "minimum": 0,
                          "type": "integer"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "402": {
            "description": "Response 402",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/smm/campaigns": {
      "get": {
        "operationId": "getApiV1SmmCampaigns",
        "summary": "List editorial campaigns for the current team",
        "tags": [
          "smm"
        ],
        "description": "Returns all editorial campaigns (non-archived) for the current team.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "campaigns"
                  ],
                  "properties": {
                    "campaigns": {
                      "type": "array",
                      "items": {
                        "additionalProperties": false,
                        "type": "object",
                        "required": [
                          "id",
                          "team_id",
                          "name",
                          "description",
                          "starts_on",
                          "ends_on",
                          "color",
                          "folder_id",
                          "created_at",
                          "updated_at",
                          "deleted_at"
                        ],
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "team_id": {
                            "type": "string"
                          },
                          "name": {
                            "type": "string"
                          },
                          "description": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "starts_on": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "ends_on": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "color": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "folder_id": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "created_at": {
                            "type": "string"
                          },
                          "updated_at": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "deleted_at": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "postApiV1SmmCampaigns",
        "summary": "Create an editorial campaign",
        "tags": [
          "smm"
        ],
        "description": "Creates a new editorial campaign for the current team. The name must be unique per team (case-insensitive).",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "name"
                ],
                "properties": {
                  "name": {
                    "minLength": 1,
                    "type": "string"
                  },
                  "description": {
                    "anyOf": [
                      {
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "starts_on": {
                    "anyOf": [
                      {
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "ends_on": {
                    "anyOf": [
                      {
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "color": {
                    "anyOf": [
                      {
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "campaign"
                  ],
                  "properties": {
                    "campaign": {
                      "additionalProperties": false,
                      "type": "object",
                      "required": [
                        "id",
                        "team_id",
                        "name",
                        "description",
                        "starts_on",
                        "ends_on",
                        "color",
                        "folder_id",
                        "created_at",
                        "updated_at",
                        "deleted_at"
                      ],
                      "properties": {
                        "id": {
                          "type": "string"
                        },
                        "team_id": {
                          "type": "string"
                        },
                        "name": {
                          "type": "string"
                        },
                        "description": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "starts_on": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "ends_on": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "color": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "folder_id": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "created_at": {
                          "type": "string"
                        },
                        "updated_at": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "deleted_at": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "409": {
            "description": "Conflict - resource state prevents the operation",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/smm/campaigns/{id}": {
      "patch": {
        "operationId": "patchApiV1SmmCampaignsById",
        "summary": "Update an editorial campaign",
        "tags": [
          "smm"
        ],
        "description": "Updates an editorial campaign by id for the current team. Renaming propagates the new name onto existing posts that reference the campaign.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "properties": {
                  "name": {
                    "minLength": 1,
                    "type": "string"
                  },
                  "description": {
                    "anyOf": [
                      {
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "starts_on": {
                    "anyOf": [
                      {
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "ends_on": {
                    "anyOf": [
                      {
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "color": {
                    "anyOf": [
                      {
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "campaign"
                  ],
                  "properties": {
                    "campaign": {
                      "additionalProperties": false,
                      "type": "object",
                      "required": [
                        "id",
                        "team_id",
                        "name",
                        "description",
                        "starts_on",
                        "ends_on",
                        "color",
                        "folder_id",
                        "created_at",
                        "updated_at",
                        "deleted_at"
                      ],
                      "properties": {
                        "id": {
                          "type": "string"
                        },
                        "team_id": {
                          "type": "string"
                        },
                        "name": {
                          "type": "string"
                        },
                        "description": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "starts_on": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "ends_on": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "color": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "folder_id": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "created_at": {
                          "type": "string"
                        },
                        "updated_at": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "deleted_at": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "Conflict - resource state prevents the operation",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      },
      "delete": {
        "operationId": "deleteApiV1SmmCampaignsById",
        "summary": "Archive an editorial campaign",
        "tags": [
          "smm"
        ],
        "description": "Soft-deletes (archives) an editorial campaign by id for the current team. Posts keep the campaign name as a historical string.",
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "ok"
                  ],
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/smm/connections": {
      "get": {
        "operationId": "getApiV1SmmConnections",
        "summary": "List connected social accounts with token-health and platform capabilities",
        "tags": [
          "smm"
        ],
        "description": "Returns the connected social accounts for the current team with their derived token-health and the per-account platform capability matrix resolved from the SMM adapter registry. A platform with no registered adapter reports every capability as false instead of failing the listing.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "connections"
                  ],
                  "properties": {
                    "connections": {
                      "type": "array",
                      "items": {
                        "additionalProperties": false,
                        "type": "object",
                        "required": [
                          "id",
                          "platform",
                          "name",
                          "username",
                          "status",
                          "tokenExpiresAt",
                          "health",
                          "capabilities"
                        ],
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "platform": {
                            "description": "Stored platform value, e.g. facebook_page, instagram, tiktok, youtube.",
                            "type": "string"
                          },
                          "name": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "username": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "status": {
                            "type": "string"
                          },
                          "tokenExpiresAt": {
                            "anyOf": [
                              {
                                "format": "date-time",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "health": {
                            "description": "Token health derived from tokenExpiresAt (expiring = within 7 days).",
                            "anyOf": [
                              {
                                "type": "string",
                                "enum": [
                                  "active"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "expiring"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "expired"
                                ]
                              }
                            ]
                          },
                          "capabilities": {
                            "additionalProperties": false,
                            "description": "What the connected account can actually do today.",
                            "type": "object",
                            "required": [
                              "publish",
                              "comments",
                              "dm",
                              "insights",
                              "listening",
                              "webhooks"
                            ],
                            "properties": {
                              "publish": {
                                "description": "The platform can publish posts.",
                                "type": "boolean"
                              },
                              "comments": {
                                "description": "The platform exposes comment listing/moderation.",
                                "type": "boolean"
                              },
                              "dm": {
                                "description": "The platform exposes a direct-message API.",
                                "type": "boolean"
                              },
                              "insights": {
                                "description": "The platform exposes post/account insight collection.",
                                "type": "boolean"
                              },
                              "listening": {
                                "description": "The platform supports social-listening collection.",
                                "type": "boolean"
                              },
                              "webhooks": {
                                "description": "The platform delivers webhook events.",
                                "type": "boolean"
                              }
                            }
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/smm/connections/{id}/disconnect": {
      "post": {
        "operationId": "postApiV1SmmConnectionsByIdDisconnect",
        "summary": "Disconnect (soft-delete) a connected social account",
        "tags": [
          "smm"
        ],
        "description": "Disconnects (soft-deletes) a connected social account for the current team.",
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "ok"
                  ],
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/smm/connections/discover": {
      "get": {
        "operationId": "getApiV1SmmConnectionsDiscover",
        "summary": "Discover connectable Pages / Instagram accounts from a user access token",
        "tags": [
          "smm"
        ],
        "description": "Discovers connectable Pages / Instagram accounts from a user access token.",
        "parameters": [
          {
            "schema": {
              "minLength": 20,
              "type": "string"
            },
            "in": "query",
            "name": "token",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "pages"
                  ],
                  "properties": {
                    "pages": {
                      "type": "array",
                      "items": {
                        "$comment": "json-value",
                        "description": "Arbitrary JSON value."
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/smm/dms": {
      "get": {
        "operationId": "getApiV1SmmDms",
        "summary": "List DM conversations across connected Facebook/Instagram accounts",
        "tags": [
          "smm"
        ],
        "description": "Returns the direct-message conversations across the team connected accounts.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "conversations"
                  ],
                  "properties": {
                    "conversations": {
                      "type": "array",
                      "items": {
                        "additionalProperties": false,
                        "type": "object",
                        "required": [
                          "id",
                          "accountId",
                          "externalThreadId",
                          "platform",
                          "status"
                        ],
                        "properties": {
                          "id": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "accountId": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "externalThreadId": {
                            "type": "string"
                          },
                          "participantExternalId": {
                            "type": "string"
                          },
                          "participantName": {
                            "type": "string"
                          },
                          "platform": {
                            "type": "string"
                          },
                          "status": {
                            "anyOf": [
                              {
                                "type": "string",
                                "enum": [
                                  "open"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "resolved"
                                ]
                              }
                            ]
                          },
                          "lastMessageAt": {
                            "format": "date-time",
                            "type": "string"
                          },
                          "unread": {
                            "minimum": 0,
                            "type": "integer"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/smm/dms/{id}/messages": {
      "get": {
        "operationId": "getApiV1SmmDmsByIdMessages",
        "summary": "List the messages of a DM conversation",
        "tags": [
          "smm"
        ],
        "description": "Returns the messages of a single DM conversation owned by the team.",
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "messages"
                  ],
                  "properties": {
                    "messages": {
                      "type": "array",
                      "items": {
                        "additionalProperties": false,
                        "type": "object",
                        "required": [
                          "id",
                          "conversationId",
                          "direction",
                          "text",
                          "attachments"
                        ],
                        "properties": {
                          "id": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "conversationId": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "direction": {
                            "anyOf": [
                              {
                                "type": "string",
                                "enum": [
                                  "in"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "out"
                                ]
                              }
                            ]
                          },
                          "text": {
                            "type": "string"
                          },
                          "attachments": {
                            "type": "array",
                            "items": {
                              "additionalProperties": false,
                              "type": "object",
                              "required": [
                                "type",
                                "url"
                              ],
                              "properties": {
                                "type": {
                                  "anyOf": [
                                    {
                                      "type": "string",
                                      "enum": [
                                        "image"
                                      ]
                                    },
                                    {
                                      "type": "string",
                                      "enum": [
                                        "video"
                                      ]
                                    },
                                    {
                                      "type": "string",
                                      "enum": [
                                        "audio"
                                      ]
                                    },
                                    {
                                      "type": "string",
                                      "enum": [
                                        "file"
                                      ]
                                    }
                                  ]
                                },
                                "url": {
                                  "format": "uri",
                                  "type": "string"
                                },
                                "name": {
                                  "type": "string"
                                }
                              }
                            }
                          },
                          "createdAt": {
                            "format": "date-time",
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/smm/dms/{id}/read": {
      "post": {
        "operationId": "postApiV1SmmDmsByIdRead",
        "summary": "Mark a DM conversation as read",
        "tags": [
          "smm"
        ],
        "description": "Idempotently clears the unread counter for a team-owned DM conversation.",
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "ok"
                  ],
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/smm/dms/{id}/reply": {
      "post": {
        "operationId": "postApiV1SmmDmsByIdReply",
        "summary": "Send a reply on a DM conversation",
        "tags": [
          "smm"
        ],
        "description": "Sends text and/or one Creative Hub attachment on a team-owned DM conversation. Meta receives text and media as separate messages when both are provided.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "minProperties": 1,
                "type": "object",
                "properties": {
                  "text": {
                    "type": "string"
                  },
                  "attachment": {
                    "additionalProperties": false,
                    "type": "object",
                    "required": [
                      "type",
                      "url"
                    ],
                    "properties": {
                      "type": {
                        "anyOf": [
                          {
                            "type": "string",
                            "enum": [
                              "image"
                            ]
                          },
                          {
                            "type": "string",
                            "enum": [
                              "video"
                            ]
                          },
                          {
                            "type": "string",
                            "enum": [
                              "audio"
                            ]
                          },
                          {
                            "type": "string",
                            "enum": [
                              "file"
                            ]
                          }
                        ]
                      },
                      "url": {
                        "format": "uri",
                        "type": "string"
                      },
                      "name": {
                        "type": "string"
                      }
                    }
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "ok"
                  ],
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/smm/hashtag-groups": {
      "get": {
        "operationId": "getApiV1SmmHashtagGroups",
        "summary": "List hashtag groups for the current team",
        "tags": [
          "smm"
        ],
        "description": "Returns all hashtag groups for the current team.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "groups"
                  ],
                  "properties": {
                    "groups": {
                      "type": "array",
                      "items": {
                        "additionalProperties": true,
                        "type": "object",
                        "required": [
                          "id"
                        ],
                        "properties": {
                          "id": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "postApiV1SmmHashtagGroups",
        "summary": "Create a hashtag group",
        "tags": [
          "smm"
        ],
        "description": "Creates a new hashtag group for the current team.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "name",
                  "hashtags"
                ],
                "properties": {
                  "name": {
                    "type": "string"
                  },
                  "hashtags": {
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "group"
                  ],
                  "properties": {
                    "group": {
                      "additionalProperties": true,
                      "type": "object",
                      "required": [
                        "id"
                      ],
                      "properties": {
                        "id": {
                          "type": "string"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/smm/hashtag-groups/{id}": {
      "put": {
        "operationId": "putApiV1SmmHashtagGroupsById",
        "summary": "Update a hashtag group",
        "tags": [
          "smm"
        ],
        "description": "Updates an existing hashtag group by id for the current team.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string"
                  },
                  "hashtags": {
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "group"
                  ],
                  "properties": {
                    "group": {
                      "additionalProperties": true,
                      "type": "object",
                      "required": [
                        "id"
                      ],
                      "properties": {
                        "id": {
                          "type": "string"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      },
      "delete": {
        "operationId": "deleteApiV1SmmHashtagGroupsById",
        "summary": "Delete a hashtag group",
        "tags": [
          "smm"
        ],
        "description": "Deletes a hashtag group by id for the current team.",
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "ok"
                  ],
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/smm/comments": {
      "get": {
        "operationId": "getApiV1SmmComments",
        "summary": "List recent comments across supported connected social accounts",
        "tags": [
          "smm"
        ],
        "description": "Lists live comments for connected Facebook, Instagram and YouTube accounts, optionally filtered. The current TikTok Content Posting connection has no comment-inbox permission and is skipped; demo accounts remain available for product QA.",
        "parameters": [
          {
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "enum": [
                    "all"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "unread"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "replied"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "bookmarked"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "hidden"
                  ]
                }
              ]
            },
            "in": "query",
            "name": "view",
            "required": false
          },
          {
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "enum": [
                    "all"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "facebook"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "instagram"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "tiktok"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "youtube"
                  ]
                }
              ]
            },
            "in": "query",
            "name": "platform",
            "required": false
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "search",
            "required": false
          },
          {
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "enum": [
                    "positive"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "neutral"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "negative"
                  ]
                }
              ]
            },
            "in": "query",
            "name": "sentiment",
            "required": false
          },
          {
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "enum": [
                    "open"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "pending"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "closed"
                  ]
                }
              ]
            },
            "in": "query",
            "name": "status",
            "required": false
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "assignee",
            "required": false
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "tag",
            "required": false
          }
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "comments"
                  ],
                  "properties": {
                    "comments": {
                      "type": "array",
                      "items": {
                        "additionalProperties": false,
                        "type": "object",
                        "required": [
                          "id",
                          "externalId",
                          "accountId",
                          "accountName",
                          "platform",
                          "postId",
                          "text",
                          "authorName"
                        ],
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "externalId": {
                            "type": "string"
                          },
                          "accountId": {
                            "type": "string"
                          },
                          "accountName": {
                            "type": "string"
                          },
                          "platform": {
                            "type": "string"
                          },
                          "postId": {
                            "type": "string"
                          },
                          "text": {
                            "type": "string"
                          },
                          "authorName": {
                            "type": "string"
                          },
                          "authorAvatarUrl": {
                            "type": "string"
                          },
                          "authorExternalId": {
                            "type": "string"
                          },
                          "authorProfileUrl": {
                            "type": "string"
                          },
                          "authorUsername": {
                            "type": "string"
                          },
                          "createdAt": {
                            "type": "string"
                          },
                          "likeCount": {
                            "type": "number"
                          },
                          "postUrl": {
                            "type": "string"
                          },
                          "postContext": {
                            "anyOf": [
                              {
                                "additionalProperties": false,
                                "type": "object",
                                "required": [
                                  "campaign",
                                  "id",
                                  "mediaType",
                                  "mediaUrl",
                                  "text"
                                ],
                                "properties": {
                                  "campaign": {
                                    "anyOf": [
                                      {
                                        "type": "string"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "id": {
                                    "type": "string"
                                  },
                                  "mediaType": {
                                    "anyOf": [
                                      {
                                        "type": "string"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "mediaUrl": {
                                    "anyOf": [
                                      {
                                        "type": "string"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "text": {
                                    "type": "string"
                                  }
                                }
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "assignedTo": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "intent": {
                            "anyOf": [
                              {
                                "type": "string",
                                "enum": [
                                  "question"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "complaint"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "lead"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "praise"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "spam"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "other"
                                ]
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "isBookmarked": {
                            "type": "boolean"
                          },
                          "isHidden": {
                            "type": "boolean"
                          },
                          "isRead": {
                            "type": "boolean"
                          },
                          "moderationDecision": {
                            "anyOf": [
                              {
                                "type": "string",
                                "enum": [
                                  "hide"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "leave"
                                ]
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "moderationFeedback": {
                            "anyOf": [
                              {
                                "type": "string",
                                "enum": [
                                  "up"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "down"
                                ]
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "moderationReasoning": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "replied": {
                            "type": "boolean"
                          },
                          "sentiment": {
                            "anyOf": [
                              {
                                "type": "string",
                                "enum": [
                                  "positive"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "neutral"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "negative"
                                ]
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "status": {
                            "anyOf": [
                              {
                                "type": "string",
                                "enum": [
                                  "open"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "pending"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "closed"
                                ]
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "tags": {
                            "type": "array",
                            "items": {
                              "type": "string"
                            }
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/smm/comments/reply": {
      "post": {
        "operationId": "postApiV1SmmCommentsReply",
        "summary": "Reply to a comment",
        "tags": [
          "smm"
        ],
        "description": "Posts a public reply to a comment on the given connected account. `applied` is false when the connected platform has no supported reply capability (the current TikTok Content Posting connection is skipped).",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "accountId",
                  "commentId",
                  "message"
                ],
                "properties": {
                  "accountId": {
                    "type": "string"
                  },
                  "commentId": {
                    "type": "string"
                  },
                  "message": {
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "ok",
                    "applied"
                  ],
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    },
                    "applied": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/smm/comments/read": {
      "post": {
        "operationId": "postApiV1SmmCommentsRead",
        "summary": "Mark a comment as read or unread",
        "tags": [
          "smm"
        ],
        "description": "Marks a comment as read or unread for the current team.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "accountId",
                  "commentId",
                  "read"
                ],
                "properties": {
                  "accountId": {
                    "type": "string"
                  },
                  "commentId": {
                    "type": "string"
                  },
                  "read": {
                    "type": "boolean"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "ok"
                  ],
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/smm/comments/bookmark": {
      "post": {
        "operationId": "postApiV1SmmCommentsBookmark",
        "summary": "Bookmark or un-bookmark a comment",
        "tags": [
          "smm"
        ],
        "description": "Bookmarks or un-bookmarks a comment for the current team.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "accountId",
                  "commentId",
                  "bookmarked"
                ],
                "properties": {
                  "accountId": {
                    "type": "string"
                  },
                  "commentId": {
                    "type": "string"
                  },
                  "bookmarked": {
                    "type": "boolean"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "ok"
                  ],
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/smm/comments/hide": {
      "post": {
        "operationId": "postApiV1SmmCommentsHide",
        "summary": "Hide or unhide a comment",
        "tags": [
          "smm"
        ],
        "description": "Hides or unhides a comment on the connected account. `applied` is false when the connected platform has no supported moderation capability (the current TikTok Content Posting connection is skipped).",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "accountId",
                  "commentId",
                  "hidden"
                ],
                "properties": {
                  "accountId": {
                    "type": "string"
                  },
                  "commentId": {
                    "type": "string"
                  },
                  "hidden": {
                    "type": "boolean"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "ok",
                    "applied"
                  ],
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    },
                    "applied": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/smm/comments/suggest-reply": {
      "post": {
        "operationId": "postApiV1SmmCommentsSuggestReply",
        "summary": "AI-draft a suggested reply for a comment (human-in-the-loop)",
        "tags": [
          "smm"
        ],
        "description": "Generates an AI-drafted reply using the selected account agent knowledge, tone and language when configured. The operator must review it before sending.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "accountId",
                  "commentText"
                ],
                "properties": {
                  "accountId": {
                    "type": "string"
                  },
                  "commentText": {
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "suggestion"
                  ],
                  "properties": {
                    "suggestion": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "402": {
            "description": "Response 402",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/smm/comments/moderate/run": {
      "post": {
        "operationId": "postApiV1SmmCommentsModerateRun",
        "summary": "Run AI moderation over explicitly selected comments",
        "tags": [
          "smm"
        ],
        "description": "Triggers an on-demand AI moderation pass only for the explicit account/comment targets currently visible to the operator. Empty targets perform no work and consume no credits.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "targets"
                ],
                "properties": {
                  "targets": {
                    "maxItems": 50,
                    "type": "array",
                    "items": {
                      "additionalProperties": false,
                      "type": "object",
                      "required": [
                        "accountId",
                        "commentId"
                      ],
                      "properties": {
                        "accountId": {
                          "type": "string"
                        },
                        "commentId": {
                          "type": "string"
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "result"
                  ],
                  "properties": {
                    "result": {
                      "additionalProperties": false,
                      "type": "object",
                      "required": [
                        "hidden",
                        "processed"
                      ],
                      "properties": {
                        "hidden": {
                          "type": "number"
                        },
                        "processed": {
                          "type": "number"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "402": {
            "description": "Response 402",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/smm/comments/moderation-feedback": {
      "post": {
        "operationId": "postApiV1SmmCommentsModerationFeedback",
        "summary": "Record up/down feedback on an AI moderation decision",
        "tags": [
          "smm"
        ],
        "description": "Records up/down human feedback on an AI moderation decision for a comment.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "accountId",
                  "commentId",
                  "feedback"
                ],
                "properties": {
                  "accountId": {
                    "type": "string"
                  },
                  "commentId": {
                    "type": "string"
                  },
                  "feedback": {
                    "anyOf": [
                      {
                        "type": "string",
                        "enum": [
                          "up"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "down"
                        ]
                      }
                    ]
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "ok"
                  ],
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/smm/comments/classify/run": {
      "post": {
        "operationId": "postApiV1SmmCommentsClassifyRun",
        "summary": "Run AI sentiment/intent classification over explicitly selected comments",
        "tags": [
          "smm"
        ],
        "description": "Triggers an on-demand AI classification pass only for the explicit account/comment targets currently visible to the operator. Empty targets perform no work and consume no credits.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "targets"
                ],
                "properties": {
                  "targets": {
                    "maxItems": 50,
                    "type": "array",
                    "items": {
                      "additionalProperties": false,
                      "type": "object",
                      "required": [
                        "accountId",
                        "commentId"
                      ],
                      "properties": {
                        "accountId": {
                          "type": "string"
                        },
                        "commentId": {
                          "type": "string"
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "result"
                  ],
                  "properties": {
                    "result": {
                      "additionalProperties": false,
                      "type": "object",
                      "required": [
                        "classified",
                        "processed"
                      ],
                      "properties": {
                        "classified": {
                          "type": "number"
                        },
                        "processed": {
                          "type": "number"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "402": {
            "description": "Response 402",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/smm/comments/assign": {
      "post": {
        "operationId": "postApiV1SmmCommentsAssign",
        "summary": "Assign (or unassign) a comment to a team member",
        "tags": [
          "smm"
        ],
        "description": "Assigns a comment to a team member, or clears the assignment when assignedTo is null.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "accountId",
                  "commentId",
                  "assignedTo"
                ],
                "properties": {
                  "accountId": {
                    "type": "string"
                  },
                  "commentId": {
                    "type": "string"
                  },
                  "assignedTo": {
                    "anyOf": [
                      {
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "ok"
                  ],
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/smm/comments/status": {
      "post": {
        "operationId": "postApiV1SmmCommentsStatus",
        "summary": "Set the conversation status of a comment",
        "tags": [
          "smm"
        ],
        "description": "Sets the conversation status (open/pending/closed) of a comment for the current team.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "accountId",
                  "commentId",
                  "status"
                ],
                "properties": {
                  "accountId": {
                    "type": "string"
                  },
                  "commentId": {
                    "type": "string"
                  },
                  "status": {
                    "anyOf": [
                      {
                        "type": "string",
                        "enum": [
                          "open"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "pending"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "closed"
                        ]
                      }
                    ]
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "ok"
                  ],
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/smm/comments/tags": {
      "post": {
        "operationId": "postApiV1SmmCommentsTags",
        "summary": "Replace the tag set of a comment",
        "tags": [
          "smm"
        ],
        "description": "Replaces the full tag set of a comment for the current team.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "accountId",
                  "commentId",
                  "tags"
                ],
                "properties": {
                  "accountId": {
                    "type": "string"
                  },
                  "commentId": {
                    "type": "string"
                  },
                  "tags": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "ok"
                  ],
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/smm/comments/notes": {
      "get": {
        "operationId": "getApiV1SmmCommentsNotes",
        "summary": "List internal notes on a comment",
        "tags": [
          "smm"
        ],
        "description": "Lists the internal team notes attached to a comment.",
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "accountId",
            "required": true
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "commentId",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "notes"
                  ],
                  "properties": {
                    "notes": {
                      "type": "array",
                      "items": {
                        "additionalProperties": true,
                        "type": "object",
                        "required": [
                          "id"
                        ],
                        "properties": {
                          "id": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "postApiV1SmmCommentsNotes",
        "summary": "Add an internal note to a comment",
        "tags": [
          "smm"
        ],
        "description": "Adds an internal team note to a comment, authored by the current user.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "accountId",
                  "commentId",
                  "body"
                ],
                "properties": {
                  "accountId": {
                    "type": "string"
                  },
                  "commentId": {
                    "type": "string"
                  },
                  "body": {
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "note"
                  ],
                  "properties": {
                    "note": {
                      "additionalProperties": true,
                      "type": "object",
                      "required": [
                        "id"
                      ],
                      "properties": {
                        "id": {
                          "type": "string"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/smm/comments/bulk": {
      "post": {
        "operationId": "postApiV1SmmCommentsBulk",
        "summary": "Apply a bulk action (hide/unhide/read/unread) to multiple comments",
        "tags": [
          "smm"
        ],
        "description": "Applies a bulk action (hide/unhide/read/unread) to multiple comments on one account.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "accountId",
                  "commentIds",
                  "action"
                ],
                "properties": {
                  "accountId": {
                    "type": "string"
                  },
                  "commentIds": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  },
                  "action": {
                    "anyOf": [
                      {
                        "type": "string",
                        "enum": [
                          "hide"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "unhide"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "read"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "unread"
                        ]
                      }
                    ]
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "ok",
                    "count"
                  ],
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    },
                    "count": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/smm/media/upload": {
      "post": {
        "operationId": "postApiV1SmmMediaUpload",
        "summary": "Upload a media file to the SMM library",
        "tags": [
          "smm"
        ],
        "description": "Uploads a media file into the team media library and returns the stored asset. Accepts JPEG/PNG/WebP/GIF images and MP4/MOV videos; any other content type is rejected with 415.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "asset"
                  ],
                  "properties": {
                    "asset": {
                      "type": "object",
                      "required": [
                        "id",
                        "url",
                        "type",
                        "name"
                      ],
                      "properties": {
                        "id": {
                          "type": "string"
                        },
                        "url": {
                          "type": "string"
                        },
                        "type": {
                          "type": "string"
                        },
                        "name": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "415": {
            "description": "Response 415",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/smm/media": {
      "get": {
        "operationId": "getApiV1SmmMedia",
        "summary": "List media assets in the current team library",
        "tags": [
          "smm"
        ],
        "description": "Returns all media assets in the current team library.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "assets"
                  ],
                  "properties": {
                    "assets": {
                      "type": "array",
                      "items": {
                        "additionalProperties": true,
                        "type": "object",
                        "required": [
                          "id"
                        ],
                        "properties": {
                          "id": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "postApiV1SmmMedia",
        "summary": "Add a media asset to the team library",
        "tags": [
          "smm"
        ],
        "description": "Adds a new media asset to the current team library.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "url",
                  "type"
                ],
                "properties": {
                  "url": {
                    "type": "string"
                  },
                  "type": {
                    "anyOf": [
                      {
                        "type": "string",
                        "enum": [
                          "image"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "video"
                        ]
                      }
                    ]
                  },
                  "name": {
                    "anyOf": [
                      {
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "asset"
                  ],
                  "properties": {
                    "asset": {
                      "additionalProperties": true,
                      "type": "object",
                      "required": [
                        "id"
                      ],
                      "properties": {
                        "id": {
                          "type": "string"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/smm/media/{id}": {
      "delete": {
        "operationId": "deleteApiV1SmmMediaById",
        "summary": "Delete a media asset from the team library",
        "tags": [
          "smm"
        ],
        "description": "Deletes a media asset by id from the current team library.",
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "ok"
                  ],
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/smm/notifications": {
      "get": {
        "operationId": "getApiV1SmmNotifications",
        "summary": "List notifications for the current team",
        "tags": [
          "smm"
        ],
        "description": "Returns the in-app notifications for the current team, optionally only the unread ones.",
        "parameters": [
          {
            "schema": {
              "anyOf": [
                {
                  "type": "boolean"
                },
                {
                  "type": "string"
                }
              ]
            },
            "in": "query",
            "name": "unread",
            "required": false
          }
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "notifications"
                  ],
                  "properties": {
                    "notifications": {
                      "type": "array",
                      "items": {
                        "additionalProperties": true,
                        "type": "object",
                        "required": [
                          "id"
                        ],
                        "properties": {
                          "id": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/smm/notifications/unread-count": {
      "get": {
        "operationId": "getApiV1SmmNotificationsUnreadCount",
        "summary": "Count unread notifications for the current team",
        "tags": [
          "smm"
        ],
        "description": "Returns the number of unread notifications for the current team.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "count"
                  ],
                  "properties": {
                    "count": {
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/smm/notifications/{id}/read": {
      "post": {
        "operationId": "postApiV1SmmNotificationsByIdRead",
        "summary": "Mark a notification as read",
        "tags": [
          "smm"
        ],
        "description": "Marks a single notification as read for the current team.",
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "ok"
                  ],
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/smm/notifications/read-all": {
      "post": {
        "operationId": "postApiV1SmmNotificationsReadAll",
        "summary": "Mark all notifications as read for the current team",
        "tags": [
          "smm"
        ],
        "description": "Marks every notification as read for the current team.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "ok"
                  ],
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/smm/notifications/run": {
      "post": {
        "operationId": "postApiV1SmmNotificationsRun",
        "summary": "Build notifications for the current team now",
        "tags": [
          "smm"
        ],
        "description": "Triggers an on-demand notification build pass and returns the number created.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "result"
                  ],
                  "properties": {
                    "result": {
                      "additionalProperties": true,
                      "type": "object",
                      "required": [
                        "created"
                      ],
                      "properties": {
                        "created": {
                          "type": "number"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/smm/oauth/{provider}/start": {
      "get": {
        "operationId": "getApiV1SmmOauthByProviderStart",
        "summary": "Get the OAuth authorize URL for an SMM provider",
        "tags": [
          "smm"
        ],
        "description": "Returns the provider OAuth authorize URL the frontend redirects the browser to for connecting an account. Guarded by the per-organization SMM account quota: over the plan limit it returns 403 PLAN_LIMIT_EXCEEDED before any provider redirect.",
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "in": "path",
            "name": "provider",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "url"
                  ],
                  "properties": {
                    "url": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "resource": {
                      "type": "string"
                    },
                    "current": {
                      "type": "number"
                    },
                    "max": {
                      "type": "number"
                    },
                    "plan": {
                      "type": "string"
                    },
                    "reason": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/smm/oauth/{provider}/callback": {
      "get": {
        "operationId": "getApiV1SmmOauthByProviderCallback",
        "summary": "Complete the OAuth callback for an SMM provider",
        "tags": [
          "smm"
        ],
        "description": "Completes the provider OAuth exchange and account connection, then redirects the browser back to the accounts page with a success or error marker. Reached by the provider browser redirect; authenticated by the signed one-time OAuth state instead of a bearer token.",
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "code",
            "required": false
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "state",
            "required": false
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "error",
            "required": false
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "error_description",
            "required": false
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "path",
            "name": "provider",
            "required": true
          }
        ],
        "responses": {
          "302": {
            "description": "Redirect to the frontend accounts page with a ?connected= (success) or ?error= (failure) marker — provider errors, invalid state and connect failures all land here.",
            "content": {
              "application/json": {
                "schema": {
                  "description": "Redirect to the frontend accounts page with a ?connected= (success) or ?error= (failure) marker — provider errors, invalid state and connect failures all land here.",
                  "type": "string"
                }
              }
            }
          },
          "500": {
            "description": "Unexpected failure outside the graceful redirect path.",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "description": "Unexpected failure outside the graceful redirect path.",
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/smm/posts": {
      "get": {
        "operationId": "getApiV1SmmPosts",
        "summary": "List SMM posts (calendar/list), optionally filtered by date range and status",
        "tags": [
          "smm"
        ],
        "description": "Lists SMM posts for the current team, optionally filtered by date range, status, approval or tag.",
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "from",
            "required": false
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "to",
            "required": false
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "status",
            "required": false
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "approval",
            "required": false
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "tag",
            "required": false
          }
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "posts"
                  ],
                  "properties": {
                    "posts": {
                      "type": "array",
                      "items": {
                        "additionalProperties": false,
                        "type": "object",
                        "required": [
                          "id",
                          "team_id",
                          "status",
                          "content",
                          "scheduled_at",
                          "published_at",
                          "created_by",
                          "labels",
                          "approval_status",
                          "approved_by",
                          "created_at",
                          "updated_at",
                          "deleted_at"
                        ],
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "team_id": {
                            "type": "string"
                          },
                          "status": {
                            "type": "string"
                          },
                          "content": {
                            "additionalProperties": false,
                            "type": "object",
                            "properties": {
                              "text": {
                                "type": "string"
                              },
                              "campaign": {
                                "type": "string"
                              },
                              "mediaUrls": {
                                "type": "array",
                                "items": {
                                  "type": "string"
                                }
                              },
                              "mediaType": {
                                "type": "string"
                              },
                              "firstComment": {
                                "type": "string"
                              },
                              "accountIds": {
                                "type": "array",
                                "items": {
                                  "type": "string"
                                }
                              }
                            }
                          },
                          "scheduled_at": {
                            "anyOf": [
                              {
                                "format": "date-time",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "published_at": {
                            "anyOf": [
                              {
                                "format": "date-time",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "created_by": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "labels": {
                            "anyOf": [
                              {
                                "type": "array",
                                "items": {
                                  "type": "string"
                                }
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "approval_status": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "approved_by": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "created_at": {
                            "format": "date-time",
                            "type": "string"
                          },
                          "updated_at": {
                            "anyOf": [
                              {
                                "format": "date-time",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "deleted_at": {
                            "anyOf": [
                              {
                                "format": "date-time",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "postApiV1SmmPosts",
        "summary": "Create or update an SMM post (draft or scheduled)",
        "tags": [
          "smm"
        ],
        "description": "Creates a new SMM post or updates an existing one (draft or scheduled) for the current team.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "content"
                ],
                "properties": {
                  "id": {
                    "type": "string"
                  },
                  "content": {
                    "additionalProperties": false,
                    "type": "object",
                    "properties": {
                      "text": {
                        "type": "string"
                      },
                      "campaign": {
                        "type": "string"
                      },
                      "mediaUrls": {
                        "type": "array",
                        "items": {
                          "type": "string"
                        }
                      },
                      "mediaType": {
                        "type": "string"
                      },
                      "firstComment": {
                        "type": "string"
                      },
                      "accountIds": {
                        "type": "array",
                        "items": {
                          "type": "string"
                        }
                      }
                    }
                  },
                  "scheduledAt": {
                    "anyOf": [
                      {
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "labels": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "post"
                  ],
                  "properties": {
                    "post": {
                      "additionalProperties": false,
                      "type": "object",
                      "required": [
                        "id",
                        "team_id",
                        "status",
                        "content",
                        "scheduled_at",
                        "published_at",
                        "created_by",
                        "labels",
                        "approval_status",
                        "approved_by",
                        "created_at",
                        "updated_at",
                        "deleted_at"
                      ],
                      "properties": {
                        "id": {
                          "type": "string"
                        },
                        "team_id": {
                          "type": "string"
                        },
                        "status": {
                          "type": "string"
                        },
                        "content": {
                          "additionalProperties": false,
                          "type": "object",
                          "properties": {
                            "text": {
                              "type": "string"
                            },
                            "campaign": {
                              "type": "string"
                            },
                            "mediaUrls": {
                              "type": "array",
                              "items": {
                                "type": "string"
                              }
                            },
                            "mediaType": {
                              "type": "string"
                            },
                            "firstComment": {
                              "type": "string"
                            },
                            "accountIds": {
                              "type": "array",
                              "items": {
                                "type": "string"
                              }
                            }
                          }
                        },
                        "scheduled_at": {
                          "anyOf": [
                            {
                              "format": "date-time",
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "published_at": {
                          "anyOf": [
                            {
                              "format": "date-time",
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "created_by": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "labels": {
                          "anyOf": [
                            {
                              "type": "array",
                              "items": {
                                "type": "string"
                              }
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "approval_status": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "approved_by": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "created_at": {
                          "format": "date-time",
                          "type": "string"
                        },
                        "updated_at": {
                          "anyOf": [
                            {
                              "format": "date-time",
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "deleted_at": {
                          "anyOf": [
                            {
                              "format": "date-time",
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/smm/posts/bulk": {
      "post": {
        "operationId": "postApiV1SmmPostsBulk",
        "summary": "Bulk create SMM posts (drafts or scheduled)",
        "tags": [
          "smm"
        ],
        "description": "Creates multiple SMM posts (drafts or scheduled) in a single call for the current team.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "posts"
                ],
                "properties": {
                  "posts": {
                    "type": "array",
                    "items": {
                      "additionalProperties": false,
                      "type": "object",
                      "required": [
                        "content"
                      ],
                      "properties": {
                        "id": {
                          "type": "string"
                        },
                        "content": {
                          "additionalProperties": false,
                          "type": "object",
                          "properties": {
                            "text": {
                              "type": "string"
                            },
                            "campaign": {
                              "type": "string"
                            },
                            "mediaUrls": {
                              "type": "array",
                              "items": {
                                "type": "string"
                              }
                            },
                            "mediaType": {
                              "type": "string"
                            },
                            "firstComment": {
                              "type": "string"
                            },
                            "accountIds": {
                              "type": "array",
                              "items": {
                                "type": "string"
                              }
                            }
                          }
                        },
                        "scheduledAt": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "labels": {
                          "type": "array",
                          "items": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "created"
                  ],
                  "properties": {
                    "created": {
                      "minimum": 0,
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/smm/posts/{id}/approval": {
      "post": {
        "operationId": "postApiV1SmmPostsByIdApproval",
        "summary": "Submit, approve or reject an SMM post for approval",
        "tags": [
          "smm"
        ],
        "description": "Submits, approves or rejects an SMM post in the approval workflow.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "action"
                ],
                "properties": {
                  "action": {
                    "anyOf": [
                      {
                        "type": "string",
                        "enum": [
                          "submit"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "approve"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "reject"
                        ]
                      }
                    ]
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "post"
                  ],
                  "properties": {
                    "post": {
                      "additionalProperties": false,
                      "type": "object",
                      "required": [
                        "id",
                        "team_id",
                        "status",
                        "content",
                        "scheduled_at",
                        "published_at",
                        "created_by",
                        "labels",
                        "approval_status",
                        "approved_by",
                        "created_at",
                        "updated_at",
                        "deleted_at"
                      ],
                      "properties": {
                        "id": {
                          "type": "string"
                        },
                        "team_id": {
                          "type": "string"
                        },
                        "status": {
                          "type": "string"
                        },
                        "content": {
                          "additionalProperties": false,
                          "type": "object",
                          "properties": {
                            "text": {
                              "type": "string"
                            },
                            "campaign": {
                              "type": "string"
                            },
                            "mediaUrls": {
                              "type": "array",
                              "items": {
                                "type": "string"
                              }
                            },
                            "mediaType": {
                              "type": "string"
                            },
                            "firstComment": {
                              "type": "string"
                            },
                            "accountIds": {
                              "type": "array",
                              "items": {
                                "type": "string"
                              }
                            }
                          }
                        },
                        "scheduled_at": {
                          "anyOf": [
                            {
                              "format": "date-time",
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "published_at": {
                          "anyOf": [
                            {
                              "format": "date-time",
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "created_by": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "labels": {
                          "anyOf": [
                            {
                              "type": "array",
                              "items": {
                                "type": "string"
                              }
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "approval_status": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "approved_by": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "created_at": {
                          "format": "date-time",
                          "type": "string"
                        },
                        "updated_at": {
                          "anyOf": [
                            {
                              "format": "date-time",
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "deleted_at": {
                          "anyOf": [
                            {
                              "format": "date-time",
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/smm/posts/{id}/queue": {
      "post": {
        "operationId": "postApiV1SmmPostsByIdQueue",
        "summary": "Add an SMM post to the publishing queue (next free slot)",
        "tags": [
          "smm"
        ],
        "description": "Adds an SMM post to the publishing queue at the next free slot for its category.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "category": {
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "post"
                  ],
                  "properties": {
                    "post": {
                      "additionalProperties": false,
                      "type": "object",
                      "required": [
                        "id",
                        "team_id",
                        "status",
                        "content",
                        "scheduled_at",
                        "published_at",
                        "created_by",
                        "labels",
                        "approval_status",
                        "approved_by",
                        "created_at",
                        "updated_at",
                        "deleted_at"
                      ],
                      "properties": {
                        "id": {
                          "type": "string"
                        },
                        "team_id": {
                          "type": "string"
                        },
                        "status": {
                          "type": "string"
                        },
                        "content": {
                          "additionalProperties": false,
                          "type": "object",
                          "properties": {
                            "text": {
                              "type": "string"
                            },
                            "campaign": {
                              "type": "string"
                            },
                            "mediaUrls": {
                              "type": "array",
                              "items": {
                                "type": "string"
                              }
                            },
                            "mediaType": {
                              "type": "string"
                            },
                            "firstComment": {
                              "type": "string"
                            },
                            "accountIds": {
                              "type": "array",
                              "items": {
                                "type": "string"
                              }
                            }
                          }
                        },
                        "scheduled_at": {
                          "anyOf": [
                            {
                              "format": "date-time",
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "published_at": {
                          "anyOf": [
                            {
                              "format": "date-time",
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "created_by": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "labels": {
                          "anyOf": [
                            {
                              "type": "array",
                              "items": {
                                "type": "string"
                              }
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "approval_status": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "approved_by": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "created_at": {
                          "format": "date-time",
                          "type": "string"
                        },
                        "updated_at": {
                          "anyOf": [
                            {
                              "format": "date-time",
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "deleted_at": {
                          "anyOf": [
                            {
                              "format": "date-time",
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/smm/posts/{id}": {
      "get": {
        "operationId": "getApiV1SmmPostsById",
        "summary": "Get a single SMM post",
        "tags": [
          "smm"
        ],
        "description": "Returns a single SMM post by id for the current team.",
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "post"
                  ],
                  "properties": {
                    "post": {
                      "anyOf": [
                        {
                          "additionalProperties": false,
                          "type": "object",
                          "required": [
                            "id",
                            "team_id",
                            "status",
                            "content",
                            "scheduled_at",
                            "published_at",
                            "created_by",
                            "labels",
                            "approval_status",
                            "approved_by",
                            "created_at",
                            "updated_at",
                            "deleted_at"
                          ],
                          "properties": {
                            "id": {
                              "type": "string"
                            },
                            "team_id": {
                              "type": "string"
                            },
                            "status": {
                              "type": "string"
                            },
                            "content": {
                              "additionalProperties": false,
                              "type": "object",
                              "properties": {
                                "text": {
                                  "type": "string"
                                },
                                "campaign": {
                                  "type": "string"
                                },
                                "mediaUrls": {
                                  "type": "array",
                                  "items": {
                                    "type": "string"
                                  }
                                },
                                "mediaType": {
                                  "type": "string"
                                },
                                "firstComment": {
                                  "type": "string"
                                },
                                "accountIds": {
                                  "type": "array",
                                  "items": {
                                    "type": "string"
                                  }
                                }
                              }
                            },
                            "scheduled_at": {
                              "anyOf": [
                                {
                                  "format": "date-time",
                                  "type": "string"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "published_at": {
                              "anyOf": [
                                {
                                  "format": "date-time",
                                  "type": "string"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "created_by": {
                              "anyOf": [
                                {
                                  "type": "string"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "labels": {
                              "anyOf": [
                                {
                                  "type": "array",
                                  "items": {
                                    "type": "string"
                                  }
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "approval_status": {
                              "anyOf": [
                                {
                                  "type": "string"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "approved_by": {
                              "anyOf": [
                                {
                                  "type": "string"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "created_at": {
                              "format": "date-time",
                              "type": "string"
                            },
                            "updated_at": {
                              "anyOf": [
                                {
                                  "format": "date-time",
                                  "type": "string"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "deleted_at": {
                              "anyOf": [
                                {
                                  "format": "date-time",
                                  "type": "string"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            }
                          }
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/smm/posts/{id}/schedule": {
      "patch": {
        "operationId": "patchApiV1SmmPostsByIdSchedule",
        "summary": "Schedule an SMM post at a date/time",
        "tags": [
          "smm"
        ],
        "description": "Schedules an SMM post to publish at the given date/time.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "scheduledAt"
                ],
                "properties": {
                  "scheduledAt": {
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "post"
                  ],
                  "properties": {
                    "post": {
                      "additionalProperties": false,
                      "type": "object",
                      "required": [
                        "id",
                        "team_id",
                        "status",
                        "content",
                        "scheduled_at",
                        "published_at",
                        "created_by",
                        "labels",
                        "approval_status",
                        "approved_by",
                        "created_at",
                        "updated_at",
                        "deleted_at"
                      ],
                      "properties": {
                        "id": {
                          "type": "string"
                        },
                        "team_id": {
                          "type": "string"
                        },
                        "status": {
                          "type": "string"
                        },
                        "content": {
                          "additionalProperties": false,
                          "type": "object",
                          "properties": {
                            "text": {
                              "type": "string"
                            },
                            "campaign": {
                              "type": "string"
                            },
                            "mediaUrls": {
                              "type": "array",
                              "items": {
                                "type": "string"
                              }
                            },
                            "mediaType": {
                              "type": "string"
                            },
                            "firstComment": {
                              "type": "string"
                            },
                            "accountIds": {
                              "type": "array",
                              "items": {
                                "type": "string"
                              }
                            }
                          }
                        },
                        "scheduled_at": {
                          "anyOf": [
                            {
                              "format": "date-time",
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "published_at": {
                          "anyOf": [
                            {
                              "format": "date-time",
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "created_by": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "labels": {
                          "anyOf": [
                            {
                              "type": "array",
                              "items": {
                                "type": "string"
                              }
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "approval_status": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "approved_by": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "created_at": {
                          "format": "date-time",
                          "type": "string"
                        },
                        "updated_at": {
                          "anyOf": [
                            {
                              "format": "date-time",
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "deleted_at": {
                          "anyOf": [
                            {
                              "format": "date-time",
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/smm/scheduler/run": {
      "post": {
        "operationId": "postApiV1SmmSchedulerRun",
        "summary": "Run the SMM scheduler now for the current team (publish due scheduled posts)",
        "tags": [
          "smm"
        ],
        "description": "Runs the SMM scheduler immediately for the current team, publishing any due scheduled posts.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "result"
                  ],
                  "properties": {
                    "result": {
                      "$comment": "json-value",
                      "description": "Arbitrary JSON value."
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/smm/queue-slots": {
      "get": {
        "operationId": "getApiV1SmmQueueSlots",
        "summary": "List publishing queue slots for the current team",
        "tags": [
          "smm"
        ],
        "description": "Returns all publishing queue slots for the current team.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "slots"
                  ],
                  "properties": {
                    "slots": {
                      "type": "array",
                      "items": {
                        "additionalProperties": true,
                        "type": "object",
                        "required": [
                          "id"
                        ],
                        "properties": {
                          "id": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "postApiV1SmmQueueSlots",
        "summary": "Create a publishing queue slot",
        "tags": [
          "smm"
        ],
        "description": "Creates a new publishing queue slot for the current team.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "dayOfWeek",
                  "hour"
                ],
                "properties": {
                  "socialAccountId": {
                    "anyOf": [
                      {
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "category": {
                    "anyOf": [
                      {
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "dayOfWeek": {
                    "minimum": 0,
                    "maximum": 6,
                    "type": "integer"
                  },
                  "hour": {
                    "minimum": 0,
                    "maximum": 23,
                    "type": "integer"
                  },
                  "minute": {
                    "minimum": 0,
                    "maximum": 59,
                    "type": "integer"
                  },
                  "timezone": {
                    "anyOf": [
                      {
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "slot"
                  ],
                  "properties": {
                    "slot": {
                      "additionalProperties": true,
                      "type": "object",
                      "required": [
                        "id"
                      ],
                      "properties": {
                        "id": {
                          "type": "string"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/smm/queue-slots/{id}": {
      "put": {
        "operationId": "putApiV1SmmQueueSlotsById",
        "summary": "Update a publishing queue slot",
        "tags": [
          "smm"
        ],
        "description": "Updates an existing publishing queue slot by id for the current team.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "socialAccountId": {
                    "anyOf": [
                      {
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "category": {
                    "anyOf": [
                      {
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "dayOfWeek": {
                    "minimum": 0,
                    "maximum": 6,
                    "type": "integer"
                  },
                  "hour": {
                    "minimum": 0,
                    "maximum": 23,
                    "type": "integer"
                  },
                  "minute": {
                    "minimum": 0,
                    "maximum": 59,
                    "type": "integer"
                  },
                  "timezone": {
                    "anyOf": [
                      {
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "enabled": {
                    "type": "boolean"
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "slot"
                  ],
                  "properties": {
                    "slot": {
                      "additionalProperties": true,
                      "type": "object",
                      "required": [
                        "id"
                      ],
                      "properties": {
                        "id": {
                          "type": "string"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      },
      "delete": {
        "operationId": "deleteApiV1SmmQueueSlotsById",
        "summary": "Delete a publishing queue slot",
        "tags": [
          "smm"
        ],
        "description": "Deletes a publishing queue slot by id for the current team.",
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "ok"
                  ],
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/smm/reports/overview": {
      "get": {
        "operationId": "getApiV1SmmReportsOverview",
        "summary": "Analytics report (totals, per-platform, per-account, timeseries, previous period)",
        "tags": [
          "smm"
        ],
        "description": "Aggregate analytics report for the current team over the [from, to] window (default: last 30 days), windowed on the parent post publish time. Returns totals, per-platform and per-account breakdowns, a daily timeseries, and the same-length preceding period for comparison. Optionally scoped to specific account ids.",
        "parameters": [
          {
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "array",
                  "items": {
                    "type": "string"
                  }
                }
              ]
            },
            "in": "query",
            "name": "accountIds",
            "required": false,
            "description": "Restrict the report to these social account ids: a comma-separated string or a repeated query param. Omit for all accounts."
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "from",
            "required": false,
            "description": "Inclusive window start (ISO 8601). Defaults to 30 days before `to`. Unparseable values are ignored."
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "to",
            "required": false,
            "description": "Inclusive window end (ISO 8601). Defaults to now. Unparseable values are ignored."
          }
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "report"
                  ],
                  "properties": {
                    "report": {
                      "additionalProperties": false,
                      "type": "object",
                      "required": [
                        "perAccount",
                        "perPlatform",
                        "previous",
                        "timeseries",
                        "totals"
                      ],
                      "properties": {
                        "perAccount": {
                          "type": "array",
                          "items": {
                            "additionalProperties": false,
                            "type": "object",
                            "required": [
                              "accountId",
                              "engagement",
                              "followers",
                              "impressions",
                              "platform"
                            ],
                            "properties": {
                              "accountId": {
                                "type": "string"
                              },
                              "engagement": {
                                "type": "integer"
                              },
                              "followers": {
                                "type": "integer"
                              },
                              "impressions": {
                                "type": "integer"
                              },
                              "platform": {
                                "type": "string"
                              }
                            }
                          }
                        },
                        "perPlatform": {
                          "type": "array",
                          "items": {
                            "additionalProperties": false,
                            "type": "object",
                            "required": [
                              "engagement",
                              "impressions",
                              "platform",
                              "reach"
                            ],
                            "properties": {
                              "engagement": {
                                "type": "integer"
                              },
                              "impressions": {
                                "type": "integer"
                              },
                              "platform": {
                                "type": "string"
                              },
                              "reach": {
                                "type": "integer"
                              }
                            }
                          }
                        },
                        "previous": {
                          "additionalProperties": false,
                          "type": "object",
                          "required": [
                            "engagement",
                            "impressions",
                            "reach"
                          ],
                          "properties": {
                            "engagement": {
                              "type": "integer"
                            },
                            "impressions": {
                              "type": "integer"
                            },
                            "reach": {
                              "type": "integer"
                            }
                          }
                        },
                        "timeseries": {
                          "type": "array",
                          "items": {
                            "additionalProperties": false,
                            "type": "object",
                            "required": [
                              "date",
                              "engagement",
                              "followers",
                              "impressions"
                            ],
                            "properties": {
                              "date": {
                                "description": "UTC day bucket (YYYY-MM-DD).",
                                "type": "string"
                              },
                              "engagement": {
                                "type": "integer"
                              },
                              "followers": {
                                "type": "integer"
                              },
                              "impressions": {
                                "type": "integer"
                              }
                            }
                          }
                        },
                        "totals": {
                          "additionalProperties": false,
                          "type": "object",
                          "required": [
                            "comments",
                            "engagement",
                            "followers",
                            "impressions",
                            "likes",
                            "posts",
                            "reach",
                            "shares"
                          ],
                          "properties": {
                            "comments": {
                              "type": "integer"
                            },
                            "engagement": {
                              "type": "integer"
                            },
                            "followers": {
                              "type": "integer"
                            },
                            "impressions": {
                              "type": "integer"
                            },
                            "likes": {
                              "type": "integer"
                            },
                            "posts": {
                              "type": "integer"
                            },
                            "reach": {
                              "type": "integer"
                            },
                            "shares": {
                              "type": "integer"
                            }
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/smm/saved-replies": {
      "get": {
        "operationId": "getApiV1SmmSavedReplies",
        "summary": "List saved replies (canned responses) for the current team",
        "tags": [
          "smm"
        ],
        "description": "Returns all saved replies (canned responses) for the current team.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "savedReplies"
                  ],
                  "properties": {
                    "savedReplies": {
                      "type": "array",
                      "items": {
                        "additionalProperties": true,
                        "type": "object",
                        "required": [
                          "id"
                        ],
                        "properties": {
                          "id": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "postApiV1SmmSavedReplies",
        "summary": "Create a saved reply",
        "tags": [
          "smm"
        ],
        "description": "Creates a new saved reply for the current team.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "title",
                  "body"
                ],
                "properties": {
                  "title": {
                    "type": "string"
                  },
                  "body": {
                    "type": "string"
                  },
                  "category": {
                    "anyOf": [
                      {
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "shortcut": {
                    "anyOf": [
                      {
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "savedReply"
                  ],
                  "properties": {
                    "savedReply": {
                      "additionalProperties": true,
                      "type": "object",
                      "required": [
                        "id"
                      ],
                      "properties": {
                        "id": {
                          "type": "string"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/smm/saved-replies/{id}": {
      "put": {
        "operationId": "putApiV1SmmSavedRepliesById",
        "summary": "Update a saved reply",
        "tags": [
          "smm"
        ],
        "description": "Updates an existing saved reply by id for the current team.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "title": {
                    "type": "string"
                  },
                  "body": {
                    "type": "string"
                  },
                  "category": {
                    "anyOf": [
                      {
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "shortcut": {
                    "anyOf": [
                      {
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "savedReply"
                  ],
                  "properties": {
                    "savedReply": {
                      "additionalProperties": true,
                      "type": "object",
                      "required": [
                        "id"
                      ],
                      "properties": {
                        "id": {
                          "type": "string"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      },
      "delete": {
        "operationId": "deleteApiV1SmmSavedRepliesById",
        "summary": "Delete a saved reply",
        "tags": [
          "smm"
        ],
        "description": "Deletes a saved reply by id for the current team.",
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "ok"
                  ],
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/smm/saved-replies/{id}/use": {
      "post": {
        "operationId": "postApiV1SmmSavedRepliesByIdUse",
        "summary": "Increment the usage count of a saved reply",
        "tags": [
          "smm"
        ],
        "description": "Increments the usage count of a saved reply by id for the current team.",
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "ok"
                  ],
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/smm/streams": {
      "get": {
        "operationId": "getApiV1SmmStreams",
        "summary": "List social listening streams for the current team",
        "tags": [
          "smm"
        ],
        "description": "Returns the social listening streams for the current team.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "streams"
                  ],
                  "properties": {
                    "streams": {
                      "type": "array",
                      "items": {
                        "additionalProperties": true,
                        "type": "object",
                        "required": [
                          "id"
                        ],
                        "properties": {
                          "id": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "postApiV1SmmStreams",
        "summary": "Create a social listening stream",
        "tags": [
          "smm"
        ],
        "description": "Creates a social listening stream for the current team.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "type",
                  "query"
                ],
                "properties": {
                  "type": {
                    "anyOf": [
                      {
                        "type": "string",
                        "enum": [
                          "keyword"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "hashtag"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "mention"
                        ]
                      }
                    ]
                  },
                  "query": {
                    "type": "string"
                  },
                  "socialAccountId": {
                    "anyOf": [
                      {
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "stream"
                  ],
                  "properties": {
                    "stream": {
                      "additionalProperties": true,
                      "type": "object",
                      "required": [
                        "id"
                      ],
                      "properties": {
                        "id": {
                          "type": "string"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/smm/streams/{id}": {
      "put": {
        "operationId": "putApiV1SmmStreamsById",
        "summary": "Update a social listening stream",
        "tags": [
          "smm"
        ],
        "description": "Updates a social listening stream for the current team.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "query": {
                    "type": "string"
                  },
                  "enabled": {
                    "type": "boolean"
                  },
                  "socialAccountId": {
                    "anyOf": [
                      {
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "stream"
                  ],
                  "properties": {
                    "stream": {
                      "additionalProperties": true,
                      "type": "object",
                      "required": [
                        "id"
                      ],
                      "properties": {
                        "id": {
                          "type": "string"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      },
      "delete": {
        "operationId": "deleteApiV1SmmStreamsById",
        "summary": "Delete a social listening stream",
        "tags": [
          "smm"
        ],
        "description": "Deletes a social listening stream for the current team.",
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "ok"
                  ],
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/smm/streams/{id}/results": {
      "get": {
        "operationId": "getApiV1SmmStreamsByIdResults",
        "summary": "List collected mentions for a stream",
        "tags": [
          "smm"
        ],
        "description": "Returns the collected mentions for a social listening stream.",
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "mentions"
                  ],
                  "properties": {
                    "mentions": {
                      "type": "array",
                      "items": {
                        "additionalProperties": true,
                        "type": "object",
                        "required": [
                          "id"
                        ],
                        "properties": {
                          "id": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/smm/streams/run": {
      "post": {
        "operationId": "postApiV1SmmStreamsRun",
        "summary": "Run a listening collection pass for the current team now",
        "tags": [
          "smm"
        ],
        "description": "Runs a listening collection pass for the current team immediately.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "result"
                  ],
                  "properties": {
                    "result": {
                      "$comment": "json-value",
                      "description": "Arbitrary JSON value."
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/smm/suggestions/best-times": {
      "get": {
        "operationId": "getApiV1SmmSuggestionsBestTimes",
        "summary": "Suggested best times to post by platform and industry target",
        "tags": [
          "smm"
        ],
        "description": "Returns one series per requested platform. Team history wins independently only with at least five valid posts, positive engagement signal, and repeated comparable slots; otherwise the response explicitly identifies a curated industry or platform benchmark. History is ranked by average engagement rate when complete impression denominators exist, or average engagement per post otherwise. Target benchmarks are hypotheses to test, not personalized predictions. Slot day/hour are wall-clock in the `tz` IANA timezone (UTC when omitted or invalid).",
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "tz",
            "required": false,
            "description": "IANA timezone for returned local wall-clock slots"
          },
          {
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "enum": [
                    "generale"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "costruzioni_industria"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "ristorazione_ospitalita_turismo"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "retail_beni_consumo"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "servizi_finanziari"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "pubblica_amministrazione"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "sanita_farmaceutica_biotech"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "agenzie_marketing"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "media_intrattenimento"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "non_profit"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "energia_utility"
                  ]
                }
              ]
            },
            "in": "query",
            "name": "target",
            "required": false
          },
          {
            "schema": {
              "pattern": "^(facebook|facebook_page|instagram|tiktok|youtube)(,(facebook|facebook_page|instagram|tiktok|youtube))*$",
              "type": "string"
            },
            "in": "query",
            "name": "platforms",
            "required": false,
            "description": "Comma-separated platforms; facebook_page is normalized to facebook"
          }
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "timezone",
                    "target",
                    "series",
                    "metadata"
                  ],
                  "properties": {
                    "timezone": {
                      "type": "string"
                    },
                    "target": {
                      "additionalProperties": false,
                      "type": "object",
                      "required": [
                        "key",
                        "label"
                      ],
                      "properties": {
                        "key": {
                          "anyOf": [
                            {
                              "type": "string",
                              "enum": [
                                "generale"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "costruzioni_industria"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "ristorazione_ospitalita_turismo"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "retail_beni_consumo"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "servizi_finanziari"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "pubblica_amministrazione"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "sanita_farmaceutica_biotech"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "agenzie_marketing"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "media_intrattenimento"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "non_profit"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "energia_utility"
                              ]
                            }
                          ]
                        },
                        "label": {
                          "type": "string"
                        }
                      }
                    },
                    "series": {
                      "type": "array",
                      "items": {
                        "additionalProperties": false,
                        "type": "object",
                        "required": [
                          "platform",
                          "source",
                          "slots",
                          "grid",
                          "metadata"
                        ],
                        "properties": {
                          "platform": {
                            "anyOf": [
                              {
                                "type": "string",
                                "enum": [
                                  "facebook"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "instagram"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "tiktok"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "youtube"
                                ]
                              }
                            ]
                          },
                          "source": {
                            "anyOf": [
                              {
                                "type": "string",
                                "enum": [
                                  "history"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "industry_benchmark"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "platform_benchmark"
                                ]
                              }
                            ]
                          },
                          "slots": {
                            "description": "Top slots for the per-platform drill-down list",
                            "type": "array",
                            "items": {
                              "additionalProperties": false,
                              "type": "object",
                              "required": [
                                "day",
                                "hour",
                                "label",
                                "score"
                              ],
                              "properties": {
                                "day": {
                                  "minimum": 0,
                                  "maximum": 6,
                                  "description": "Local weekday, 0=Sunday and 6=Saturday",
                                  "type": "integer"
                                },
                                "hour": {
                                  "minimum": 0,
                                  "maximum": 23,
                                  "description": "Local wall-clock hour",
                                  "type": "integer"
                                },
                                "label": {
                                  "type": "string"
                                },
                                "score": {
                                  "minimum": 1,
                                  "maximum": 100,
                                  "description": "Relative priority, not predicted uplift",
                                  "type": "integer"
                                }
                              }
                            }
                          },
                          "grid": {
                            "description": "Full scored day/hour list for this platform: lets the client merge platforms and judge any chosen time",
                            "type": "array",
                            "items": {
                              "additionalProperties": false,
                              "type": "object",
                              "required": [
                                "day",
                                "hour",
                                "label",
                                "score"
                              ],
                              "properties": {
                                "day": {
                                  "minimum": 0,
                                  "maximum": 6,
                                  "description": "Local weekday, 0=Sunday and 6=Saturday",
                                  "type": "integer"
                                },
                                "hour": {
                                  "minimum": 0,
                                  "maximum": 23,
                                  "description": "Local wall-clock hour",
                                  "type": "integer"
                                },
                                "label": {
                                  "type": "string"
                                },
                                "score": {
                                  "minimum": 1,
                                  "maximum": 100,
                                  "description": "Relative priority, not predicted uplift",
                                  "type": "integer"
                                }
                              }
                            }
                          },
                          "metadata": {
                            "additionalProperties": false,
                            "type": "object",
                            "required": [
                              "version",
                              "methodology",
                              "sampleSize",
                              "sampleDescription",
                              "historySampleSize",
                              "historyThreshold",
                              "publishedAt",
                              "sourceUrl"
                            ],
                            "properties": {
                              "version": {
                                "type": "string"
                              },
                              "methodology": {
                                "type": "string"
                              },
                              "sampleSize": {
                                "minimum": 0,
                                "type": "integer"
                              },
                              "sampleDescription": {
                                "type": "string"
                              },
                              "historySampleSize": {
                                "minimum": 0,
                                "type": "integer"
                              },
                              "historyThreshold": {
                                "minimum": 1,
                                "type": "integer"
                              },
                              "publishedAt": {
                                "anyOf": [
                                  {
                                    "format": "date",
                                    "type": "string"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "sourceUrl": {
                                "anyOf": [
                                  {
                                    "format": "uri",
                                    "type": "string"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              }
                            }
                          }
                        }
                      }
                    },
                    "metadata": {
                      "additionalProperties": false,
                      "type": "object",
                      "required": [
                        "version",
                        "methodology",
                        "sampleSize",
                        "historyThreshold",
                        "publishedAt",
                        "sourceUrl"
                      ],
                      "properties": {
                        "version": {
                          "type": "string"
                        },
                        "methodology": {
                          "type": "string"
                        },
                        "sampleSize": {
                          "minimum": 0,
                          "type": "integer"
                        },
                        "historyThreshold": {
                          "minimum": 1,
                          "type": "integer"
                        },
                        "publishedAt": {
                          "format": "date",
                          "type": "string"
                        },
                        "sourceUrl": {
                          "format": "uri",
                          "type": "string"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/smm/suggestions/caption": {
      "post": {
        "operationId": "postApiV1SmmSuggestionsCaption",
        "summary": "Generate an AI caption for selected social platforms",
        "tags": [
          "smm"
        ],
        "description": "Generates one Italian social caption for the selected platforms, respecting each platform text limit and measurement unit. The result is a draft for human review and costs 20 user-facing credits.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "platforms"
                ],
                "properties": {
                  "prompt": {
                    "maxLength": 4000,
                    "description": "Instructions or context for the requested caption",
                    "type": "string"
                  },
                  "text": {
                    "maxLength": 63206,
                    "description": "Existing caption to improve or rewrite, when available",
                    "type": "string"
                  },
                  "platforms": {
                    "minItems": 1,
                    "maxItems": 5,
                    "uniqueItems": true,
                    "description": "Target social platforms; all corresponding text limits are applied",
                    "type": "array",
                    "items": {
                      "anyOf": [
                        {
                          "type": "string",
                          "enum": [
                            "facebook"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "facebook_page"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "instagram"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "tiktok"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "youtube"
                          ]
                        }
                      ]
                    }
                  },
                  "tone": {
                    "maxLength": 80,
                    "description": "Requested voice or tone",
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "caption"
                  ],
                  "properties": {
                    "caption": {
                      "description": "Generated Italian caption ready for human review",
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "402": {
            "description": "Response 402",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/smm/webhooks/meta": {
      "get": {
        "operationId": "getApiV1SmmWebhooksMeta",
        "summary": "Verify the Meta (Facebook/Instagram) webhook subscription",
        "tags": [
          "smm"
        ],
        "description": "Subscription verification handshake. Returns hub.challenge when hub.verify_token matches SMM_META_WEBHOOK_VERIFY_TOKEN, otherwise 403. Public (no auth) — Meta calls it directly.",
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "hub.mode",
            "required": false
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "hub.verify_token",
            "required": false
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "hub.challenge",
            "required": false
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "challenge",
            "required": false
          }
        ],
        "responses": {
          "200": {
            "description": "Echoed verification challenge",
            "content": {
              "application/json": {
                "schema": {
                  "description": "Echoed verification challenge",
                  "type": "string"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Verification failed",
            "content": {
              "application/json": {
                "schema": {
                  "description": "Verification failed",
                  "type": "string"
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ]
      },
      "post": {
        "operationId": "postApiV1SmmWebhooksMeta",
        "summary": "Ingest a Meta (Facebook/Instagram) webhook event for SMM",
        "tags": [
          "smm"
        ],
        "description": "Verified event delivery. HMAC-checks the raw body against META_APP_SECRET (x-hub-signature-256), parses JSON, then processes the event. Always replies 200 quickly so Meta does not retry; processing failures are swallowed inside the service. Returns 401 on an invalid signature.",
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "ok"
                  ],
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ]
      }
    },
    "/api/v1/smm/webhooks/tiktok": {
      "get": {
        "operationId": "getApiV1SmmWebhooksTiktok",
        "summary": "Verify the TikTok webhook subscription (stub)",
        "tags": [
          "smm"
        ],
        "description": "Verification handshake stub. When SMM_TIKTOK_WEBHOOK_VERIFY_TOKEN is set, requires a matching verify_token query param before echoing the challenge (403 otherwise) — same pattern as the Meta handshake. When unset (no subscription configured yet), echoes the challenge unconditionally. Public (no auth).",
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "hub.mode",
            "required": false
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "hub.verify_token",
            "required": false
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "hub.challenge",
            "required": false
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "challenge",
            "required": false
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "anyOf": [
                    {
                      "description": "Echoed verification challenge",
                      "type": "string"
                    },
                    {
                      "additionalProperties": false,
                      "type": "object",
                      "required": [
                        "ok"
                      ],
                      "properties": {
                        "ok": {
                          "type": "boolean"
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Verification failed",
            "content": {
              "application/json": {
                "schema": {
                  "description": "Verification failed",
                  "type": "string"
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ]
      },
      "post": {
        "operationId": "postApiV1SmmWebhooksTiktok",
        "summary": "Ingest a TikTok webhook event for SMM",
        "tags": [
          "smm"
        ],
        "description": "Verified event delivery for authorization.removed / video.publish.completed / video.upload.failed / portability.download.ready (TikTok has no comment webhook — see smm-webhook.service.ts). HMAC-checks the raw body against TIKTOK_CLIENT_SECRET (TikTok-Signature: t=..,s=..), parses JSON, then processes the event. Always replies 200 quickly so TikTok does not retry; processing failures are swallowed inside the service. Returns 401 on an invalid signature.",
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "ok"
                  ],
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ]
      }
    },
    "/api/v1/smm/webhooks/youtube": {
      "get": {
        "operationId": "getApiV1SmmWebhooksYoutube",
        "summary": "Verify the YouTube (PubSubHubbub) webhook subscription (stub)",
        "tags": [
          "smm"
        ],
        "description": "PubSubHubbub-style verification stub. When SMM_YOUTUBE_WEBHOOK_VERIFY_TOKEN is set, requires a matching verify_token query param before echoing hub.challenge (403 otherwise) — same pattern as the Meta handshake. When unset (no subscription configured yet), echoes the challenge unconditionally. Public (no auth).",
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "hub.mode",
            "required": false
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "hub.verify_token",
            "required": false
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "hub.challenge",
            "required": false
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "challenge",
            "required": false
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "anyOf": [
                    {
                      "description": "Echoed verification challenge",
                      "type": "string"
                    },
                    {
                      "additionalProperties": false,
                      "type": "object",
                      "required": [
                        "ok"
                      ],
                      "properties": {
                        "ok": {
                          "type": "boolean"
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Verification failed",
            "content": {
              "application/json": {
                "schema": {
                  "description": "Verification failed",
                  "type": "string"
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ]
      },
      "post": {
        "operationId": "postApiV1SmmWebhooksYoutube",
        "summary": "Ingest a YouTube webhook event for SMM (stub)",
        "tags": [
          "smm"
        ],
        "description": "Stub endpoint: acknowledges the delivery. Real processing is not yet implemented — this route MUST gain signature verification (PubSubHubbub X-Hub-Signature against a subscription-time hub.secret) before any real event processing is wired in here; do not add processing logic without it. Public (no auth).",
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "ok"
                  ],
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/smm/connect/meta": {
      "post": {
        "operationId": "postApiV1SmmConnectMeta",
        "summary": "Connect Meta (Facebook Pages + linked Instagram accounts) via a user access token",
        "tags": [
          "smm"
        ],
        "description": "Connects the available Facebook Pages and linked Instagram accounts for the supplied Meta user access token, up to the organization plan quota (D3: first discovered win), and returns the connected account summaries plus how many discovered accounts the quota refused.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "userAccessToken"
                ],
                "properties": {
                  "userAccessToken": {
                    "minLength": 20,
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "connected",
                    "quota_skipped"
                  ],
                  "properties": {
                    "connected": {
                      "type": "array",
                      "items": {
                        "additionalProperties": true,
                        "type": "object",
                        "required": [
                          "platform"
                        ],
                        "properties": {
                          "platform": {
                            "type": "string"
                          }
                        }
                      }
                    },
                    "quota_skipped": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message",
                    "code",
                    "resource"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "resource": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/smm/accounts/demo": {
      "post": {
        "operationId": "postApiV1SmmAccountsDemo",
        "summary": "Create a local demo/test social account (no real connection)",
        "tags": [
          "smm"
        ],
        "description": "Creates a local demo/test social account for the current team and returns its account summary.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "connected"
                  ],
                  "properties": {
                    "connected": {
                      "type": "array",
                      "items": {
                        "additionalProperties": true,
                        "type": "object",
                        "required": [
                          "platform"
                        ],
                        "properties": {
                          "platform": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/smm/connect/tiktok": {
      "post": {
        "operationId": "postApiV1SmmConnectTiktok",
        "summary": "Connect a TikTok account via an access token",
        "tags": [
          "smm"
        ],
        "description": "Connects a TikTok account for the current team using the supplied access token.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "accessToken"
                ],
                "properties": {
                  "accessToken": {
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "connected"
                  ],
                  "properties": {
                    "connected": {
                      "type": "array",
                      "items": {
                        "additionalProperties": true,
                        "type": "object",
                        "required": [
                          "platform"
                        ],
                        "properties": {
                          "platform": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message",
                    "code",
                    "resource"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "resource": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/smm/connect/youtube": {
      "post": {
        "operationId": "postApiV1SmmConnectYoutube",
        "summary": "Connect a YouTube channel via an access token",
        "tags": [
          "smm"
        ],
        "description": "Connects a YouTube channel for the current team using the supplied access token.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "accessToken"
                ],
                "properties": {
                  "accessToken": {
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "connected"
                  ],
                  "properties": {
                    "connected": {
                      "type": "array",
                      "items": {
                        "additionalProperties": true,
                        "type": "object",
                        "required": [
                          "platform"
                        ],
                        "properties": {
                          "platform": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message",
                    "code",
                    "resource"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "resource": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/smm/accounts": {
      "get": {
        "operationId": "getApiV1SmmAccounts",
        "summary": "List connected SMM social accounts with their platform capabilities",
        "tags": [
          "smm"
        ],
        "description": "Returns the connected social accounts for the current team, each carrying the platform capability matrix resolved from the SMM adapter registry. A platform with no registered adapter reports every capability as false instead of failing the listing.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "accounts"
                  ],
                  "properties": {
                    "accounts": {
                      "type": "array",
                      "items": {
                        "additionalProperties": false,
                        "type": "object",
                        "required": [
                          "id",
                          "platform",
                          "external_id",
                          "name",
                          "username",
                          "status",
                          "capabilities"
                        ],
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "platform": {
                            "description": "Stored platform value, e.g. facebook_page, instagram, tiktok, youtube.",
                            "type": "string"
                          },
                          "external_id": {
                            "description": "Platform-side account id.",
                            "type": "string"
                          },
                          "name": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "username": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "status": {
                            "type": "string"
                          },
                          "capabilities": {
                            "additionalProperties": false,
                            "description": "What the connected account can actually do today.",
                            "type": "object",
                            "required": [
                              "publish",
                              "comments",
                              "dm",
                              "insights",
                              "listening",
                              "webhooks"
                            ],
                            "properties": {
                              "publish": {
                                "description": "The platform can publish posts.",
                                "type": "boolean"
                              },
                              "comments": {
                                "description": "The platform exposes comment listing/moderation.",
                                "type": "boolean"
                              },
                              "dm": {
                                "description": "The platform exposes a direct-message API.",
                                "type": "boolean"
                              },
                              "insights": {
                                "description": "The platform exposes post/account insight collection.",
                                "type": "boolean"
                              },
                              "listening": {
                                "description": "The platform supports social-listening collection.",
                                "type": "boolean"
                              },
                              "webhooks": {
                                "description": "The platform delivers webhook events.",
                                "type": "boolean"
                              }
                            }
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/smm/publish": {
      "post": {
        "operationId": "postApiV1SmmPublish",
        "summary": "Publish a post to selected connected social accounts",
        "tags": [
          "smm"
        ],
        "description": "Publishes the given content to the selected connected accounts and returns a per-account outcome. When postId is provided, persists the outcomes and final status on that existing team post.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "accountIds"
                ],
                "properties": {
                  "accountIds": {
                    "minItems": 1,
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  },
                  "postId": {
                    "type": "string"
                  },
                  "campaign": {
                    "type": "string"
                  },
                  "text": {
                    "type": "string"
                  },
                  "imageUrl": {
                    "type": "string"
                  },
                  "mediaUrls": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  },
                  "mediaType": {
                    "anyOf": [
                      {
                        "type": "string",
                        "enum": [
                          "image"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "video"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "carousel"
                        ]
                      }
                    ]
                  },
                  "firstComment": {
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "results"
                  ],
                  "properties": {
                    "results": {
                      "type": "array",
                      "items": {
                        "additionalProperties": true,
                        "type": "object",
                        "required": [
                          "accountId",
                          "platform",
                          "ok"
                        ],
                        "properties": {
                          "accountId": {
                            "type": "string"
                          },
                          "platform": {
                            "type": "string"
                          },
                          "ok": {
                            "type": "boolean"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/snapchat/ad-accounts": {
      "get": {
        "operationId": "listSnapchatAdAccounts",
        "summary": "List Snapchat ad accounts",
        "tags": [
          "snapchat"
        ],
        "description": "Returns Snapchat ad accounts synced for the authenticated user and excludes soft-deleted accounts.",
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "ad_accounts",
                    "total"
                  ],
                  "properties": {
                    "ad_accounts": {
                      "type": "array",
                      "items": {
                        "additionalProperties": true,
                        "type": "object",
                        "properties": {
                          "id": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "session_id": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "snapchat_token_id": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "organization_id": {
                            "type": "string"
                          },
                          "organization_name": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "account_id": {
                            "type": "string"
                          },
                          "account_name": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "account_status": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "currency": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "timezone": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "funding_source_ids": {
                            "type": "array",
                            "items": {
                              "type": "string"
                            }
                          },
                          "is_test": {
                            "type": "boolean"
                          },
                          "connected": {
                            "type": "boolean"
                          },
                          "is_active": {
                            "anyOf": [
                              {
                                "type": "boolean"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "created_at": {
                            "format": "date-time",
                            "type": "string"
                          },
                          "updated_at": {
                            "anyOf": [
                              {
                                "format": "date-time",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "deleted_at": {
                            "anyOf": [
                              {
                                "format": "date-time",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "team_id": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          }
                        }
                      }
                    },
                    "total": {
                      "minimum": 0,
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "integer"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "integer"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "integer"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/snapchat/sync/ad-accounts": {
      "post": {
        "operationId": "syncSnapchatAdAccounts",
        "summary": "Sync Snapchat ad accounts",
        "tags": [
          "snapchat"
        ],
        "description": "Queues the Snapchat ad-account sync worker and returns the worker run id used by the sync progress banner.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "success",
                    "queued",
                    "worker_run_id"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "queued": {
                      "type": "boolean"
                    },
                    "worker_run_id": {
                      "format": "uuid",
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "integer"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "integer"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "integer"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/snapchat/toggle-account": {
      "post": {
        "operationId": "toggleSnapchatAccount",
        "summary": "Toggle Snapchat ad-account connection",
        "tags": [
          "snapchat"
        ],
        "description": "Updates the connected flag for a Snapchat ad account and its platform connection row.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "account_id",
                  "connected"
                ],
                "properties": {
                  "account_id": {
                    "minLength": 1,
                    "type": "string"
                  },
                  "connected": {
                    "type": "boolean"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "success"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "integer"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "integer"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "integer"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/snapchat/campaigns/{campaignId}/budget": {
      "post": {
        "operationId": "updateSnapchatCampaignBudget",
        "summary": "Update Snapchat campaign budget",
        "tags": [
          "snapchat"
        ],
        "description": "Queues a Snapchat campaign daily-budget update for asynchronous worker execution.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "account_id",
                  "daily_budget"
                ],
                "properties": {
                  "account_id": {
                    "minLength": 1,
                    "maxLength": 100,
                    "type": "string"
                  },
                  "daily_budget": {
                    "minimum": 0,
                    "type": "number"
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "schema": {
              "minLength": 1,
              "type": "string"
            },
            "in": "path",
            "name": "campaignId",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "success",
                    "queued"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "queued": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "integer"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "integer"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "integer"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/snapchat/adsquads/{adSquadId}/budget": {
      "post": {
        "operationId": "updateSnapchatAdSquadBudget",
        "summary": "Update Snapchat ad squad budget",
        "tags": [
          "snapchat"
        ],
        "description": "Queues a Snapchat ad squad daily-budget update for asynchronous worker execution.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "account_id",
                  "daily_budget"
                ],
                "properties": {
                  "account_id": {
                    "minLength": 1,
                    "type": "string"
                  },
                  "daily_budget": {
                    "minimum": 0,
                    "type": "number"
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "schema": {
              "minLength": 1,
              "type": "string"
            },
            "in": "path",
            "name": "adSquadId",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "success",
                    "queued"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "queued": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "integer"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "integer"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "integer"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/snapchat/campaigns/{campaignId}/toggle": {
      "post": {
        "operationId": "toggleSnapchatCampaign",
        "summary": "Toggle Snapchat campaign status",
        "tags": [
          "snapchat"
        ],
        "description": "Updates a Snapchat campaign status to ACTIVE or PAUSED.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "account_id",
                  "status"
                ],
                "properties": {
                  "account_id": {
                    "minLength": 1,
                    "maxLength": 100,
                    "type": "string"
                  },
                  "status": {
                    "anyOf": [
                      {
                        "type": "string",
                        "enum": [
                          "ACTIVE"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "PAUSED"
                        ]
                      }
                    ]
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "schema": {
              "minLength": 1,
              "type": "string"
            },
            "in": "path",
            "name": "campaignId",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "success"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "integer"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "integer"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "integer"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/snapchat/toggle": {
      "post": {
        "operationId": "toggleSnapchatEntity",
        "summary": "Toggle a Snapchat entity",
        "tags": [
          "snapchat"
        ],
        "description": "Queues a status toggle for a Snapchat campaign, ad squad, or ad using the shared entity-toggle worker.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "account_id",
                  "entity_id",
                  "entity_type",
                  "is_active"
                ],
                "properties": {
                  "account_id": {
                    "minLength": 1,
                    "maxLength": 100,
                    "type": "string"
                  },
                  "entity_id": {
                    "minLength": 1,
                    "maxLength": 100,
                    "type": "string"
                  },
                  "entity_type": {
                    "anyOf": [
                      {
                        "type": "string",
                        "enum": [
                          "campaign"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "adsquad"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "ad"
                        ]
                      }
                    ]
                  },
                  "is_active": {
                    "type": "boolean"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "success",
                    "queued"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "queued": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "integer"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "integer"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "integer"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/snapchat/delete-campaigns": {
      "post": {
        "operationId": "deleteSnapchatCampaignsByAccount",
        "summary": "Delete all Snapchat campaigns for an account",
        "tags": [
          "snapchat"
        ],
        "description": "Queues a bulk-delete worker for every campaign under the supplied Snapchat ad account.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "account_id"
                ],
                "properties": {
                  "account_id": {
                    "minLength": 1,
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "202": {
            "description": "Accepted - processing asynchronously",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "success",
                    "queued",
                    "worker_run_id"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "queued": {
                      "type": "boolean"
                    },
                    "worker_run_id": {
                      "format": "uuid",
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "integer"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "integer"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "integer"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/snapchat/disconnect": {
      "post": {
        "operationId": "disconnectSnapchat",
        "summary": "Disconnect Snapchat",
        "tags": [
          "snapchat"
        ],
        "description": "Soft-deletes Snapchat tokens and synced Snapchat assets for the authenticated user.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "success"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "integer"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "integer"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "integer"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/snapchat/sync/public-profiles": {
      "post": {
        "operationId": "syncSnapchatPublicProfiles",
        "summary": "Sync Snapchat public profiles",
        "tags": [
          "snapchat"
        ],
        "description": "Queues a Snapchat public-profile sync worker for the authenticated user.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "success",
                    "queued",
                    "worker_run_id"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "queued": {
                      "type": "boolean"
                    },
                    "worker_run_id": {
                      "format": "uuid",
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "integer"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "integer"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "integer"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/snapchat/sync/pixels": {
      "post": {
        "operationId": "syncSnapchatPixels",
        "summary": "Sync Snapchat pixels",
        "tags": [
          "snapchat"
        ],
        "description": "Queues a Snapchat pixel sync worker for the authenticated user.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "success",
                    "queued",
                    "worker_run_id"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "queued": {
                      "type": "boolean"
                    },
                    "worker_run_id": {
                      "format": "uuid",
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "integer"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "integer"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "integer"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/snapchat/sync/catalogs": {
      "post": {
        "operationId": "syncSnapchatCatalogs",
        "summary": "Sync Snapchat catalogs",
        "tags": [
          "snapchat"
        ],
        "description": "Queues a Snapchat catalog sync worker for the authenticated user.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "success",
                    "queued",
                    "worker_run_id"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "queued": {
                      "type": "boolean"
                    },
                    "worker_run_id": {
                      "format": "uuid",
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "integer"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "integer"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "integer"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/snapchat/sync/insights": {
      "post": {
        "operationId": "syncSnapchatInsights",
        "summary": "Sync Snapchat insights",
        "tags": [
          "snapchat"
        ],
        "description": "Dispatches a Snapchat insights backfill for the authenticated user over the default 30-day window.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "success",
                    "queued",
                    "status"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "queued": {
                      "type": "boolean"
                    },
                    "status": {
                      "anyOf": [
                        {
                          "type": "string",
                          "enum": [
                            "processing"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "skipped"
                          ]
                        }
                      ]
                    },
                    "worker_run_id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "days": {
                      "type": "number"
                    },
                    "chunks": {
                      "type": "number"
                    },
                    "from_date": {
                      "format": "date",
                      "type": "string"
                    },
                    "to_date": {
                      "format": "date",
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "integer"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "integer"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "integer"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/snapchat/public-profiles": {
      "get": {
        "operationId": "listSnapchatPublicProfiles",
        "summary": "List Snapchat public profiles",
        "tags": [
          "snapchat"
        ],
        "description": "Returns synced Snapchat public profiles enriched with organization and team-member display data.",
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "public_profiles",
                    "total"
                  ],
                  "properties": {
                    "public_profiles": {
                      "type": "array",
                      "items": {
                        "additionalProperties": true,
                        "type": "object",
                        "properties": {
                          "id": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "session_id": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "snapchat_token_id": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "organization_id": {
                            "type": "string"
                          },
                          "organization_name": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "profile_id": {
                            "type": "string"
                          },
                          "name": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "handle": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "status": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "connected": {
                            "type": "boolean"
                          },
                          "is_active": {
                            "anyOf": [
                              {
                                "type": "boolean"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "created_at": {
                            "format": "date-time",
                            "type": "string"
                          },
                          "updated_at": {
                            "anyOf": [
                              {
                                "format": "date-time",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "deleted_at": {
                            "anyOf": [
                              {
                                "format": "date-time",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "member_name": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "member_email": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "team_name": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          }
                        }
                      }
                    },
                    "total": {
                      "minimum": 0,
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "integer"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "integer"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "integer"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/snapchat/lead-forms": {
      "get": {
        "operationId": "listSnapchatLeadForms",
        "summary": "List Snapchat lead forms",
        "tags": [
          "snapchat"
        ],
        "description": "Fetches live Snapchat lead-generation forms for connected accounts, optionally filtered by ad account.",
        "parameters": [
          {
            "schema": {
              "minLength": 1,
              "maxLength": 100,
              "type": "string"
            },
            "in": "query",
            "name": "account_id",
            "required": false
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "lead_forms",
                    "total"
                  ],
                  "properties": {
                    "lead_forms": {
                      "type": "array",
                      "items": {
                        "additionalProperties": true,
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "name": {
                            "type": "string"
                          },
                          "ad_account_id": {
                            "type": "string"
                          },
                          "form_status": {
                            "type": "string"
                          },
                          "privacy_policy_url": {
                            "type": "string"
                          },
                          "created_at": {
                            "type": "string"
                          },
                          "updated_at": {
                            "type": "string"
                          }
                        }
                      }
                    },
                    "total": {
                      "minimum": 0,
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "integer"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "integer"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "integer"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/snapchat/pixels": {
      "get": {
        "operationId": "listSnapchatPixels",
        "summary": "List Snapchat pixels",
        "tags": [
          "snapchat"
        ],
        "description": "Returns synced Snapchat pixels enriched with organization and team-member display data.",
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "pixels",
                    "total"
                  ],
                  "properties": {
                    "pixels": {
                      "type": "array",
                      "items": {
                        "additionalProperties": true,
                        "type": "object",
                        "properties": {
                          "id": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "session_id": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "snapchat_token_id": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "account_id": {
                            "type": "string"
                          },
                          "pixel_id": {
                            "type": "string"
                          },
                          "name": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "status": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "connected": {
                            "type": "boolean"
                          },
                          "organization_id": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "organization_name": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "created_at": {
                            "format": "date-time",
                            "type": "string"
                          },
                          "updated_at": {
                            "anyOf": [
                              {
                                "format": "date-time",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "deleted_at": {
                            "anyOf": [
                              {
                                "format": "date-time",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "member_name": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "member_email": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "team_name": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          }
                        }
                      }
                    },
                    "total": {
                      "minimum": 0,
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "integer"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "integer"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "integer"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/snapchat/catalogs": {
      "get": {
        "operationId": "listSnapchatCatalogs",
        "summary": "List Snapchat catalogs",
        "tags": [
          "snapchat"
        ],
        "description": "Returns synced Snapchat product catalogs with recent diagnostics and team-member display data.",
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "catalogs",
                    "total"
                  ],
                  "properties": {
                    "catalogs": {
                      "type": "array",
                      "items": {
                        "additionalProperties": true,
                        "type": "object",
                        "properties": {
                          "id": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "session_id": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "snapchat_token_id": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "organization_id": {
                            "type": "string"
                          },
                          "organization_name": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "catalog_id": {
                            "type": "string"
                          },
                          "name": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "vertical": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "product_count": {
                            "minimum": 0,
                            "type": "integer"
                          },
                          "source": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "connected": {
                            "type": "boolean"
                          },
                          "is_active": {
                            "anyOf": [
                              {
                                "type": "boolean"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "diagnostics": {
                            "type": "array",
                            "items": {
                              "additionalProperties": true,
                              "type": "object",
                              "properties": {
                                "id": {
                                  "format": "uuid",
                                  "type": "string"
                                },
                                "catalog_id": {
                                  "format": "uuid",
                                  "type": "string"
                                },
                                "severity": {
                                  "type": "string"
                                },
                                "code": {
                                  "anyOf": [
                                    {
                                      "type": "string"
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "message": {
                                  "anyOf": [
                                    {
                                      "type": "string"
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "created_at": {
                                  "format": "date-time",
                                  "type": "string"
                                }
                              }
                            }
                          },
                          "created_at": {
                            "format": "date-time",
                            "type": "string"
                          },
                          "updated_at": {
                            "anyOf": [
                              {
                                "format": "date-time",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "deleted_at": {
                            "anyOf": [
                              {
                                "format": "date-time",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "member_name": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "member_email": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "team_name": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          }
                        }
                      }
                    },
                    "total": {
                      "minimum": 0,
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "integer"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "integer"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "integer"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/snapchat/catalogs/{catalogId}/product-sets": {
      "get": {
        "operationId": "listSnapchatCatalogProductSets",
        "summary": "List Snapchat catalog product sets",
        "tags": [
          "snapchat"
        ],
        "description": "Fetches live product sets for a synced Snapchat catalog, returning an empty list when the catalog is unavailable.",
        "parameters": [
          {
            "schema": {
              "minLength": 1,
              "maxLength": 100,
              "type": "string"
            },
            "in": "path",
            "name": "catalogId",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "product_sets",
                    "total"
                  ],
                  "properties": {
                    "product_sets": {
                      "type": "array",
                      "items": {
                        "additionalProperties": true,
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "catalog_id": {
                            "type": "string"
                          },
                          "name": {
                            "type": "string"
                          },
                          "status": {
                            "type": "string"
                          }
                        }
                      }
                    },
                    "total": {
                      "minimum": 0,
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "integer"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "integer"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "integer"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "502": {
            "description": "Bad gateway - upstream provider failed",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "integer"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/snapchat/ad-accounts/{accountId}/phone-numbers": {
      "get": {
        "operationId": "listSnapchatPhoneNumbers",
        "summary": "List Snapchat phone numbers",
        "tags": [
          "snapchat"
        ],
        "description": "Fetches live phone numbers associated with a synced Snapchat ad account.",
        "parameters": [
          {
            "schema": {
              "minLength": 1,
              "maxLength": 100,
              "type": "string"
            },
            "in": "path",
            "name": "accountId",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "phone_numbers",
                    "total"
                  ],
                  "properties": {
                    "phone_numbers": {
                      "type": "array",
                      "items": {
                        "additionalProperties": true,
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "label": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "phone_number": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "verified": {
                            "anyOf": [
                              {
                                "type": "boolean"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          }
                        }
                      }
                    },
                    "total": {
                      "minimum": 0,
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "integer"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "integer"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "integer"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "502": {
            "description": "Bad gateway - upstream provider failed",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "integer"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/snapchat/members": {
      "get": {
        "operationId": "listSnapchatMembers",
        "summary": "List Snapchat organization members",
        "tags": [
          "snapchat"
        ],
        "description": "Fetches live Snapchat organization members visible to the authenticated user token.",
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "members",
                    "total"
                  ],
                  "properties": {
                    "members": {
                      "type": "array",
                      "items": {
                        "additionalProperties": true,
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "organization_id": {
                            "type": "string"
                          },
                          "display_name": {
                            "type": "string"
                          },
                          "email": {
                            "type": "string"
                          },
                          "member_status": {
                            "type": "string"
                          },
                          "member_roles": {
                            "type": "array",
                            "items": {
                              "type": "string"
                            }
                          },
                          "created_at": {
                            "type": "string"
                          },
                          "updated_at": {
                            "type": "string"
                          }
                        }
                      }
                    },
                    "total": {
                      "minimum": 0,
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "integer"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "integer"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "integer"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/snapchat/campaigns/{campaignId}/duplicate": {
      "post": {
        "operationId": "snapchatDuplicateCampaign",
        "summary": "Duplicate a Snapchat campaign (shallow copy)",
        "tags": [
          "snapchat"
        ],
        "description": "Copies a Snapchat campaign payload, strips read-only fields, creates a paused shallow duplicate, and returns the new campaign id.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "account_id"
                ],
                "properties": {
                  "account_id": {
                    "minLength": 1,
                    "maxLength": 100,
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "schema": {
              "minLength": 1,
              "type": "string"
            },
            "in": "path",
            "name": "campaignId",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "success",
                    "campaign_id"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "campaign_id": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "integer"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "integer"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "integer"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/snapchat/adsquads/{adSquadId}/duplicate": {
      "post": {
        "operationId": "snapchatDuplicateAdSquad",
        "summary": "Duplicate a Snapchat ad squad (shallow copy)",
        "tags": [
          "snapchat"
        ],
        "description": "Copies a Snapchat ad squad payload, strips read-only fields, creates a paused shallow duplicate, and returns the new ad squad id.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "account_id"
                ],
                "properties": {
                  "account_id": {
                    "minLength": 1,
                    "maxLength": 100,
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "schema": {
              "minLength": 1,
              "type": "string"
            },
            "in": "path",
            "name": "adSquadId",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "success",
                    "adsquad_id"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "adsquad_id": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "integer"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "integer"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "422": {
            "description": "Unprocessable entity - semantic validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "integer"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "integer"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/snapchat/ads/{adId}/duplicate": {
      "post": {
        "operationId": "snapchatDuplicateAd",
        "summary": "Duplicate a Snapchat ad",
        "tags": [
          "snapchat"
        ],
        "description": "Copies a Snapchat ad payload, strips review/read-only fields, creates a paused duplicate, and returns the new ad id.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "account_id"
                ],
                "properties": {
                  "account_id": {
                    "minLength": 1,
                    "maxLength": 100,
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "schema": {
              "minLength": 1,
              "type": "string"
            },
            "in": "path",
            "name": "adId",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "success",
                    "ad_id"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "ad_id": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "integer"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "integer"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "422": {
            "description": "Unprocessable entity - semantic validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "integer"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "integer"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/strategic/opportunities": {
      "get": {
        "operationId": "getApiV1StrategicOpportunities",
        "summary": "List strategic opportunities",
        "tags": [
          "strategic-details"
        ],
        "description": "Returns strategic opportunities for the accessible team scope filtered by status.",
        "parameters": [
          {
            "schema": {
              "type": "number"
            },
            "in": "query",
            "name": "limit",
            "required": false
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "status",
            "required": false
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "items"
                  ],
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "additionalProperties": false,
                        "type": "object",
                        "required": [
                          "id",
                          "team_id",
                          "source_snapshot_id",
                          "scope_type",
                          "scope_id",
                          "opportunity_type",
                          "title",
                          "summary",
                          "opportunity_score",
                          "evidence",
                          "source_freshness",
                          "suggested_action",
                          "related_competitor_ids",
                          "related_trend_ids",
                          "status",
                          "created_at",
                          "updated_at",
                          "expires_at",
                          "applied_at",
                          "snoozed_until"
                        ],
                        "properties": {
                          "id": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "team_id": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "source_snapshot_id": {
                            "anyOf": [
                              {
                                "format": "uuid",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "scope_type": {
                            "type": "string"
                          },
                          "scope_id": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "opportunity_type": {
                            "type": "string"
                          },
                          "title": {
                            "type": "string"
                          },
                          "summary": {
                            "type": "string"
                          },
                          "opportunity_score": {
                            "anyOf": [
                              {
                                "type": "number"
                              },
                              {
                                "type": "string"
                              }
                            ]
                          },
                          "evidence": {
                            "$comment": "json-value"
                          },
                          "source_freshness": {
                            "$comment": "json-value"
                          },
                          "suggested_action": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "related_competitor_ids": {
                            "type": "array",
                            "items": {
                              "format": "uuid",
                              "type": "string"
                            }
                          },
                          "related_trend_ids": {
                            "type": "array",
                            "items": {
                              "format": "uuid",
                              "type": "string"
                            }
                          },
                          "status": {
                            "type": "string"
                          },
                          "created_at": {
                            "format": "date-time",
                            "type": "string"
                          },
                          "updated_at": {
                            "format": "date-time",
                            "type": "string"
                          },
                          "expires_at": {
                            "anyOf": [
                              {
                                "format": "date-time",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "applied_at": {
                            "anyOf": [
                              {
                                "format": "date-time",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "snoozed_until": {
                            "anyOf": [
                              {
                                "format": "date-time",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/strategic/opportunities/{id}": {
      "get": {
        "operationId": "getApiV1StrategicOpportunitiesById",
        "summary": "Get strategic opportunity",
        "tags": [
          "strategic-details"
        ],
        "description": "Returns one strategic opportunity by id within the accessible team scope.",
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "id",
                    "team_id",
                    "source_snapshot_id",
                    "scope_type",
                    "scope_id",
                    "opportunity_type",
                    "title",
                    "summary",
                    "opportunity_score",
                    "evidence",
                    "source_freshness",
                    "suggested_action",
                    "related_competitor_ids",
                    "related_trend_ids",
                    "status",
                    "created_at",
                    "updated_at",
                    "expires_at",
                    "applied_at",
                    "snoozed_until"
                  ],
                  "properties": {
                    "id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "team_id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "source_snapshot_id": {
                      "anyOf": [
                        {
                          "format": "uuid",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "scope_type": {
                      "type": "string"
                    },
                    "scope_id": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "opportunity_type": {
                      "type": "string"
                    },
                    "title": {
                      "type": "string"
                    },
                    "summary": {
                      "type": "string"
                    },
                    "opportunity_score": {
                      "anyOf": [
                        {
                          "type": "number"
                        },
                        {
                          "type": "string"
                        }
                      ]
                    },
                    "evidence": {
                      "$comment": "json-value"
                    },
                    "source_freshness": {
                      "$comment": "json-value"
                    },
                    "suggested_action": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "related_competitor_ids": {
                      "type": "array",
                      "items": {
                        "format": "uuid",
                        "type": "string"
                      }
                    },
                    "related_trend_ids": {
                      "type": "array",
                      "items": {
                        "format": "uuid",
                        "type": "string"
                      }
                    },
                    "status": {
                      "type": "string"
                    },
                    "created_at": {
                      "format": "date-time",
                      "type": "string"
                    },
                    "updated_at": {
                      "format": "date-time",
                      "type": "string"
                    },
                    "expires_at": {
                      "anyOf": [
                        {
                          "format": "date-time",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "applied_at": {
                      "anyOf": [
                        {
                          "format": "date-time",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "snoozed_until": {
                      "anyOf": [
                        {
                          "format": "date-time",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/strategic/opportunities/{id}/status": {
      "patch": {
        "operationId": "patchApiV1StrategicOpportunitiesByIdStatus",
        "summary": "Update strategic opportunity status",
        "tags": [
          "strategic-details"
        ],
        "description": "Updates the lifecycle status for a strategic opportunity.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "status"
                ],
                "properties": {
                  "status": {
                    "anyOf": [
                      {
                        "type": "string",
                        "enum": [
                          "open"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "dismissed"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "converted"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "archived"
                        ]
                      }
                    ]
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "id",
                    "team_id",
                    "source_snapshot_id",
                    "scope_type",
                    "scope_id",
                    "opportunity_type",
                    "title",
                    "summary",
                    "opportunity_score",
                    "evidence",
                    "source_freshness",
                    "suggested_action",
                    "related_competitor_ids",
                    "related_trend_ids",
                    "status",
                    "created_at",
                    "updated_at",
                    "expires_at",
                    "applied_at",
                    "snoozed_until"
                  ],
                  "properties": {
                    "id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "team_id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "source_snapshot_id": {
                      "anyOf": [
                        {
                          "format": "uuid",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "scope_type": {
                      "type": "string"
                    },
                    "scope_id": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "opportunity_type": {
                      "type": "string"
                    },
                    "title": {
                      "type": "string"
                    },
                    "summary": {
                      "type": "string"
                    },
                    "opportunity_score": {
                      "anyOf": [
                        {
                          "type": "number"
                        },
                        {
                          "type": "string"
                        }
                      ]
                    },
                    "evidence": {
                      "$comment": "json-value"
                    },
                    "source_freshness": {
                      "$comment": "json-value"
                    },
                    "suggested_action": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "related_competitor_ids": {
                      "type": "array",
                      "items": {
                        "format": "uuid",
                        "type": "string"
                      }
                    },
                    "related_trend_ids": {
                      "type": "array",
                      "items": {
                        "format": "uuid",
                        "type": "string"
                      }
                    },
                    "status": {
                      "type": "string"
                    },
                    "created_at": {
                      "format": "date-time",
                      "type": "string"
                    },
                    "updated_at": {
                      "format": "date-time",
                      "type": "string"
                    },
                    "expires_at": {
                      "anyOf": [
                        {
                          "format": "date-time",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "applied_at": {
                      "anyOf": [
                        {
                          "format": "date-time",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "snoozed_until": {
                      "anyOf": [
                        {
                          "format": "date-time",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/strategic/opportunities/{id}/snooze": {
      "patch": {
        "operationId": "patchApiV1StrategicOpportunitiesByIdSnooze",
        "summary": "Snooze strategic opportunity",
        "tags": [
          "strategic-details"
        ],
        "description": "Temporarily snoozes a strategic opportunity for 1, 7, or 30 days.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "days"
                ],
                "properties": {
                  "days": {
                    "anyOf": [
                      {
                        "type": "number",
                        "enum": [
                          1
                        ]
                      },
                      {
                        "type": "number",
                        "enum": [
                          7
                        ]
                      },
                      {
                        "type": "number",
                        "enum": [
                          30
                        ]
                      }
                    ]
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "id",
                    "team_id",
                    "source_snapshot_id",
                    "scope_type",
                    "scope_id",
                    "opportunity_type",
                    "title",
                    "summary",
                    "opportunity_score",
                    "evidence",
                    "source_freshness",
                    "suggested_action",
                    "related_competitor_ids",
                    "related_trend_ids",
                    "status",
                    "created_at",
                    "updated_at",
                    "expires_at",
                    "applied_at",
                    "snoozed_until"
                  ],
                  "properties": {
                    "id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "team_id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "source_snapshot_id": {
                      "anyOf": [
                        {
                          "format": "uuid",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "scope_type": {
                      "type": "string"
                    },
                    "scope_id": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "opportunity_type": {
                      "type": "string"
                    },
                    "title": {
                      "type": "string"
                    },
                    "summary": {
                      "type": "string"
                    },
                    "opportunity_score": {
                      "anyOf": [
                        {
                          "type": "number"
                        },
                        {
                          "type": "string"
                        }
                      ]
                    },
                    "evidence": {
                      "$comment": "json-value"
                    },
                    "source_freshness": {
                      "$comment": "json-value"
                    },
                    "suggested_action": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "related_competitor_ids": {
                      "type": "array",
                      "items": {
                        "format": "uuid",
                        "type": "string"
                      }
                    },
                    "related_trend_ids": {
                      "type": "array",
                      "items": {
                        "format": "uuid",
                        "type": "string"
                      }
                    },
                    "status": {
                      "type": "string"
                    },
                    "created_at": {
                      "format": "date-time",
                      "type": "string"
                    },
                    "updated_at": {
                      "format": "date-time",
                      "type": "string"
                    },
                    "expires_at": {
                      "anyOf": [
                        {
                          "format": "date-time",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "applied_at": {
                      "anyOf": [
                        {
                          "format": "date-time",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "snoozed_until": {
                      "anyOf": [
                        {
                          "format": "date-time",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/strategic/recommendations": {
      "get": {
        "operationId": "getApiV1StrategicRecommendations",
        "summary": "List strategic recommendations",
        "tags": [
          "strategic-details"
        ],
        "description": "Returns recent strategic recommendations for the accessible team scope.",
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "items"
                  ],
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "additionalProperties": false,
                        "type": "object",
                        "required": [
                          "id",
                          "team_id",
                          "opportunity_id",
                          "recommendation_type",
                          "title",
                          "recommendation",
                          "content",
                          "evidence",
                          "source_freshness",
                          "score",
                          "priority",
                          "status",
                          "created_at",
                          "updated_at",
                          "expires_at",
                          "applied_at",
                          "dismissed_at"
                        ],
                        "properties": {
                          "id": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "team_id": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "opportunity_id": {
                            "anyOf": [
                              {
                                "format": "uuid",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "recommendation_type": {
                            "type": "string"
                          },
                          "title": {
                            "type": "string"
                          },
                          "recommendation": {
                            "type": "string"
                          },
                          "content": {
                            "$comment": "json-value"
                          },
                          "evidence": {
                            "$comment": "json-value"
                          },
                          "source_freshness": {
                            "$comment": "json-value"
                          },
                          "score": {
                            "type": "integer"
                          },
                          "priority": {
                            "type": "string"
                          },
                          "status": {
                            "type": "string"
                          },
                          "created_at": {
                            "format": "date-time",
                            "type": "string"
                          },
                          "updated_at": {
                            "format": "date-time",
                            "type": "string"
                          },
                          "expires_at": {
                            "anyOf": [
                              {
                                "format": "date-time",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "applied_at": {
                            "anyOf": [
                              {
                                "format": "date-time",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "dismissed_at": {
                            "anyOf": [
                              {
                                "format": "date-time",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/strategic/recommendations/{id}/status": {
      "patch": {
        "operationId": "patchApiV1StrategicRecommendationsByIdStatus",
        "summary": "Update strategic recommendation status",
        "tags": [
          "strategic-details"
        ],
        "description": "Updates the lifecycle status for a strategic recommendation.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "status"
                ],
                "properties": {
                  "status": {
                    "anyOf": [
                      {
                        "type": "string",
                        "enum": [
                          "open"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "applied"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "dismissed"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "archived"
                        ]
                      }
                    ]
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "id",
                    "team_id",
                    "opportunity_id",
                    "recommendation_type",
                    "title",
                    "recommendation",
                    "content",
                    "evidence",
                    "source_freshness",
                    "score",
                    "priority",
                    "status",
                    "created_at",
                    "updated_at",
                    "expires_at",
                    "applied_at",
                    "dismissed_at"
                  ],
                  "properties": {
                    "id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "team_id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "opportunity_id": {
                      "anyOf": [
                        {
                          "format": "uuid",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "recommendation_type": {
                      "type": "string"
                    },
                    "title": {
                      "type": "string"
                    },
                    "recommendation": {
                      "type": "string"
                    },
                    "content": {
                      "$comment": "json-value"
                    },
                    "evidence": {
                      "$comment": "json-value"
                    },
                    "source_freshness": {
                      "$comment": "json-value"
                    },
                    "score": {
                      "type": "integer"
                    },
                    "priority": {
                      "type": "string"
                    },
                    "status": {
                      "type": "string"
                    },
                    "created_at": {
                      "format": "date-time",
                      "type": "string"
                    },
                    "updated_at": {
                      "format": "date-time",
                      "type": "string"
                    },
                    "expires_at": {
                      "anyOf": [
                        {
                          "format": "date-time",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "applied_at": {
                      "anyOf": [
                        {
                          "format": "date-time",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "dismissed_at": {
                      "anyOf": [
                        {
                          "format": "date-time",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/strategic/recommendations/channel-mix": {
      "get": {
        "operationId": "getApiV1StrategicRecommendationsChannelMix",
        "summary": "Get channel mix recommendation",
        "tags": [
          "strategic-details"
        ],
        "description": "Returns current channel allocation and suggested budget shifts from the latest strategic report or live fallback data.",
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "action",
                    "crossChannelShifts",
                    "current",
                    "dateRange",
                    "mode",
                    "reasoning",
                    "recommendations",
                    "sourceConfidence",
                    "suggested"
                  ],
                  "properties": {
                    "action": {
                      "anyOf": [
                        {
                          "additionalProperties": false,
                          "type": "object",
                          "required": [
                            "aiPrompt",
                            "description",
                            "id",
                            "title"
                          ],
                          "properties": {
                            "aiPrompt": {
                              "type": "string"
                            },
                            "description": {
                              "type": "string"
                            },
                            "id": {
                              "type": "string"
                            },
                            "title": {
                              "type": "string"
                            }
                          }
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "crossChannelShifts": {
                      "type": "array",
                      "items": {
                        "$comment": "json-value"
                      }
                    },
                    "current": {
                      "type": "array",
                      "items": {
                        "additionalProperties": false,
                        "type": "object",
                        "required": [
                          "channel",
                          "conversions",
                          "currentPercent",
                          "spend"
                        ],
                        "properties": {
                          "channel": {
                            "type": "string"
                          },
                          "conversions": {
                            "type": "number"
                          },
                          "currentPercent": {
                            "type": "integer"
                          },
                          "spend": {
                            "type": "number"
                          }
                        }
                      }
                    },
                    "dateRange": {
                      "type": "object",
                      "required": [
                        "fromDate",
                        "toDate"
                      ],
                      "properties": {
                        "fromDate": {
                          "format": "date",
                          "type": "string"
                        },
                        "toDate": {
                          "format": "date",
                          "type": "string"
                        }
                      }
                    },
                    "headline": {
                      "type": "string"
                    },
                    "mode": {
                      "anyOf": [
                        {
                          "type": "string",
                          "enum": [
                            "report"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "fallback"
                          ]
                        }
                      ]
                    },
                    "reasoning": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "recommendations": {
                      "type": "array",
                      "items": {
                        "$comment": "json-value"
                      }
                    },
                    "sourceConfidence": {
                      "type": "integer"
                    },
                    "suggested": {
                      "type": "array",
                      "items": {
                        "additionalProperties": false,
                        "type": "object",
                        "required": [
                          "channel",
                          "reason",
                          "suggestedPercent"
                        ],
                        "properties": {
                          "channel": {
                            "type": "string"
                          },
                          "reason": {
                            "type": "string"
                          },
                          "suggestedPercent": {
                            "type": "integer"
                          }
                        }
                      }
                    },
                    "title": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/strategic/recommendations/budget-advisor": {
      "get": {
        "operationId": "getApiV1StrategicRecommendationsBudgetAdvisor",
        "summary": "Get budget advisor",
        "tags": [
          "strategic-details"
        ],
        "description": "Returns seasonal budget-reserve recommendations derived from stored seasonal patterns.",
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "currency",
                    "dateRange",
                    "items",
                    "sourceConfidence"
                  ],
                  "properties": {
                    "currency": {
                      "type": "string"
                    },
                    "dateRange": {
                      "type": "object",
                      "required": [
                        "fromDate",
                        "toDate"
                      ],
                      "properties": {
                        "fromDate": {
                          "format": "date",
                          "type": "string"
                        },
                        "toDate": {
                          "format": "date",
                          "type": "string"
                        }
                      }
                    },
                    "items": {
                      "type": "array",
                      "items": {
                        "additionalProperties": false,
                        "type": "object",
                        "required": [
                          "date",
                          "daysUntil",
                          "estimatedBudgetReserve",
                          "estimatedCpmLiftPct",
                          "evidenceSource",
                          "name",
                          "preparation",
                          "rationale"
                        ],
                        "properties": {
                          "date": {
                            "format": "date",
                            "type": "string"
                          },
                          "daysUntil": {
                            "type": "integer"
                          },
                          "estimatedBudgetReserve": {
                            "type": "null"
                          },
                          "estimatedCpmLiftPct": {
                            "anyOf": [
                              {
                                "type": "number"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "evidenceSource": {
                            "type": "string"
                          },
                          "name": {
                            "type": "string"
                          },
                          "preparation": {
                            "type": "array",
                            "items": {
                              "type": "string"
                            }
                          },
                          "rationale": {
                            "type": "string"
                          }
                        }
                      }
                    },
                    "sourceConfidence": {
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/strategic/upcoming-events": {
      "get": {
        "operationId": "getApiV1StrategicUpcomingEvents",
        "summary": "List upcoming strategic events",
        "tags": [
          "strategic-details"
        ],
        "description": "Returns public holidays and commerce events relevant to the account market geography.",
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "geo",
                    "items"
                  ],
                  "properties": {
                    "geo": {
                      "type": "string"
                    },
                    "items": {
                      "type": "array",
                      "items": {
                        "additionalProperties": false,
                        "type": "object",
                        "required": [
                          "date",
                          "daysUntil",
                          "name",
                          "source",
                          "type"
                        ],
                        "properties": {
                          "countryCode": {
                            "type": "string"
                          },
                          "date": {
                            "format": "date",
                            "type": "string"
                          },
                          "daysUntil": {
                            "type": "integer"
                          },
                          "name": {
                            "type": "string"
                          },
                          "source": {
                            "anyOf": [
                              {
                                "type": "string",
                                "enum": [
                                  "nager.at"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "commerce-static"
                                ]
                              }
                            ]
                          },
                          "type": {
                            "anyOf": [
                              {
                                "type": "string",
                                "enum": [
                                  "public_holiday"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "commerce"
                                ]
                              }
                            ]
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/strategic/context": {
      "get": {
        "operationId": "getApiV1StrategicContext",
        "summary": "Get strategic intelligence context",
        "tags": [
          "strategic-details"
        ],
        "description": "Returns latest strategic brief context, opportunities, recommendations, budget advisor, and channel mix data.",
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "budgetAdvisor",
                    "channelMix",
                    "latestBrief",
                    "opportunities",
                    "recommendations"
                  ],
                  "properties": {
                    "budgetAdvisor": {
                      "type": "array",
                      "items": {
                        "additionalProperties": false,
                        "type": "object",
                        "required": [
                          "date",
                          "daysUntil",
                          "estimatedBudgetReserve",
                          "estimatedCpmLiftPct",
                          "evidenceSource",
                          "name",
                          "preparation",
                          "rationale"
                        ],
                        "properties": {
                          "date": {
                            "format": "date",
                            "type": "string"
                          },
                          "daysUntil": {
                            "type": "integer"
                          },
                          "estimatedBudgetReserve": {
                            "type": "null"
                          },
                          "estimatedCpmLiftPct": {
                            "anyOf": [
                              {
                                "type": "number"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "evidenceSource": {
                            "type": "string"
                          },
                          "name": {
                            "type": "string"
                          },
                          "preparation": {
                            "type": "array",
                            "items": {
                              "type": "string"
                            }
                          },
                          "rationale": {
                            "type": "string"
                          }
                        }
                      }
                    },
                    "channelMix": {
                      "additionalProperties": false,
                      "type": "object",
                      "required": [
                        "action",
                        "crossChannelShifts",
                        "current",
                        "dateRange",
                        "mode",
                        "reasoning",
                        "recommendations",
                        "sourceConfidence",
                        "suggested"
                      ],
                      "properties": {
                        "action": {
                          "anyOf": [
                            {
                              "additionalProperties": false,
                              "type": "object",
                              "required": [
                                "aiPrompt",
                                "description",
                                "id",
                                "title"
                              ],
                              "properties": {
                                "aiPrompt": {
                                  "type": "string"
                                },
                                "description": {
                                  "type": "string"
                                },
                                "id": {
                                  "type": "string"
                                },
                                "title": {
                                  "type": "string"
                                }
                              }
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "crossChannelShifts": {
                          "type": "array",
                          "items": {
                            "$comment": "json-value"
                          }
                        },
                        "current": {
                          "type": "array",
                          "items": {
                            "additionalProperties": false,
                            "type": "object",
                            "required": [
                              "channel",
                              "conversions",
                              "currentPercent",
                              "spend"
                            ],
                            "properties": {
                              "channel": {
                                "type": "string"
                              },
                              "conversions": {
                                "type": "number"
                              },
                              "currentPercent": {
                                "type": "integer"
                              },
                              "spend": {
                                "type": "number"
                              }
                            }
                          }
                        },
                        "dateRange": {
                          "type": "object",
                          "required": [
                            "fromDate",
                            "toDate"
                          ],
                          "properties": {
                            "fromDate": {
                              "format": "date",
                              "type": "string"
                            },
                            "toDate": {
                              "format": "date",
                              "type": "string"
                            }
                          }
                        },
                        "headline": {
                          "type": "string"
                        },
                        "mode": {
                          "anyOf": [
                            {
                              "type": "string",
                              "enum": [
                                "report"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "fallback"
                              ]
                            }
                          ]
                        },
                        "reasoning": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "recommendations": {
                          "type": "array",
                          "items": {
                            "$comment": "json-value"
                          }
                        },
                        "sourceConfidence": {
                          "type": "integer"
                        },
                        "suggested": {
                          "type": "array",
                          "items": {
                            "additionalProperties": false,
                            "type": "object",
                            "required": [
                              "channel",
                              "reason",
                              "suggestedPercent"
                            ],
                            "properties": {
                              "channel": {
                                "type": "string"
                              },
                              "reason": {
                                "type": "string"
                              },
                              "suggestedPercent": {
                                "type": "integer"
                              }
                            }
                          }
                        },
                        "title": {
                          "type": "string"
                        }
                      }
                    },
                    "latestBrief": {
                      "anyOf": [
                        {
                          "additionalProperties": false,
                          "type": "object",
                          "required": [
                            "id",
                            "team_id",
                            "dimension",
                            "period_type",
                            "period_start",
                            "period_end",
                            "previous_period_start",
                            "previous_period_end",
                            "status",
                            "content",
                            "degraded_dimensions",
                            "model_used",
                            "generated_at",
                            "status_reason",
                            "is_read",
                            "read_at",
                            "created_at",
                            "updated_at",
                            "deleted_at"
                          ],
                          "properties": {
                            "id": {
                              "format": "uuid",
                              "type": "string"
                            },
                            "team_id": {
                              "format": "uuid",
                              "type": "string"
                            },
                            "dimension": {
                              "type": "string"
                            },
                            "period_type": {
                              "type": "string"
                            },
                            "period_start": {
                              "format": "date",
                              "type": "string"
                            },
                            "period_end": {
                              "format": "date",
                              "type": "string"
                            },
                            "previous_period_start": {
                              "anyOf": [
                                {
                                  "format": "date",
                                  "type": "string"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "previous_period_end": {
                              "anyOf": [
                                {
                                  "format": "date",
                                  "type": "string"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "status": {
                              "type": "string"
                            },
                            "content": {
                              "$comment": "json-value"
                            },
                            "degraded_dimensions": {
                              "type": "array",
                              "items": {
                                "type": "string"
                              }
                            },
                            "model_used": {
                              "anyOf": [
                                {
                                  "type": "string"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "generated_at": {
                              "anyOf": [
                                {
                                  "format": "date-time",
                                  "type": "string"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "status_reason": {
                              "anyOf": [
                                {
                                  "type": "string"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "is_read": {
                              "type": "boolean"
                            },
                            "read_at": {
                              "anyOf": [
                                {
                                  "format": "date-time",
                                  "type": "string"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "created_at": {
                              "format": "date-time",
                              "type": "string"
                            },
                            "updated_at": {
                              "format": "date-time",
                              "type": "string"
                            },
                            "deleted_at": {
                              "anyOf": [
                                {
                                  "format": "date-time",
                                  "type": "string"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            }
                          }
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "opportunities": {
                      "type": "array",
                      "items": {
                        "additionalProperties": false,
                        "type": "object",
                        "required": [
                          "id",
                          "team_id",
                          "source_snapshot_id",
                          "scope_type",
                          "scope_id",
                          "opportunity_type",
                          "title",
                          "summary",
                          "opportunity_score",
                          "evidence",
                          "source_freshness",
                          "suggested_action",
                          "related_competitor_ids",
                          "related_trend_ids",
                          "status",
                          "created_at",
                          "updated_at",
                          "expires_at",
                          "applied_at",
                          "snoozed_until"
                        ],
                        "properties": {
                          "id": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "team_id": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "source_snapshot_id": {
                            "anyOf": [
                              {
                                "format": "uuid",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "scope_type": {
                            "type": "string"
                          },
                          "scope_id": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "opportunity_type": {
                            "type": "string"
                          },
                          "title": {
                            "type": "string"
                          },
                          "summary": {
                            "type": "string"
                          },
                          "opportunity_score": {
                            "anyOf": [
                              {
                                "type": "number"
                              },
                              {
                                "type": "string"
                              }
                            ]
                          },
                          "evidence": {
                            "$comment": "json-value"
                          },
                          "source_freshness": {
                            "$comment": "json-value"
                          },
                          "suggested_action": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "related_competitor_ids": {
                            "type": "array",
                            "items": {
                              "format": "uuid",
                              "type": "string"
                            }
                          },
                          "related_trend_ids": {
                            "type": "array",
                            "items": {
                              "format": "uuid",
                              "type": "string"
                            }
                          },
                          "status": {
                            "type": "string"
                          },
                          "created_at": {
                            "format": "date-time",
                            "type": "string"
                          },
                          "updated_at": {
                            "format": "date-time",
                            "type": "string"
                          },
                          "expires_at": {
                            "anyOf": [
                              {
                                "format": "date-time",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "applied_at": {
                            "anyOf": [
                              {
                                "format": "date-time",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "snoozed_until": {
                            "anyOf": [
                              {
                                "format": "date-time",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          }
                        }
                      }
                    },
                    "recommendations": {
                      "type": "array",
                      "items": {
                        "additionalProperties": false,
                        "type": "object",
                        "required": [
                          "id",
                          "team_id",
                          "opportunity_id",
                          "recommendation_type",
                          "title",
                          "recommendation",
                          "content",
                          "evidence",
                          "source_freshness",
                          "score",
                          "priority",
                          "status",
                          "created_at",
                          "updated_at",
                          "expires_at",
                          "applied_at",
                          "dismissed_at"
                        ],
                        "properties": {
                          "id": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "team_id": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "opportunity_id": {
                            "anyOf": [
                              {
                                "format": "uuid",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "recommendation_type": {
                            "type": "string"
                          },
                          "title": {
                            "type": "string"
                          },
                          "recommendation": {
                            "type": "string"
                          },
                          "content": {
                            "$comment": "json-value"
                          },
                          "evidence": {
                            "$comment": "json-value"
                          },
                          "source_freshness": {
                            "$comment": "json-value"
                          },
                          "score": {
                            "type": "integer"
                          },
                          "priority": {
                            "type": "string"
                          },
                          "status": {
                            "type": "string"
                          },
                          "created_at": {
                            "format": "date-time",
                            "type": "string"
                          },
                          "updated_at": {
                            "format": "date-time",
                            "type": "string"
                          },
                          "expires_at": {
                            "anyOf": [
                              {
                                "format": "date-time",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "applied_at": {
                            "anyOf": [
                              {
                                "format": "date-time",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "dismissed_at": {
                            "anyOf": [
                              {
                                "format": "date-time",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/strategic-plans": {
      "get": {
        "operationId": "getApiV1StrategicPlans",
        "summary": "List strategic plans",
        "tags": [
          "strategic-plan"
        ],
        "description": "Lists the strategic plans owned by the authenticated user, with per-step progress.",
        "parameters": [
          {
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "enum": [
                    "active"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "completed"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "archived"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "all"
                  ]
                }
              ]
            },
            "in": "query",
            "name": "status",
            "required": false
          },
          {
            "schema": {
              "maxLength": 200,
              "type": "string"
            },
            "in": "query",
            "name": "q",
            "required": false
          },
          {
            "schema": {
              "minimum": 1,
              "maximum": 100,
              "default": 50,
              "type": "integer"
            },
            "in": "query",
            "name": "limit",
            "required": false
          },
          {
            "schema": {
              "minimum": 0,
              "default": 0,
              "type": "integer"
            },
            "in": "query",
            "name": "offset",
            "required": false
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "items",
                    "total"
                  ],
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "additionalProperties": false,
                        "type": "object",
                        "required": [
                          "id",
                          "objective",
                          "title",
                          "status",
                          "progress_pct",
                          "created_at",
                          "updated_at",
                          "steps"
                        ],
                        "properties": {
                          "id": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "objective": {
                            "type": "string"
                          },
                          "title": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "status": {
                            "type": "string"
                          },
                          "progress_pct": {
                            "type": "number"
                          },
                          "created_at": {
                            "type": "string",
                            "format": "date-time"
                          },
                          "updated_at": {
                            "type": "string",
                            "format": "date-time"
                          },
                          "steps": {
                            "type": "array",
                            "items": {
                              "additionalProperties": false,
                              "type": "object",
                              "required": [
                                "step_type",
                                "step_order",
                                "status",
                                "progress_pct",
                                "started_at"
                              ],
                              "properties": {
                                "step_type": {
                                  "type": "string"
                                },
                                "step_order": {
                                  "type": "integer"
                                },
                                "status": {
                                  "type": "string"
                                },
                                "progress_pct": {
                                  "type": "number"
                                },
                                "started_at": {
                                  "anyOf": [
                                    {
                                      "type": "string",
                                      "format": "date-time"
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                }
                              }
                            }
                          }
                        }
                      }
                    },
                    "total": {
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "postApiV1StrategicPlans",
        "summary": "Create a strategic plan",
        "tags": [
          "strategic-plan"
        ],
        "description": "Creates a plan from a macro objective and the confirmed connection selection. Requires an explicit destination workspace/team and seeds the 4 pipeline steps in pending state.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "objective"
                ],
                "properties": {
                  "objective": {
                    "minLength": 3,
                    "maxLength": 4000,
                    "type": "string"
                  },
                  "title": {
                    "minLength": 1,
                    "maxLength": 200,
                    "type": "string"
                  },
                  "budget": {
                    "minimum": 0,
                    "type": "number"
                  },
                  "budget_currency": {
                    "maxLength": 8,
                    "type": "string"
                  },
                  "connections": {
                    "description": "JSON object with nested arrays and objects.",
                    "type": "object",
                    "additionalProperties": {
                      "$comment": "json-value",
                      "description": "Arbitrary JSON value with nested arrays and objects."
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "201": {
            "description": "Resource created",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "id",
                    "objective",
                    "status"
                  ],
                  "properties": {
                    "id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "objective": {
                      "type": "string"
                    },
                    "status": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/strategic-plans/interpret": {
      "post": {
        "operationId": "postApiV1StrategicPlansInterpret",
        "summary": "Interpret a raw objective into a structured plan objective",
        "tags": [
          "strategic-plan"
        ],
        "description": "Wavo reads the free-form objective and returns a refined objective plus a recap to confirm before creating the plan.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "objective"
                ],
                "properties": {
                  "objective": {
                    "minLength": 3,
                    "maxLength": 4000,
                    "type": "string"
                  },
                  "notes": {
                    "maxLength": 2000,
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "title",
                    "objective",
                    "understanding"
                  ],
                  "properties": {
                    "title": {
                      "type": "string"
                    },
                    "objective": {
                      "type": "string"
                    },
                    "understanding": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/strategic-plans/connectable-resources": {
      "get": {
        "operationId": "getApiV1StrategicPlansConnectableResources",
        "summary": "List connectable resources for plan connections",
        "tags": [
          "strategic-plan"
        ],
        "description": "Returns the connected ad accounts grouped by platform, for granular Step 0 selection.",
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "platforms"
                  ],
                  "properties": {
                    "platforms": {
                      "type": "array",
                      "items": {
                        "additionalProperties": false,
                        "type": "object",
                        "required": [
                          "slug",
                          "accounts"
                        ],
                        "properties": {
                          "slug": {
                            "type": "string"
                          },
                          "accounts": {
                            "type": "array",
                            "items": {
                              "additionalProperties": false,
                              "type": "object",
                              "required": [
                                "id",
                                "name",
                                "currency"
                              ],
                              "properties": {
                                "id": {
                                  "type": "string"
                                },
                                "name": {
                                  "type": "string"
                                },
                                "currency": {
                                  "anyOf": [
                                    {
                                      "type": "string"
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                }
                              }
                            }
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/strategic-plans/{planId}": {
      "get": {
        "operationId": "getApiV1StrategicPlansByPlanId",
        "summary": "Get a strategic plan",
        "tags": [
          "strategic-plan"
        ],
        "description": "Returns the full plan: steps, latest deliverables and any open questionnaire.",
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "planId",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "id",
                    "objective",
                    "title",
                    "budget",
                    "budget_currency",
                    "status",
                    "progress_pct",
                    "connections",
                    "chat_project_id",
                    "created_at",
                    "updated_at",
                    "completed_at",
                    "steps"
                  ],
                  "properties": {
                    "id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "objective": {
                      "type": "string"
                    },
                    "title": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "budget": {
                      "anyOf": [
                        {
                          "type": "number"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "budget_currency": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "status": {
                      "type": "string"
                    },
                    "progress_pct": {
                      "type": "number"
                    },
                    "connections": {
                      "$comment": "json-value",
                      "description": "Arbitrary JSON value with nested arrays and objects."
                    },
                    "chat_project_id": {
                      "anyOf": [
                        {
                          "format": "uuid",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "created_at": {
                      "type": "string",
                      "format": "date-time"
                    },
                    "updated_at": {
                      "type": "string",
                      "format": "date-time"
                    },
                    "completed_at": {
                      "anyOf": [
                        {
                          "type": "string",
                          "format": "date-time"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "steps": {
                      "type": "array",
                      "items": {
                        "additionalProperties": false,
                        "type": "object",
                        "required": [
                          "id",
                          "step_type",
                          "step_order",
                          "status",
                          "version",
                          "progress_pct",
                          "progress_detail",
                          "credits_used",
                          "change_summary",
                          "eta_seconds",
                          "error",
                          "started_at",
                          "ready_at",
                          "approved_at",
                          "deliverable",
                          "questionnaire"
                        ],
                        "properties": {
                          "id": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "step_type": {
                            "type": "string"
                          },
                          "step_order": {
                            "type": "integer"
                          },
                          "status": {
                            "type": "string"
                          },
                          "version": {
                            "type": "integer"
                          },
                          "progress_pct": {
                            "type": "number"
                          },
                          "progress_detail": {
                            "anyOf": [
                              {
                                "type": "array",
                                "items": {
                                  "additionalProperties": true,
                                  "type": "object",
                                  "required": [
                                    "key",
                                    "status"
                                  ],
                                  "properties": {
                                    "key": {
                                      "type": "string"
                                    },
                                    "status": {
                                      "type": "string"
                                    },
                                    "startedAt": {
                                      "type": "string"
                                    },
                                    "endedAt": {
                                      "type": "string"
                                    }
                                  }
                                }
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "credits_used": {
                            "anyOf": [
                              {
                                "type": "number"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "change_summary": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "eta_seconds": {
                            "anyOf": [
                              {
                                "type": "integer"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "error": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "started_at": {
                            "anyOf": [
                              {
                                "type": "string",
                                "format": "date-time"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "ready_at": {
                            "anyOf": [
                              {
                                "type": "string",
                                "format": "date-time"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "approved_at": {
                            "anyOf": [
                              {
                                "type": "string",
                                "format": "date-time"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "deliverable": {
                            "anyOf": [
                              {
                                "additionalProperties": false,
                                "type": "object",
                                "required": [
                                  "id",
                                  "version",
                                  "sections",
                                  "edited_at"
                                ],
                                "properties": {
                                  "id": {
                                    "format": "uuid",
                                    "type": "string"
                                  },
                                  "version": {
                                    "type": "integer"
                                  },
                                  "sections": {
                                    "type": "array",
                                    "items": {
                                      "additionalProperties": false,
                                      "type": "object",
                                      "required": [
                                        "key",
                                        "title",
                                        "content_md"
                                      ],
                                      "properties": {
                                        "key": {
                                          "maxLength": 80,
                                          "type": "string"
                                        },
                                        "title": {
                                          "maxLength": 300,
                                          "type": "string"
                                        },
                                        "content_md": {
                                          "type": "string"
                                        }
                                      }
                                    }
                                  },
                                  "edited_at": {
                                    "anyOf": [
                                      {
                                        "type": "string",
                                        "format": "date-time"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  }
                                }
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "questionnaire": {
                            "anyOf": [
                              {
                                "additionalProperties": false,
                                "type": "object",
                                "required": [
                                  "id",
                                  "status",
                                  "questions",
                                  "answers"
                                ],
                                "properties": {
                                  "id": {
                                    "format": "uuid",
                                    "type": "string"
                                  },
                                  "status": {
                                    "type": "string"
                                  },
                                  "questions": {
                                    "type": "array",
                                    "items": {
                                      "additionalProperties": true,
                                      "type": "object",
                                      "required": [
                                        "id",
                                        "prompt"
                                      ],
                                      "properties": {
                                        "id": {
                                          "type": "string"
                                        },
                                        "prompt": {
                                          "type": "string"
                                        },
                                        "kind": {
                                          "type": "string"
                                        },
                                        "options": {
                                          "type": "array",
                                          "items": {
                                            "type": "string"
                                          }
                                        },
                                        "required": {
                                          "type": "boolean"
                                        }
                                      }
                                    }
                                  },
                                  "answers": {
                                    "type": "array",
                                    "items": {
                                      "additionalProperties": false,
                                      "type": "object",
                                      "required": [
                                        "question_id",
                                        "value"
                                      ],
                                      "properties": {
                                        "question_id": {
                                          "type": "string"
                                        },
                                        "value": {
                                          "$comment": "json-value",
                                          "description": "Arbitrary JSON value with nested arrays and objects."
                                        }
                                      }
                                    }
                                  }
                                }
                              },
                              {
                                "type": "null"
                              }
                            ]
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      },
      "patch": {
        "operationId": "patchApiV1StrategicPlansByPlanId",
        "summary": "Update a strategic plan",
        "tags": [
          "strategic-plan"
        ],
        "description": "Updates the display title and/or the objective text. At least one field must be provided.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "properties": {
                  "title": {
                    "minLength": 1,
                    "maxLength": 200,
                    "type": "string"
                  },
                  "objective": {
                    "minLength": 3,
                    "maxLength": 4000,
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "planId",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "id",
                    "title",
                    "objective"
                  ],
                  "properties": {
                    "id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "title": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "objective": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      },
      "delete": {
        "operationId": "deleteApiV1StrategicPlansByPlanId",
        "summary": "Delete a strategic plan",
        "tags": [
          "strategic-plan"
        ],
        "description": "Soft-deletes the plan and cascades to its steps and deliverables.",
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "planId",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "204": {
            "description": "No content"
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/strategic-plans/{planId}/connections": {
      "patch": {
        "operationId": "patchApiV1StrategicPlansByPlanIdConnections",
        "summary": "Update plan connection selection",
        "tags": [
          "strategic-plan"
        ],
        "description": "Replaces the confirmed connection selection (Step 0) for the plan.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "connections"
                ],
                "properties": {
                  "connections": {
                    "description": "JSON object with nested arrays and objects.",
                    "type": "object",
                    "additionalProperties": {
                      "$comment": "json-value",
                      "description": "Arbitrary JSON value with nested arrays and objects."
                    }
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "planId",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "ok"
                  ],
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/strategic-plans/{planId}/steps/{stepType}/run": {
      "post": {
        "operationId": "postApiV1StrategicPlansByPlanIdStepsByStepTypeRun",
        "summary": "Run a plan step",
        "tags": [
          "strategic-plan"
        ],
        "description": "Dispatches the step to background execution. Fails with 409 if earlier steps are not approved.",
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "planId",
            "required": true
          },
          {
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "enum": [
                    "current_state"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "market"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "budget"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "scope"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "paid_strategy"
                  ]
                }
              ]
            },
            "in": "path",
            "name": "stepType",
            "required": true,
            "description": "Pipeline step: current_state | market | scope | paid_strategy"
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "202": {
            "description": "Accepted - processing asynchronously",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "status"
                  ],
                  "properties": {
                    "status": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "Conflict - resource state prevents the operation",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/strategic-plans/{planId}/steps/{stepType}/answers": {
      "post": {
        "operationId": "postApiV1StrategicPlansByPlanIdStepsByStepTypeAnswers",
        "summary": "Submit questionnaire answers for a step",
        "tags": [
          "strategic-plan"
        ],
        "description": "Stores the answers and re-runs the step to finalize the deliverable.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "answers"
                ],
                "properties": {
                  "answers": {
                    "maxItems": 50,
                    "type": "array",
                    "items": {
                      "additionalProperties": false,
                      "type": "object",
                      "required": [
                        "question_id",
                        "value"
                      ],
                      "properties": {
                        "question_id": {
                          "maxLength": 100,
                          "type": "string"
                        },
                        "value": {
                          "$comment": "json-value",
                          "description": "Arbitrary JSON value with nested arrays and objects."
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "planId",
            "required": true
          },
          {
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "enum": [
                    "current_state"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "market"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "budget"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "scope"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "paid_strategy"
                  ]
                }
              ]
            },
            "in": "path",
            "name": "stepType",
            "required": true,
            "description": "Pipeline step: current_state | market | scope | paid_strategy"
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "202": {
            "description": "Accepted - processing asynchronously",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "status"
                  ],
                  "properties": {
                    "status": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/strategic-plans/{planId}/steps/{stepType}/deliverable": {
      "patch": {
        "operationId": "patchApiV1StrategicPlansByPlanIdStepsByStepTypeDeliverable",
        "summary": "Edit a step deliverable inline",
        "tags": [
          "strategic-plan"
        ],
        "description": "Replaces the current deliverable sections with user-authored content.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "sections"
                ],
                "properties": {
                  "sections": {
                    "maxItems": 50,
                    "type": "array",
                    "items": {
                      "additionalProperties": false,
                      "type": "object",
                      "required": [
                        "key",
                        "title",
                        "content_md"
                      ],
                      "properties": {
                        "key": {
                          "maxLength": 80,
                          "type": "string"
                        },
                        "title": {
                          "maxLength": 300,
                          "type": "string"
                        },
                        "content_md": {
                          "type": "string"
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "planId",
            "required": true
          },
          {
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "enum": [
                    "current_state"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "market"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "budget"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "scope"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "paid_strategy"
                  ]
                }
              ]
            },
            "in": "path",
            "name": "stepType",
            "required": true,
            "description": "Pipeline step: current_state | market | scope | paid_strategy"
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "ok"
                  ],
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "Conflict - resource state prevents the operation",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/strategic-plans/{planId}/steps/{stepType}/request-changes": {
      "post": {
        "operationId": "postApiV1StrategicPlansByPlanIdStepsByStepTypeRequestChanges",
        "summary": "Ask Wavo to revise a step deliverable",
        "tags": [
          "strategic-plan"
        ],
        "description": "Re-runs the step generation with a free-text revision instruction.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "instruction"
                ],
                "properties": {
                  "instruction": {
                    "minLength": 1,
                    "maxLength": 4000,
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "planId",
            "required": true
          },
          {
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "enum": [
                    "current_state"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "market"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "budget"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "scope"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "paid_strategy"
                  ]
                }
              ]
            },
            "in": "path",
            "name": "stepType",
            "required": true,
            "description": "Pipeline step: current_state | market | scope | paid_strategy"
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "202": {
            "description": "Accepted - processing asynchronously",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "status"
                  ],
                  "properties": {
                    "status": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "Conflict - resource state prevents the operation",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/strategic-plans/{planId}/steps/{stepType}/approve": {
      "post": {
        "operationId": "postApiV1StrategicPlansByPlanIdStepsByStepTypeApprove",
        "summary": "Approve a step",
        "tags": [
          "strategic-plan"
        ],
        "description": "Approves a ready step, unlocking the next one. Approving the final step completes the plan and generates the handoff.",
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "planId",
            "required": true
          },
          {
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "enum": [
                    "current_state"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "market"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "budget"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "scope"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "paid_strategy"
                  ]
                }
              ]
            },
            "in": "path",
            "name": "stepType",
            "required": true,
            "description": "Pipeline step: current_state | market | scope | paid_strategy"
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "status"
                  ],
                  "properties": {
                    "status": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "Conflict - resource state prevents the operation",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/strategic-plans/{planId}/steps/{stepType}/reopen": {
      "post": {
        "operationId": "postApiV1StrategicPlansByPlanIdStepsByStepTypeReopen",
        "summary": "Re-open an approved step",
        "tags": [
          "strategic-plan"
        ],
        "description": "Invalidates this step and every downstream step, returning them to pending so they can be re-run.",
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "planId",
            "required": true
          },
          {
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "enum": [
                    "current_state"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "market"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "budget"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "scope"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "paid_strategy"
                  ]
                }
              ]
            },
            "in": "path",
            "name": "stepType",
            "required": true,
            "description": "Pipeline step: current_state | market | scope | paid_strategy"
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "ok"
                  ],
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/support-tickets": {
      "get": {
        "operationId": "getApiV1SupportTickets",
        "summary": "List support tickets",
        "tags": [
          "support-tickets"
        ],
        "description": "Returns support tickets visible to the authenticated user.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "required": [
                      "id",
                      "subject",
                      "status",
                      "category",
                      "priority",
                      "created_at"
                    ],
                    "properties": {
                      "id": {
                        "format": "uuid",
                        "type": "string"
                      },
                      "subject": {
                        "type": "string"
                      },
                      "status": {
                        "type": "string"
                      },
                      "category": {
                        "type": "string"
                      },
                      "priority": {
                        "type": "string"
                      },
                      "created_at": {
                        "format": "date-time",
                        "type": "string"
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/support/pylon-identity": {
      "get": {
        "operationId": "getApiV1SupportPylonIdentity",
        "summary": "Pylon identity-verification hash",
        "tags": [
          "support"
        ],
        "description": "Return the Pylon identity-verification email hash (HMAC-SHA256 of the authenticated user email) used to load the support chat widget with a verified identity. Returns null when PYLON_IDENTITY_SECRET is not configured.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "emailHash"
                  ],
                  "properties": {
                    "emailHash": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/support/chat-entitlements": {
      "get": {
        "operationId": "getApiV1SupportChatEntitlements",
        "summary": "In-app support-chat entitlements",
        "tags": [
          "support"
        ],
        "description": "Return the in-app support-chat entitlements for the authenticated user: whether the AI assistant (Fibi) and the human live-chat handoff may be opened. Server-side source of truth for the FE render gate. Resolution order: super_admin bypass → AI for everyone → human chat date-gate (SUPPORT_CHAT_PRO_GATE_FROM) then Pro+ only. Fails OPEN on a plan-lookup error so a paying user is never locked out.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "chat_ai_enabled",
                    "chat_human_enabled"
                  ],
                  "properties": {
                    "chat_ai_enabled": {
                      "type": "boolean"
                    },
                    "chat_human_enabled": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "503": {
            "description": "Service unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/sync/status": {
      "get": {
        "operationId": "getSyncStatus",
        "summary": "Get sync progress status",
        "tags": [
          "sync"
        ],
        "description": "Returns the current sync progress for the authenticated user team, including running worker_runs (sync/assign/backfill) and the timestamp of the last completed run.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "is_syncing",
                    "overall_progress",
                    "sync_runs",
                    "last_completed_at"
                  ],
                  "properties": {
                    "is_syncing": {
                      "type": "boolean"
                    },
                    "overall_progress": {
                      "type": "integer"
                    },
                    "sync_runs": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "id",
                          "type",
                          "status",
                          "total_tasks",
                          "completed_tasks",
                          "failed_tasks",
                          "progress",
                          "created_at"
                        ],
                        "properties": {
                          "id": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "type": {
                            "description": "Subset of worker_type used for sync flows.",
                            "anyOf": [
                              {
                                "type": "string",
                                "enum": [
                                  "SYNC_AD_ACCOUNTS"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "ASSIGN_AD_ACCOUNTS"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "SYNC_FAN_PAGES"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "ASSIGN_FAN_PAGES"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "SYNC_PIXELS"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "ASSIGN_PIXELS"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "SYNC_TOKEN_PERMISSIONS"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "BACKFILL_INSIGHTS"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "SYNC_GOOGLE_AD_ACCOUNTS"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "SYNC_TIKTOK_AD_ACCOUNTS"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "SYNC_TABOOLA_AD_ACCOUNTS"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "SYNC_SNAPCHAT_AD_ACCOUNTS"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "SYNC_SNAPCHAT_PUBLIC_PROFILES"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "SYNC_SNAPCHAT_PIXELS"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "SYNC_SNAPCHAT_CATALOGS"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "SYNC_SNAPCHAT_MEMBERS"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "BACKFILL_GOOGLE_INSIGHTS"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "BACKFILL_TIKTOK_INSIGHTS"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "BACKFILL_TABOOLA_INSIGHTS"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "BACKFILL_SNAPCHAT_INSIGHTS"
                                ]
                              }
                            ]
                          },
                          "status": {
                            "description": "Lifecycle state of a worker_run.",
                            "anyOf": [
                              {
                                "type": "string",
                                "enum": [
                                  "RUNNING"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "COMPLETED"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "FAILED"
                                ]
                              }
                            ]
                          },
                          "total_tasks": {
                            "type": "integer"
                          },
                          "completed_tasks": {
                            "type": "integer"
                          },
                          "failed_tasks": {
                            "type": "integer"
                          },
                          "progress": {
                            "type": "integer"
                          },
                          "created_at": {
                            "format": "date-time",
                            "type": "string"
                          }
                        }
                      }
                    },
                    "last_completed_at": {
                      "anyOf": [
                        {
                          "format": "date-time",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/taboola/campaigns/{campaignId}/budget": {
      "post": {
        "operationId": "editTaboolaCampaignBudget",
        "summary": "Edit a Taboola campaign budget",
        "tags": [
          "taboola"
        ],
        "description": "Enqueues a budget update for the supplied Taboola campaign. The mutation runs asynchronously on the TABOOLA_EDIT_BUDGET worker; the response is an immediate ack.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "account_id",
                  "budget"
                ],
                "properties": {
                  "account_id": {
                    "minLength": 1,
                    "description": "Taboola account id that owns the campaign.",
                    "type": "string"
                  },
                  "budget": {
                    "exclusiveMinimum": 0,
                    "description": "New budget amount in account currency.",
                    "type": "number"
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "schema": {
              "minLength": 1,
              "type": "string"
            },
            "in": "path",
            "name": "campaignId",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Acknowledged enqueue (worker will apply the change asynchronously).",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "description": "Acknowledged enqueue (worker will apply the change asynchronously).",
                  "type": "object",
                  "required": [
                    "success",
                    "queued"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "queued": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "423": {
            "description": "Response 423",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number",
                      "enum": [
                        423
                      ]
                    },
                    "error": {
                      "type": "string",
                      "enum": [
                        "Locked"
                      ]
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/taboola/pixels/sync": {
      "get": {
        "operationId": "syncTaboolaPixels",
        "summary": "Sync Taboola pixels",
        "tags": [
          "taboola"
        ],
        "description": "Triggers synchronization of Taboola pixels from connected ad accounts.",
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "sheet_id",
            "required": true,
            "description": "Session/sheet ID"
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "status"
                  ],
                  "properties": {
                    "status": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/taboola/pixels": {
      "get": {
        "operationId": "listTaboolaPixels",
        "summary": "List Taboola pixels",
        "tags": [
          "taboola"
        ],
        "description": "Returns paginated list of synced Taboola pixels for the session.",
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "sheet_id",
            "required": true,
            "description": "Session/sheet ID"
          },
          {
            "schema": {
              "minimum": 1,
              "maximum": 100,
              "default": 50,
              "type": "number"
            },
            "in": "query",
            "name": "limit",
            "required": false
          },
          {
            "schema": {
              "minimum": 0,
              "default": 0,
              "type": "number"
            },
            "in": "query",
            "name": "offset",
            "required": false
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "items",
                    "total"
                  ],
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "id",
                          "session_id",
                          "account_id",
                          "account_name",
                          "pixel_name",
                          "connected",
                          "created_at",
                          "updated_at"
                        ],
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "session_id": {
                            "type": "string"
                          },
                          "account_id": {
                            "type": "string"
                          },
                          "account_name": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "pixel_name": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "connected": {
                            "type": "boolean"
                          },
                          "created_at": {
                            "type": "string"
                          },
                          "updated_at": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "member_name": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "member_email": {
                            "type": "string"
                          }
                        }
                      }
                    },
                    "total": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/taboola/users": {
      "get": {
        "operationId": "listTaboolaUsers",
        "summary": "List Taboola tokens (Users page)",
        "tags": [
          "taboola"
        ],
        "description": "Returns paginated Taboola token rows for the active workspace scope, with status counts. Tokens assigned to a team are filtered by accessible team ids; legacy team-less tokens are visible only through readable sessions. Same shape as `/api/v1/meta/users` for frontend compatibility.",
        "parameters": [
          {
            "schema": {
              "minimum": 1,
              "maximum": 100,
              "default": 50,
              "type": "integer"
            },
            "in": "query",
            "name": "limit",
            "required": false
          },
          {
            "schema": {
              "minimum": 0,
              "default": 0,
              "type": "integer"
            },
            "in": "query",
            "name": "offset",
            "required": false
          },
          {
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "enum": [
                    "ACTIVE"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "INACTIVE"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "EXPIRED"
                  ]
                }
              ]
            },
            "in": "query",
            "name": "status",
            "required": false
          },
          {
            "schema": {
              "minLength": 2,
              "maxLength": 200,
              "type": "string"
            },
            "in": "query",
            "name": "search",
            "required": false
          },
          {
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "enum": [
                    "account_name"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "token_status"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "created_at"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "updated_at"
                  ]
                }
              ]
            },
            "in": "query",
            "name": "sort_by",
            "required": false
          },
          {
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "enum": [
                    "asc"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "desc"
                  ]
                }
              ]
            },
            "in": "query",
            "name": "sort_order",
            "required": false
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "items",
                    "total",
                    "counts"
                  ],
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "additionalProperties": true,
                        "type": "object",
                        "required": [
                          "id",
                          "user_id",
                          "email",
                          "name",
                          "_accountName",
                          "token_status",
                          "business_user_ids",
                          "member_name",
                          "member_email",
                          "platform",
                          "created_at",
                          "updated_at"
                        ],
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "user_id": {
                            "description": "Taboola account id (mirrors meta-users.user_id semantics).",
                            "type": "string"
                          },
                          "email": {
                            "type": "string"
                          },
                          "name": {
                            "type": "string"
                          },
                          "_accountName": {
                            "type": "string"
                          },
                          "token_status": {
                            "anyOf": [
                              {
                                "type": "string",
                                "enum": [
                                  "ACTIVE"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "INACTIVE"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "EXPIRED"
                                ]
                              }
                            ]
                          },
                          "business_user_ids": {
                            "type": "null"
                          },
                          "member_name": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "member_email": {
                            "type": "string"
                          },
                          "platform": {
                            "type": "string",
                            "enum": [
                              "taboola"
                            ]
                          },
                          "created_at": {
                            "format": "date-time",
                            "type": "string"
                          },
                          "updated_at": {
                            "anyOf": [
                              {
                                "format": "date-time",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          }
                        }
                      }
                    },
                    "total": {
                      "type": "integer"
                    },
                    "counts": {
                      "additionalProperties": false,
                      "type": "object",
                      "required": [
                        "ACTIVE",
                        "INACTIVE",
                        "EXPIRED"
                      ],
                      "properties": {
                        "ACTIVE": {
                          "type": "integer"
                        },
                        "INACTIVE": {
                          "type": "integer"
                        },
                        "EXPIRED": {
                          "type": "integer"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/tracker-cloaker/advertisers": {
      "get": {
        "operationId": "getApiV1TrackerCloakerAdvertisers",
        "summary": "List Tracker & Cloaker advertisers",
        "tags": [
          "tracker-cloaker"
        ],
        "description": "Returns advertisers for the current team. Archived advertisers are hidden by default; pass an explicit status filter to select a specific state. Authentication, body-template, static-parameter, and sensitive custom-header values are write-only.",
        "parameters": [
          {
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "enum": [
                    "active"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "paused"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "archived"
                  ]
                }
              ]
            },
            "in": "query",
            "name": "status",
            "required": false
          },
          {
            "schema": {
              "maxLength": 200,
              "type": "string"
            },
            "in": "query",
            "name": "search",
            "required": false
          },
          {
            "schema": {
              "minimum": 1,
              "maximum": 100,
              "type": "integer"
            },
            "in": "query",
            "name": "limit",
            "required": false
          },
          {
            "schema": {
              "minimum": 0,
              "type": "integer"
            },
            "in": "query",
            "name": "offset",
            "required": false
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "items",
                    "total"
                  ],
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "id",
                          "teamId",
                          "name",
                          "apiEndpoint",
                          "apiMethod",
                          "apiAuthType",
                          "hasAuthValue",
                          "apiContentType",
                          "apiHeaders",
                          "hasBodyTemplate",
                          "bodyTemplate",
                          "fieldMapping",
                          "staticParams",
                          "successCriteria",
                          "timeoutMs",
                          "status",
                          "createdAt",
                          "updatedAt"
                        ],
                        "properties": {
                          "id": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "teamId": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "name": {
                            "type": "string"
                          },
                          "apiEndpoint": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "apiMethod": {
                            "type": "string"
                          },
                          "apiAuthType": {
                            "type": "string"
                          },
                          "hasAuthValue": {
                            "type": "boolean"
                          },
                          "apiContentType": {
                            "type": "string"
                          },
                          "apiHeaders": {
                            "description": "Custom headers. Credential-bearing values are returned as a fixed write-only mask.",
                            "anyOf": [
                              {
                                "description": "JSON object with nested arrays and objects.",
                                "type": "object",
                                "additionalProperties": {
                                  "$comment": "json-value",
                                  "description": "Arbitrary JSON value with nested arrays and objects."
                                }
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "hasBodyTemplate": {
                            "type": "boolean"
                          },
                          "bodyTemplate": {
                            "description": "Fixed write-only mask when a body template is configured; null otherwise.",
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "fieldMapping": {
                            "anyOf": [
                              {
                                "description": "JSON object with nested arrays and objects.",
                                "type": "object",
                                "additionalProperties": {
                                  "$comment": "json-value",
                                  "description": "Arbitrary JSON value with nested arrays and objects."
                                }
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "staticParams": {
                            "description": "Static-parameter keys with every configured value replaced by a fixed write-only mask.",
                            "anyOf": [
                              {
                                "description": "JSON object with nested arrays and objects.",
                                "type": "object",
                                "additionalProperties": {
                                  "$comment": "json-value",
                                  "description": "Arbitrary JSON value with nested arrays and objects."
                                }
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "successCriteria": {
                            "anyOf": [
                              {
                                "description": "JSON object with nested arrays and objects.",
                                "type": "object",
                                "additionalProperties": {
                                  "$comment": "json-value",
                                  "description": "Arbitrary JSON value with nested arrays and objects."
                                }
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "timeoutMs": {
                            "type": "number"
                          },
                          "status": {
                            "anyOf": [
                              {
                                "type": "string",
                                "enum": [
                                  "active"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "paused"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "archived"
                                ]
                              }
                            ]
                          },
                          "createdAt": {
                            "format": "date-time",
                            "type": "string"
                          },
                          "updatedAt": {
                            "anyOf": [
                              {
                                "format": "date-time",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          }
                        }
                      }
                    },
                    "total": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "postApiV1TrackerCloakerAdvertisers",
        "summary": "Create a Tracker & Cloaker advertiser",
        "tags": [
          "tracker-cloaker"
        ],
        "description": "Creates a new advertiser for the current team. Credential placeholders are invalid on create; configured secrets are encrypted at rest and write-only.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "name"
                ],
                "properties": {
                  "name": {
                    "minLength": 1,
                    "maxLength": 200,
                    "type": "string"
                  },
                  "api_endpoint": {
                    "anyOf": [
                      {
                        "maxLength": 2000,
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "api_method": {
                    "anyOf": [
                      {
                        "type": "string",
                        "enum": [
                          "GET"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "POST"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "PUT"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "PATCH"
                        ]
                      }
                    ]
                  },
                  "api_auth_type": {
                    "anyOf": [
                      {
                        "type": "string",
                        "enum": [
                          "none"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "bearer"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "basic"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "api_key"
                        ]
                      }
                    ]
                  },
                  "api_auth_value": {
                    "anyOf": [
                      {
                        "maxLength": 2000,
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "api_content_type": {
                    "anyOf": [
                      {
                        "type": "string",
                        "enum": [
                          "application/json"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "application/x-www-form-urlencoded"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "multipart/form-data"
                        ]
                      }
                    ]
                  },
                  "api_headers": {
                    "anyOf": [
                      {
                        "description": "JSON object with nested arrays and objects.",
                        "type": "object",
                        "additionalProperties": {
                          "$comment": "json-value",
                          "description": "Arbitrary JSON value with nested arrays and objects."
                        }
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "body_template": {
                    "anyOf": [
                      {
                        "maxLength": 20000,
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "field_mapping": {
                    "anyOf": [
                      {
                        "description": "JSON object with nested arrays and objects.",
                        "type": "object",
                        "additionalProperties": {
                          "$comment": "json-value",
                          "description": "Arbitrary JSON value with nested arrays and objects."
                        }
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "static_params": {
                    "anyOf": [
                      {
                        "description": "JSON object with nested arrays and objects.",
                        "type": "object",
                        "additionalProperties": {
                          "$comment": "json-value",
                          "description": "Arbitrary JSON value with nested arrays and objects."
                        }
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "success_criteria": {
                    "anyOf": [
                      {
                        "description": "JSON object with nested arrays and objects.",
                        "type": "object",
                        "additionalProperties": {
                          "$comment": "json-value",
                          "description": "Arbitrary JSON value with nested arrays and objects."
                        }
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "timeout_ms": {
                    "minimum": 500,
                    "maximum": 120000,
                    "type": "integer"
                  },
                  "status": {
                    "anyOf": [
                      {
                        "type": "string",
                        "enum": [
                          "active"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "paused"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "archived"
                        ]
                      }
                    ]
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "header",
            "name": "x-team-id",
            "required": false,
            "description": "Destination workspace team id."
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "201": {
            "description": "Resource created",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "id",
                    "teamId",
                    "name",
                    "apiEndpoint",
                    "apiMethod",
                    "apiAuthType",
                    "hasAuthValue",
                    "apiContentType",
                    "apiHeaders",
                    "hasBodyTemplate",
                    "bodyTemplate",
                    "fieldMapping",
                    "staticParams",
                    "successCriteria",
                    "timeoutMs",
                    "status",
                    "createdAt",
                    "updatedAt"
                  ],
                  "properties": {
                    "id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "teamId": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "name": {
                      "type": "string"
                    },
                    "apiEndpoint": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "apiMethod": {
                      "type": "string"
                    },
                    "apiAuthType": {
                      "type": "string"
                    },
                    "hasAuthValue": {
                      "type": "boolean"
                    },
                    "apiContentType": {
                      "type": "string"
                    },
                    "apiHeaders": {
                      "description": "Custom headers. Credential-bearing values are returned as a fixed write-only mask.",
                      "anyOf": [
                        {
                          "description": "JSON object with nested arrays and objects.",
                          "type": "object",
                          "additionalProperties": {
                            "$comment": "json-value",
                            "description": "Arbitrary JSON value with nested arrays and objects."
                          }
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "hasBodyTemplate": {
                      "type": "boolean"
                    },
                    "bodyTemplate": {
                      "description": "Fixed write-only mask when a body template is configured; null otherwise.",
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "fieldMapping": {
                      "anyOf": [
                        {
                          "description": "JSON object with nested arrays and objects.",
                          "type": "object",
                          "additionalProperties": {
                            "$comment": "json-value",
                            "description": "Arbitrary JSON value with nested arrays and objects."
                          }
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "staticParams": {
                      "description": "Static-parameter keys with every configured value replaced by a fixed write-only mask.",
                      "anyOf": [
                        {
                          "description": "JSON object with nested arrays and objects.",
                          "type": "object",
                          "additionalProperties": {
                            "$comment": "json-value",
                            "description": "Arbitrary JSON value with nested arrays and objects."
                          }
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "successCriteria": {
                      "anyOf": [
                        {
                          "description": "JSON object with nested arrays and objects.",
                          "type": "object",
                          "additionalProperties": {
                            "$comment": "json-value",
                            "description": "Arbitrary JSON value with nested arrays and objects."
                          }
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "timeoutMs": {
                      "type": "number"
                    },
                    "status": {
                      "anyOf": [
                        {
                          "type": "string",
                          "enum": [
                            "active"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "paused"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "archived"
                          ]
                        }
                      ]
                    },
                    "createdAt": {
                      "format": "date-time",
                      "type": "string"
                    },
                    "updatedAt": {
                      "anyOf": [
                        {
                          "format": "date-time",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "anyOf": [
                    {
                      "description": "Explicit destination workspace required: send the x-team-id header or activate a team scope for this operation.",
                      "additionalProperties": false,
                      "type": "object",
                      "required": [
                        "statusCode",
                        "error",
                        "message"
                      ],
                      "properties": {
                        "statusCode": {
                          "type": "number"
                        },
                        "error": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "code": {
                          "type": "string",
                          "enum": [
                            "SCOPE_TEAM_REQUIRED"
                          ]
                        }
                      }
                    },
                    {
                      "type": "object",
                      "required": [
                        "statusCode",
                        "error",
                        "message"
                      ],
                      "properties": {
                        "statusCode": {
                          "type": "number"
                        },
                        "error": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/tracker-cloaker/advertisers/{id}": {
      "get": {
        "operationId": "getApiV1TrackerCloakerAdvertisersById",
        "summary": "Get a Tracker & Cloaker advertiser",
        "tags": [
          "tracker-cloaker"
        ],
        "description": "Returns details for a specific advertiser. Authentication values and sensitive custom-header values are never returned.",
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "id",
                    "teamId",
                    "name",
                    "apiEndpoint",
                    "apiMethod",
                    "apiAuthType",
                    "hasAuthValue",
                    "apiContentType",
                    "apiHeaders",
                    "hasBodyTemplate",
                    "bodyTemplate",
                    "fieldMapping",
                    "staticParams",
                    "successCriteria",
                    "timeoutMs",
                    "status",
                    "createdAt",
                    "updatedAt"
                  ],
                  "properties": {
                    "id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "teamId": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "name": {
                      "type": "string"
                    },
                    "apiEndpoint": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "apiMethod": {
                      "type": "string"
                    },
                    "apiAuthType": {
                      "type": "string"
                    },
                    "hasAuthValue": {
                      "type": "boolean"
                    },
                    "apiContentType": {
                      "type": "string"
                    },
                    "apiHeaders": {
                      "description": "Custom headers. Credential-bearing values are returned as a fixed write-only mask.",
                      "anyOf": [
                        {
                          "description": "JSON object with nested arrays and objects.",
                          "type": "object",
                          "additionalProperties": {
                            "$comment": "json-value",
                            "description": "Arbitrary JSON value with nested arrays and objects."
                          }
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "hasBodyTemplate": {
                      "type": "boolean"
                    },
                    "bodyTemplate": {
                      "description": "Fixed write-only mask when a body template is configured; null otherwise.",
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "fieldMapping": {
                      "anyOf": [
                        {
                          "description": "JSON object with nested arrays and objects.",
                          "type": "object",
                          "additionalProperties": {
                            "$comment": "json-value",
                            "description": "Arbitrary JSON value with nested arrays and objects."
                          }
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "staticParams": {
                      "description": "Static-parameter keys with every configured value replaced by a fixed write-only mask.",
                      "anyOf": [
                        {
                          "description": "JSON object with nested arrays and objects.",
                          "type": "object",
                          "additionalProperties": {
                            "$comment": "json-value",
                            "description": "Arbitrary JSON value with nested arrays and objects."
                          }
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "successCriteria": {
                      "anyOf": [
                        {
                          "description": "JSON object with nested arrays and objects.",
                          "type": "object",
                          "additionalProperties": {
                            "$comment": "json-value",
                            "description": "Arbitrary JSON value with nested arrays and objects."
                          }
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "timeoutMs": {
                      "type": "number"
                    },
                    "status": {
                      "anyOf": [
                        {
                          "type": "string",
                          "enum": [
                            "active"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "paused"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "archived"
                          ]
                        }
                      ]
                    },
                    "createdAt": {
                      "format": "date-time",
                      "type": "string"
                    },
                    "updatedAt": {
                      "anyOf": [
                        {
                          "format": "date-time",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      },
      "put": {
        "operationId": "putApiV1TrackerCloakerAdvertisersById",
        "summary": "Update a Tracker & Cloaker advertiser",
        "tags": [
          "tracker-cloaker"
        ],
        "description": "Updates an existing advertiser. A write-only mask preserves an already-configured secret under a row lock; it cannot create a new secret.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "properties": {
                  "name": {
                    "minLength": 1,
                    "maxLength": 200,
                    "type": "string"
                  },
                  "api_endpoint": {
                    "anyOf": [
                      {
                        "maxLength": 2000,
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "api_method": {
                    "anyOf": [
                      {
                        "type": "string",
                        "enum": [
                          "GET"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "POST"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "PUT"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "PATCH"
                        ]
                      }
                    ]
                  },
                  "api_auth_type": {
                    "anyOf": [
                      {
                        "type": "string",
                        "enum": [
                          "none"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "bearer"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "basic"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "api_key"
                        ]
                      }
                    ]
                  },
                  "api_auth_value": {
                    "anyOf": [
                      {
                        "maxLength": 2000,
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "api_content_type": {
                    "anyOf": [
                      {
                        "type": "string",
                        "enum": [
                          "application/json"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "application/x-www-form-urlencoded"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "multipart/form-data"
                        ]
                      }
                    ]
                  },
                  "api_headers": {
                    "anyOf": [
                      {
                        "description": "JSON object with nested arrays and objects.",
                        "type": "object",
                        "additionalProperties": {
                          "$comment": "json-value",
                          "description": "Arbitrary JSON value with nested arrays and objects."
                        }
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "body_template": {
                    "anyOf": [
                      {
                        "maxLength": 20000,
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "field_mapping": {
                    "anyOf": [
                      {
                        "description": "JSON object with nested arrays and objects.",
                        "type": "object",
                        "additionalProperties": {
                          "$comment": "json-value",
                          "description": "Arbitrary JSON value with nested arrays and objects."
                        }
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "static_params": {
                    "anyOf": [
                      {
                        "description": "JSON object with nested arrays and objects.",
                        "type": "object",
                        "additionalProperties": {
                          "$comment": "json-value",
                          "description": "Arbitrary JSON value with nested arrays and objects."
                        }
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "success_criteria": {
                    "anyOf": [
                      {
                        "description": "JSON object with nested arrays and objects.",
                        "type": "object",
                        "additionalProperties": {
                          "$comment": "json-value",
                          "description": "Arbitrary JSON value with nested arrays and objects."
                        }
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "timeout_ms": {
                    "minimum": 500,
                    "maximum": 120000,
                    "type": "integer"
                  },
                  "status": {
                    "anyOf": [
                      {
                        "type": "string",
                        "enum": [
                          "active"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "paused"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "archived"
                        ]
                      }
                    ]
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          },
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "header",
            "name": "x-team-id",
            "required": false,
            "description": "Destination workspace team id."
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "id",
                    "teamId",
                    "name",
                    "apiEndpoint",
                    "apiMethod",
                    "apiAuthType",
                    "hasAuthValue",
                    "apiContentType",
                    "apiHeaders",
                    "hasBodyTemplate",
                    "bodyTemplate",
                    "fieldMapping",
                    "staticParams",
                    "successCriteria",
                    "timeoutMs",
                    "status",
                    "createdAt",
                    "updatedAt"
                  ],
                  "properties": {
                    "id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "teamId": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "name": {
                      "type": "string"
                    },
                    "apiEndpoint": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "apiMethod": {
                      "type": "string"
                    },
                    "apiAuthType": {
                      "type": "string"
                    },
                    "hasAuthValue": {
                      "type": "boolean"
                    },
                    "apiContentType": {
                      "type": "string"
                    },
                    "apiHeaders": {
                      "description": "Custom headers. Credential-bearing values are returned as a fixed write-only mask.",
                      "anyOf": [
                        {
                          "description": "JSON object with nested arrays and objects.",
                          "type": "object",
                          "additionalProperties": {
                            "$comment": "json-value",
                            "description": "Arbitrary JSON value with nested arrays and objects."
                          }
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "hasBodyTemplate": {
                      "type": "boolean"
                    },
                    "bodyTemplate": {
                      "description": "Fixed write-only mask when a body template is configured; null otherwise.",
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "fieldMapping": {
                      "anyOf": [
                        {
                          "description": "JSON object with nested arrays and objects.",
                          "type": "object",
                          "additionalProperties": {
                            "$comment": "json-value",
                            "description": "Arbitrary JSON value with nested arrays and objects."
                          }
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "staticParams": {
                      "description": "Static-parameter keys with every configured value replaced by a fixed write-only mask.",
                      "anyOf": [
                        {
                          "description": "JSON object with nested arrays and objects.",
                          "type": "object",
                          "additionalProperties": {
                            "$comment": "json-value",
                            "description": "Arbitrary JSON value with nested arrays and objects."
                          }
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "successCriteria": {
                      "anyOf": [
                        {
                          "description": "JSON object with nested arrays and objects.",
                          "type": "object",
                          "additionalProperties": {
                            "$comment": "json-value",
                            "description": "Arbitrary JSON value with nested arrays and objects."
                          }
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "timeoutMs": {
                      "type": "number"
                    },
                    "status": {
                      "anyOf": [
                        {
                          "type": "string",
                          "enum": [
                            "active"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "paused"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "archived"
                          ]
                        }
                      ]
                    },
                    "createdAt": {
                      "format": "date-time",
                      "type": "string"
                    },
                    "updatedAt": {
                      "anyOf": [
                        {
                          "format": "date-time",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "anyOf": [
                    {
                      "description": "Explicit destination workspace required: send the x-team-id header or activate a team scope for this operation.",
                      "additionalProperties": false,
                      "type": "object",
                      "required": [
                        "statusCode",
                        "error",
                        "message"
                      ],
                      "properties": {
                        "statusCode": {
                          "type": "number"
                        },
                        "error": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "code": {
                          "type": "string",
                          "enum": [
                            "SCOPE_TEAM_REQUIRED"
                          ]
                        }
                      }
                    },
                    {
                      "type": "object",
                      "required": [
                        "statusCode",
                        "error",
                        "message"
                      ],
                      "properties": {
                        "statusCode": {
                          "type": "number"
                        },
                        "error": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      },
      "delete": {
        "operationId": "deleteApiV1TrackerCloakerAdvertisersById",
        "summary": "Delete a Tracker & Cloaker advertiser",
        "tags": [
          "tracker-cloaker"
        ],
        "description": "Soft-deletes an advertiser by setting its status to archived.",
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          },
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "header",
            "name": "x-team-id",
            "required": false,
            "description": "Destination workspace team id."
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "deleted"
                  ],
                  "properties": {
                    "deleted": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Explicit destination workspace required: send the x-team-id header or activate a team scope for this operation.",
            "content": {
              "application/json": {
                "schema": {
                  "description": "Explicit destination workspace required: send the x-team-id header or activate a team scope for this operation.",
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "SCOPE_TEAM_REQUIRED"
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/tracker-cloaker/advertisers/{id}/test": {
      "post": {
        "operationId": "postApiV1TrackerCloakerAdvertisersByIdTest",
        "summary": "Test a Tracker & Cloaker advertiser API",
        "tags": [
          "tracker-cloaker"
        ],
        "description": "Fires a real request to the advertiser endpoint with a sample payload and evaluates success_criteria against the response.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "properties": {
                  "sample_data": {
                    "description": "JSON object with nested arrays and objects.",
                    "type": "object",
                    "additionalProperties": {
                      "$comment": "json-value",
                      "description": "Arbitrary JSON value with nested arrays and objects."
                    }
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          },
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "header",
            "name": "x-team-id",
            "required": false,
            "description": "Destination workspace team id."
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "ok",
                    "status",
                    "response",
                    "error"
                  ],
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    },
                    "status": {
                      "anyOf": [
                        {
                          "type": "number"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "response": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "error": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Explicit destination workspace required: send the x-team-id header or activate a team scope for this operation.",
            "content": {
              "application/json": {
                "schema": {
                  "description": "Explicit destination workspace required: send the x-team-id header or activate a team scope for this operation.",
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "SCOPE_TEAM_REQUIRED"
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/tracker-cloaker/blacklist": {
      "get": {
        "operationId": "getApiV1TrackerCloakerBlacklist",
        "summary": "List Tracker & Cloaker blacklist entries",
        "tags": [
          "tracker-cloaker"
        ],
        "description": "Returns all blacklist entries for the current team.",
        "parameters": [
          {
            "schema": {
              "maxLength": 40,
              "type": "string"
            },
            "in": "query",
            "name": "kind",
            "required": false
          },
          {
            "schema": {
              "minimum": 1,
              "maximum": 100,
              "type": "integer"
            },
            "in": "query",
            "name": "limit",
            "required": false
          },
          {
            "schema": {
              "minimum": 0,
              "type": "integer"
            },
            "in": "query",
            "name": "offset",
            "required": false
          },
          {
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "enum": [
                    "auto"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "manual"
                  ]
                }
              ]
            },
            "in": "query",
            "name": "source",
            "required": false
          },
          {
            "schema": {
              "type": "boolean"
            },
            "in": "query",
            "name": "includeExpired",
            "required": false
          },
          {
            "schema": {
              "maxLength": 200,
              "type": "string"
            },
            "in": "query",
            "name": "search",
            "required": false
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "items",
                    "total"
                  ],
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "id",
                          "teamId",
                          "value",
                          "kind",
                          "note",
                          "autoAdded",
                          "expiresAt",
                          "reason",
                          "country",
                          "isp",
                          "asn",
                          "createdAt"
                        ],
                        "properties": {
                          "id": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "teamId": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "value": {
                            "type": "string"
                          },
                          "kind": {
                            "type": "string"
                          },
                          "note": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "autoAdded": {
                            "type": "boolean"
                          },
                          "expiresAt": {
                            "anyOf": [
                              {
                                "format": "date-time",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "reason": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "country": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "isp": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "asn": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "createdAt": {
                            "format": "date-time",
                            "type": "string"
                          }
                        }
                      }
                    },
                    "total": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "postApiV1TrackerCloakerBlacklist",
        "summary": "Create a Tracker & Cloaker blacklist entry",
        "tags": [
          "tracker-cloaker"
        ],
        "description": "Creates a new blacklist entry for the current team.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "value"
                ],
                "properties": {
                  "value": {
                    "minLength": 1,
                    "maxLength": 500,
                    "type": "string"
                  },
                  "kind": {
                    "maxLength": 40,
                    "type": "string"
                  },
                  "note": {
                    "anyOf": [
                      {
                        "maxLength": 1000,
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "team_id": {
                    "format": "uuid",
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "header",
            "name": "x-team-id",
            "required": false,
            "description": "Destination workspace team id."
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "201": {
            "description": "Resource created",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "id",
                    "teamId",
                    "value",
                    "kind",
                    "note",
                    "autoAdded",
                    "expiresAt",
                    "reason",
                    "country",
                    "isp",
                    "asn",
                    "createdAt"
                  ],
                  "properties": {
                    "id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "teamId": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "value": {
                      "type": "string"
                    },
                    "kind": {
                      "type": "string"
                    },
                    "note": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "autoAdded": {
                      "type": "boolean"
                    },
                    "expiresAt": {
                      "anyOf": [
                        {
                          "format": "date-time",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "reason": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "country": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "isp": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "asn": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "createdAt": {
                      "format": "date-time",
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Explicit destination workspace required: send the x-team-id header or activate a team scope for this operation.",
            "content": {
              "application/json": {
                "schema": {
                  "description": "Explicit destination workspace required: send the x-team-id header or activate a team scope for this operation.",
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "SCOPE_TEAM_REQUIRED"
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/tracker-cloaker/blacklist/stats": {
      "get": {
        "operationId": "getApiV1TrackerCloakerBlacklistStats",
        "summary": "Tracker & Cloaker blacklist stat cards",
        "tags": [
          "tracker-cloaker"
        ],
        "description": "Total / auto / manual / active / expired counts for the current team.",
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "total",
                    "auto",
                    "manual",
                    "active",
                    "expired"
                  ],
                  "properties": {
                    "total": {
                      "type": "number"
                    },
                    "auto": {
                      "type": "number"
                    },
                    "manual": {
                      "type": "number"
                    },
                    "active": {
                      "type": "number"
                    },
                    "expired": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/tracker-cloaker/blacklist/bleed-impact": {
      "get": {
        "operationId": "getApiV1TrackerCloakerBlacklistBleedImpact",
        "summary": "Tracker & Cloaker blacklist bleed-impact",
        "tags": [
          "tracker-cloaker"
        ],
        "description": "How much recent blocked traffic is attributable to the DB blacklist over the last N days.",
        "parameters": [
          {
            "schema": {
              "minimum": 1,
              "maximum": 90,
              "type": "integer"
            },
            "in": "query",
            "name": "days",
            "required": false
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "days",
                    "blocked",
                    "dbAttributed",
                    "dbOnly",
                    "dbAttributedPct",
                    "dbOnlyPct"
                  ],
                  "properties": {
                    "days": {
                      "type": "number"
                    },
                    "blocked": {
                      "type": "number"
                    },
                    "dbAttributed": {
                      "type": "number"
                    },
                    "dbOnly": {
                      "type": "number"
                    },
                    "dbAttributedPct": {
                      "type": "number"
                    },
                    "dbOnlyPct": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/tracker-cloaker/blacklist/export": {
      "get": {
        "operationId": "getApiV1TrackerCloakerBlacklistExport",
        "summary": "Export Tracker & Cloaker blacklist as CSV",
        "tags": [
          "tracker-cloaker"
        ],
        "description": "Returns up to 50,000 active blacklist entries as a spreadsheet-safe CSV download; formula-like text cells are neutralized.",
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/tracker-cloaker/blacklist/bulk-delete": {
      "post": {
        "operationId": "postApiV1TrackerCloakerBlacklistBulkDelete",
        "summary": "Bulk-delete Tracker & Cloaker blacklist entries",
        "tags": [
          "tracker-cloaker"
        ],
        "description": "Permanently deletes the given blacklist entries (scoped to accessible teams).",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "ids"
                ],
                "properties": {
                  "ids": {
                    "minItems": 1,
                    "maxItems": 500,
                    "type": "array",
                    "items": {
                      "format": "uuid",
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "header",
            "name": "x-team-id",
            "required": false,
            "description": "Destination workspace team id."
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "deleted"
                  ],
                  "properties": {
                    "deleted": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Explicit destination workspace required: send the x-team-id header or activate a team scope for this operation.",
            "content": {
              "application/json": {
                "schema": {
                  "description": "Explicit destination workspace required: send the x-team-id header or activate a team scope for this operation.",
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "SCOPE_TEAM_REQUIRED"
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/tracker-cloaker/blacklist/{id}": {
      "delete": {
        "operationId": "deleteApiV1TrackerCloakerBlacklistById",
        "summary": "Delete a Tracker & Cloaker blacklist entry",
        "tags": [
          "tracker-cloaker"
        ],
        "description": "Permanently deletes a blacklist entry.",
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          },
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "header",
            "name": "x-team-id",
            "required": false,
            "description": "Destination workspace team id."
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "deleted"
                  ],
                  "properties": {
                    "deleted": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Explicit destination workspace required: send the x-team-id header or activate a team scope for this operation.",
            "content": {
              "application/json": {
                "schema": {
                  "description": "Explicit destination workspace required: send the x-team-id header or activate a team scope for this operation.",
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "SCOPE_TEAM_REQUIRED"
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/tracker-cloaker/campaigns": {
      "get": {
        "operationId": "getApiV1TrackerCloakerCampaigns",
        "summary": "List Tracker & Cloaker campaigns",
        "tags": [
          "tracker-cloaker"
        ],
        "description": "Returns all campaigns for the current team.",
        "parameters": [
          {
            "schema": {
              "maxLength": 50,
              "type": "string"
            },
            "in": "query",
            "name": "status",
            "required": false
          },
          {
            "schema": {
              "maxLength": 200,
              "type": "string"
            },
            "in": "query",
            "name": "search",
            "required": false
          },
          {
            "schema": {
              "minimum": 1,
              "maximum": 200,
              "type": "integer"
            },
            "in": "query",
            "name": "limit",
            "required": false
          },
          {
            "schema": {
              "minimum": 0,
              "type": "integer"
            },
            "in": "query",
            "name": "offset",
            "required": false
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "items",
                    "total"
                  ],
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "id",
                          "teamId",
                          "userId",
                          "name",
                          "domainId",
                          "alias",
                          "trafficSourceId",
                          "status",
                          "trafficFiltering",
                          "serveMode",
                          "filterConfig",
                          "timezone",
                          "currency",
                          "clickIdFormat",
                          "fbPixelId",
                          "fbCapiToken",
                          "fbCapiTokenSet",
                          "fbCapiEnabled",
                          "fbApiVersion",
                          "fbCapiEventLead",
                          "fbCapiEventPurchase",
                          "capiLeadStatuses",
                          "capiPurchaseStatuses",
                          "riskTier",
                          "whitePageId",
                          "category",
                          "tags",
                          "costModel",
                          "costValue",
                          "createdAt",
                          "updatedAt",
                          "archivedAt"
                        ],
                        "properties": {
                          "id": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "teamId": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "userId": {
                            "anyOf": [
                              {
                                "format": "uuid",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "name": {
                            "type": "string"
                          },
                          "domainId": {
                            "anyOf": [
                              {
                                "format": "uuid",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "alias": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "trafficSourceId": {
                            "anyOf": [
                              {
                                "format": "uuid",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "status": {
                            "type": "string"
                          },
                          "trafficFiltering": {
                            "type": "boolean"
                          },
                          "serveMode": {
                            "type": "string"
                          },
                          "filterConfig": {
                            "anyOf": [
                              {
                                "description": "JSON object with nested arrays and objects.",
                                "type": "object",
                                "additionalProperties": {
                                  "$comment": "json-value",
                                  "description": "Arbitrary JSON value with nested arrays and objects."
                                }
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "timezone": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "currency": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "clickIdFormat": {
                            "type": "string"
                          },
                          "fbPixelId": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "fbCapiToken": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "fbCapiTokenSet": {
                            "type": "boolean"
                          },
                          "fbCapiEnabled": {
                            "type": "boolean"
                          },
                          "fbApiVersion": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "fbCapiEventLead": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "fbCapiEventPurchase": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "capiLeadStatuses": {
                            "anyOf": [
                              {
                                "type": "array",
                                "items": {
                                  "type": "string"
                                }
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "capiPurchaseStatuses": {
                            "anyOf": [
                              {
                                "type": "array",
                                "items": {
                                  "type": "string"
                                }
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "riskTier": {
                            "type": "string"
                          },
                          "whitePageId": {
                            "anyOf": [
                              {
                                "format": "uuid",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "category": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "tags": {
                            "anyOf": [
                              {
                                "type": "array",
                                "items": {
                                  "type": "string"
                                }
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "costModel": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "costValue": {
                            "anyOf": [
                              {
                                "type": "number"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "createdAt": {
                            "format": "date-time",
                            "type": "string"
                          },
                          "updatedAt": {
                            "anyOf": [
                              {
                                "format": "date-time",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "archivedAt": {
                            "anyOf": [
                              {
                                "format": "date-time",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          }
                        }
                      }
                    },
                    "total": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "postApiV1TrackerCloakerCampaigns",
        "summary": "Create Tracker & Cloaker campaign",
        "tags": [
          "tracker-cloaker"
        ],
        "description": "Creates a new campaign for the current team.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "name"
                ],
                "properties": {
                  "name": {
                    "minLength": 1,
                    "maxLength": 200,
                    "type": "string"
                  },
                  "domain_id": {
                    "anyOf": [
                      {
                        "format": "uuid",
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "alias": {
                    "anyOf": [
                      {
                        "minLength": 1,
                        "maxLength": 128,
                        "pattern": "^[A-Za-z0-9][A-Za-z0-9_-]{0,127}$",
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "traffic_source_id": {
                    "anyOf": [
                      {
                        "format": "uuid",
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "status": {
                    "anyOf": [
                      {
                        "type": "string",
                        "enum": [
                          "active"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "paused"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "draft"
                        ]
                      }
                    ]
                  },
                  "traffic_filtering": {
                    "type": "boolean"
                  },
                  "serve_mode": {
                    "maxLength": 50,
                    "type": "string"
                  },
                  "filter_config": {
                    "anyOf": [
                      {
                        "description": "JSON object with nested arrays and objects.",
                        "type": "object",
                        "additionalProperties": {
                          "$comment": "json-value",
                          "description": "Arbitrary JSON value with nested arrays and objects."
                        }
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "timezone": {
                    "anyOf": [
                      {
                        "maxLength": 100,
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "currency": {
                    "anyOf": [
                      {
                        "maxLength": 10,
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "click_id_format": {
                    "maxLength": 50,
                    "type": "string"
                  },
                  "fb_pixel_id": {
                    "anyOf": [
                      {
                        "maxLength": 100,
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "fb_capi_token": {
                    "anyOf": [
                      {
                        "maxLength": 500,
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "fb_capi_enabled": {
                    "type": "boolean"
                  },
                  "fb_api_version": {
                    "anyOf": [
                      {
                        "maxLength": 20,
                        "pattern": "^v\\d{1,3}\\.\\d{1,2}$",
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "fb_capi_event_lead": {
                    "anyOf": [
                      {
                        "maxLength": 100,
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "fb_capi_event_purchase": {
                    "anyOf": [
                      {
                        "maxLength": 100,
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "capi_lead_statuses": {
                    "anyOf": [
                      {
                        "type": "array",
                        "items": {
                          "maxLength": 100,
                          "type": "string"
                        }
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "capi_purchase_statuses": {
                    "anyOf": [
                      {
                        "type": "array",
                        "items": {
                          "maxLength": 100,
                          "type": "string"
                        }
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "risk_tier": {
                    "maxLength": 50,
                    "type": "string"
                  },
                  "white_page_id": {
                    "anyOf": [
                      {
                        "format": "uuid",
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "category": {
                    "anyOf": [
                      {
                        "maxLength": 100,
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "tags": {
                    "anyOf": [
                      {
                        "type": "array",
                        "items": {
                          "maxLength": 100,
                          "type": "string"
                        }
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "cost_model": {
                    "anyOf": [
                      {
                        "maxLength": 50,
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "cost_value": {
                    "anyOf": [
                      {
                        "type": "number"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "header",
            "name": "x-team-id",
            "required": false,
            "description": "Destination workspace team id."
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "201": {
            "description": "Resource created",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "id",
                    "teamId",
                    "userId",
                    "name",
                    "domainId",
                    "alias",
                    "trafficSourceId",
                    "status",
                    "trafficFiltering",
                    "serveMode",
                    "filterConfig",
                    "timezone",
                    "currency",
                    "clickIdFormat",
                    "fbPixelId",
                    "fbCapiToken",
                    "fbCapiTokenSet",
                    "fbCapiEnabled",
                    "fbApiVersion",
                    "fbCapiEventLead",
                    "fbCapiEventPurchase",
                    "capiLeadStatuses",
                    "capiPurchaseStatuses",
                    "riskTier",
                    "whitePageId",
                    "category",
                    "tags",
                    "costModel",
                    "costValue",
                    "createdAt",
                    "updatedAt",
                    "archivedAt"
                  ],
                  "properties": {
                    "id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "teamId": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "userId": {
                      "anyOf": [
                        {
                          "format": "uuid",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "name": {
                      "type": "string"
                    },
                    "domainId": {
                      "anyOf": [
                        {
                          "format": "uuid",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "alias": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "trafficSourceId": {
                      "anyOf": [
                        {
                          "format": "uuid",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "status": {
                      "type": "string"
                    },
                    "trafficFiltering": {
                      "type": "boolean"
                    },
                    "serveMode": {
                      "type": "string"
                    },
                    "filterConfig": {
                      "anyOf": [
                        {
                          "description": "JSON object with nested arrays and objects.",
                          "type": "object",
                          "additionalProperties": {
                            "$comment": "json-value",
                            "description": "Arbitrary JSON value with nested arrays and objects."
                          }
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "timezone": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "currency": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "clickIdFormat": {
                      "type": "string"
                    },
                    "fbPixelId": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "fbCapiToken": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "fbCapiTokenSet": {
                      "type": "boolean"
                    },
                    "fbCapiEnabled": {
                      "type": "boolean"
                    },
                    "fbApiVersion": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "fbCapiEventLead": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "fbCapiEventPurchase": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "capiLeadStatuses": {
                      "anyOf": [
                        {
                          "type": "array",
                          "items": {
                            "type": "string"
                          }
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "capiPurchaseStatuses": {
                      "anyOf": [
                        {
                          "type": "array",
                          "items": {
                            "type": "string"
                          }
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "riskTier": {
                      "type": "string"
                    },
                    "whitePageId": {
                      "anyOf": [
                        {
                          "format": "uuid",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "category": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "tags": {
                      "anyOf": [
                        {
                          "type": "array",
                          "items": {
                            "type": "string"
                          }
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "costModel": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "costValue": {
                      "anyOf": [
                        {
                          "type": "number"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "createdAt": {
                      "format": "date-time",
                      "type": "string"
                    },
                    "updatedAt": {
                      "anyOf": [
                        {
                          "format": "date-time",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "archivedAt": {
                      "anyOf": [
                        {
                          "format": "date-time",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "anyOf": [
                    {
                      "description": "Explicit destination workspace required: send the x-team-id header or activate a team scope for this operation.",
                      "additionalProperties": false,
                      "type": "object",
                      "required": [
                        "statusCode",
                        "error",
                        "message"
                      ],
                      "properties": {
                        "statusCode": {
                          "type": "number"
                        },
                        "error": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "code": {
                          "type": "string",
                          "enum": [
                            "SCOPE_TEAM_REQUIRED"
                          ]
                        }
                      }
                    },
                    {
                      "type": "object",
                      "required": [
                        "statusCode",
                        "error",
                        "message"
                      ],
                      "properties": {
                        "statusCode": {
                          "type": "number"
                        },
                        "error": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/tracker-cloaker/campaigns/{id}": {
      "get": {
        "operationId": "getApiV1TrackerCloakerCampaignsById",
        "summary": "Get Tracker & Cloaker campaign",
        "tags": [
          "tracker-cloaker"
        ],
        "description": "Returns details for a specific campaign.",
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "id",
                    "teamId",
                    "userId",
                    "name",
                    "domainId",
                    "alias",
                    "trafficSourceId",
                    "status",
                    "trafficFiltering",
                    "serveMode",
                    "filterConfig",
                    "timezone",
                    "currency",
                    "clickIdFormat",
                    "fbPixelId",
                    "fbCapiToken",
                    "fbCapiTokenSet",
                    "fbCapiEnabled",
                    "fbApiVersion",
                    "fbCapiEventLead",
                    "fbCapiEventPurchase",
                    "capiLeadStatuses",
                    "capiPurchaseStatuses",
                    "riskTier",
                    "whitePageId",
                    "category",
                    "tags",
                    "costModel",
                    "costValue",
                    "createdAt",
                    "updatedAt",
                    "archivedAt"
                  ],
                  "properties": {
                    "id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "teamId": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "userId": {
                      "anyOf": [
                        {
                          "format": "uuid",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "name": {
                      "type": "string"
                    },
                    "domainId": {
                      "anyOf": [
                        {
                          "format": "uuid",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "alias": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "trafficSourceId": {
                      "anyOf": [
                        {
                          "format": "uuid",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "status": {
                      "type": "string"
                    },
                    "trafficFiltering": {
                      "type": "boolean"
                    },
                    "serveMode": {
                      "type": "string"
                    },
                    "filterConfig": {
                      "anyOf": [
                        {
                          "description": "JSON object with nested arrays and objects.",
                          "type": "object",
                          "additionalProperties": {
                            "$comment": "json-value",
                            "description": "Arbitrary JSON value with nested arrays and objects."
                          }
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "timezone": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "currency": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "clickIdFormat": {
                      "type": "string"
                    },
                    "fbPixelId": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "fbCapiToken": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "fbCapiTokenSet": {
                      "type": "boolean"
                    },
                    "fbCapiEnabled": {
                      "type": "boolean"
                    },
                    "fbApiVersion": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "fbCapiEventLead": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "fbCapiEventPurchase": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "capiLeadStatuses": {
                      "anyOf": [
                        {
                          "type": "array",
                          "items": {
                            "type": "string"
                          }
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "capiPurchaseStatuses": {
                      "anyOf": [
                        {
                          "type": "array",
                          "items": {
                            "type": "string"
                          }
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "riskTier": {
                      "type": "string"
                    },
                    "whitePageId": {
                      "anyOf": [
                        {
                          "format": "uuid",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "category": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "tags": {
                      "anyOf": [
                        {
                          "type": "array",
                          "items": {
                            "type": "string"
                          }
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "costModel": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "costValue": {
                      "anyOf": [
                        {
                          "type": "number"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "createdAt": {
                      "format": "date-time",
                      "type": "string"
                    },
                    "updatedAt": {
                      "anyOf": [
                        {
                          "format": "date-time",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "archivedAt": {
                      "anyOf": [
                        {
                          "format": "date-time",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      },
      "patch": {
        "operationId": "patchApiV1TrackerCloakerCampaignsById",
        "summary": "Update Tracker & Cloaker campaign",
        "tags": [
          "tracker-cloaker"
        ],
        "description": "Updates an existing campaign.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "properties": {
                  "name": {
                    "minLength": 1,
                    "maxLength": 200,
                    "type": "string"
                  },
                  "domain_id": {
                    "anyOf": [
                      {
                        "format": "uuid",
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "alias": {
                    "anyOf": [
                      {
                        "minLength": 1,
                        "maxLength": 128,
                        "pattern": "^[A-Za-z0-9][A-Za-z0-9_-]{0,127}$",
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "traffic_source_id": {
                    "anyOf": [
                      {
                        "format": "uuid",
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "status": {
                    "anyOf": [
                      {
                        "type": "string",
                        "enum": [
                          "active"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "paused"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "draft"
                        ]
                      }
                    ]
                  },
                  "traffic_filtering": {
                    "type": "boolean"
                  },
                  "serve_mode": {
                    "maxLength": 50,
                    "type": "string"
                  },
                  "filter_config": {
                    "anyOf": [
                      {
                        "description": "JSON object with nested arrays and objects.",
                        "type": "object",
                        "additionalProperties": {
                          "$comment": "json-value",
                          "description": "Arbitrary JSON value with nested arrays and objects."
                        }
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "timezone": {
                    "anyOf": [
                      {
                        "maxLength": 100,
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "currency": {
                    "anyOf": [
                      {
                        "maxLength": 10,
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "click_id_format": {
                    "maxLength": 50,
                    "type": "string"
                  },
                  "fb_pixel_id": {
                    "anyOf": [
                      {
                        "maxLength": 100,
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "fb_capi_token": {
                    "anyOf": [
                      {
                        "maxLength": 500,
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "fb_capi_enabled": {
                    "type": "boolean"
                  },
                  "fb_api_version": {
                    "anyOf": [
                      {
                        "maxLength": 20,
                        "pattern": "^v\\d{1,3}\\.\\d{1,2}$",
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "fb_capi_event_lead": {
                    "anyOf": [
                      {
                        "maxLength": 100,
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "fb_capi_event_purchase": {
                    "anyOf": [
                      {
                        "maxLength": 100,
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "capi_lead_statuses": {
                    "anyOf": [
                      {
                        "type": "array",
                        "items": {
                          "maxLength": 100,
                          "type": "string"
                        }
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "capi_purchase_statuses": {
                    "anyOf": [
                      {
                        "type": "array",
                        "items": {
                          "maxLength": 100,
                          "type": "string"
                        }
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "risk_tier": {
                    "maxLength": 50,
                    "type": "string"
                  },
                  "white_page_id": {
                    "anyOf": [
                      {
                        "format": "uuid",
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "category": {
                    "anyOf": [
                      {
                        "maxLength": 100,
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "tags": {
                    "anyOf": [
                      {
                        "type": "array",
                        "items": {
                          "maxLength": 100,
                          "type": "string"
                        }
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "cost_model": {
                    "anyOf": [
                      {
                        "maxLength": 50,
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "cost_value": {
                    "anyOf": [
                      {
                        "type": "number"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          },
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "header",
            "name": "x-team-id",
            "required": false,
            "description": "Destination workspace team id."
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "id",
                    "teamId",
                    "userId",
                    "name",
                    "domainId",
                    "alias",
                    "trafficSourceId",
                    "status",
                    "trafficFiltering",
                    "serveMode",
                    "filterConfig",
                    "timezone",
                    "currency",
                    "clickIdFormat",
                    "fbPixelId",
                    "fbCapiToken",
                    "fbCapiTokenSet",
                    "fbCapiEnabled",
                    "fbApiVersion",
                    "fbCapiEventLead",
                    "fbCapiEventPurchase",
                    "capiLeadStatuses",
                    "capiPurchaseStatuses",
                    "riskTier",
                    "whitePageId",
                    "category",
                    "tags",
                    "costModel",
                    "costValue",
                    "createdAt",
                    "updatedAt",
                    "archivedAt"
                  ],
                  "properties": {
                    "id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "teamId": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "userId": {
                      "anyOf": [
                        {
                          "format": "uuid",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "name": {
                      "type": "string"
                    },
                    "domainId": {
                      "anyOf": [
                        {
                          "format": "uuid",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "alias": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "trafficSourceId": {
                      "anyOf": [
                        {
                          "format": "uuid",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "status": {
                      "type": "string"
                    },
                    "trafficFiltering": {
                      "type": "boolean"
                    },
                    "serveMode": {
                      "type": "string"
                    },
                    "filterConfig": {
                      "anyOf": [
                        {
                          "description": "JSON object with nested arrays and objects.",
                          "type": "object",
                          "additionalProperties": {
                            "$comment": "json-value",
                            "description": "Arbitrary JSON value with nested arrays and objects."
                          }
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "timezone": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "currency": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "clickIdFormat": {
                      "type": "string"
                    },
                    "fbPixelId": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "fbCapiToken": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "fbCapiTokenSet": {
                      "type": "boolean"
                    },
                    "fbCapiEnabled": {
                      "type": "boolean"
                    },
                    "fbApiVersion": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "fbCapiEventLead": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "fbCapiEventPurchase": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "capiLeadStatuses": {
                      "anyOf": [
                        {
                          "type": "array",
                          "items": {
                            "type": "string"
                          }
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "capiPurchaseStatuses": {
                      "anyOf": [
                        {
                          "type": "array",
                          "items": {
                            "type": "string"
                          }
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "riskTier": {
                      "type": "string"
                    },
                    "whitePageId": {
                      "anyOf": [
                        {
                          "format": "uuid",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "category": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "tags": {
                      "anyOf": [
                        {
                          "type": "array",
                          "items": {
                            "type": "string"
                          }
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "costModel": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "costValue": {
                      "anyOf": [
                        {
                          "type": "number"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "createdAt": {
                      "format": "date-time",
                      "type": "string"
                    },
                    "updatedAt": {
                      "anyOf": [
                        {
                          "format": "date-time",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "archivedAt": {
                      "anyOf": [
                        {
                          "format": "date-time",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "anyOf": [
                    {
                      "description": "Explicit destination workspace required: send the x-team-id header or activate a team scope for this operation.",
                      "additionalProperties": false,
                      "type": "object",
                      "required": [
                        "statusCode",
                        "error",
                        "message"
                      ],
                      "properties": {
                        "statusCode": {
                          "type": "number"
                        },
                        "error": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "code": {
                          "type": "string",
                          "enum": [
                            "SCOPE_TEAM_REQUIRED"
                          ]
                        }
                      }
                    },
                    {
                      "type": "object",
                      "required": [
                        "statusCode",
                        "error",
                        "message"
                      ],
                      "properties": {
                        "statusCode": {
                          "type": "number"
                        },
                        "error": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      },
      "delete": {
        "operationId": "deleteApiV1TrackerCloakerCampaignsById",
        "summary": "Archive Tracker & Cloaker campaign",
        "tags": [
          "tracker-cloaker"
        ],
        "description": "Soft-deletes (archives) a campaign by setting status and archived_at.",
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          },
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "header",
            "name": "x-team-id",
            "required": false,
            "description": "Destination workspace team id."
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "archived"
                  ],
                  "properties": {
                    "archived": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Explicit destination workspace required: send the x-team-id header or activate a team scope for this operation.",
            "content": {
              "application/json": {
                "schema": {
                  "description": "Explicit destination workspace required: send the x-team-id header or activate a team scope for this operation.",
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "SCOPE_TEAM_REQUIRED"
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/tracker-cloaker/campaigns/{id}/capi-test": {
      "post": {
        "operationId": "postApiV1TrackerCloakerCampaignsByIdCapiTest",
        "summary": "Test Tracker & Cloaker campaign CAPI",
        "tags": [
          "tracker-cloaker"
        ],
        "description": "Fires a sample Conversions API event using the campaign's pixel and token. Returns the send result. When CAPI is not configured (pixel/token missing) responds 200 with { ok:false, skipped:true } — not an error.",
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          },
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "header",
            "name": "x-team-id",
            "required": false,
            "description": "Destination workspace team id."
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "ok"
                  ],
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    },
                    "skipped": {
                      "type": "boolean"
                    },
                    "reason": {
                      "type": "string"
                    },
                    "status": {
                      "anyOf": [
                        {
                          "type": "number"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "response": {
                      "$comment": "json-value",
                      "description": "Arbitrary JSON value with nested arrays and objects."
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Explicit destination workspace required: send the x-team-id header or activate a team scope for this operation.",
            "content": {
              "application/json": {
                "schema": {
                  "description": "Explicit destination workspace required: send the x-team-id header or activate a team scope for this operation.",
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "SCOPE_TEAM_REQUIRED"
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/tracker-cloaker/campaigns/{id}/flows": {
      "get": {
        "operationId": "getApiV1TrackerCloakerCampaignsByIdFlows",
        "summary": "List Tracker & Cloaker campaign flows",
        "tags": [
          "tracker-cloaker"
        ],
        "description": "Returns the campaign flow rows ordered by sort order, each with its nested conditions, landings, offers, and black pages.",
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "flows"
                  ],
                  "properties": {
                    "flows": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "id",
                          "teamId",
                          "campaignId",
                          "name",
                          "order",
                          "type",
                          "conditionLogic",
                          "isDefault",
                          "blackPageId",
                          "createdAt",
                          "conditions",
                          "landings",
                          "offers",
                          "black_pages"
                        ],
                        "properties": {
                          "id": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "teamId": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "campaignId": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "name": {
                            "type": "string"
                          },
                          "order": {
                            "type": "integer"
                          },
                          "type": {
                            "type": "string"
                          },
                          "conditionLogic": {
                            "type": "string"
                          },
                          "isDefault": {
                            "type": "boolean"
                          },
                          "blackPageId": {
                            "anyOf": [
                              {
                                "format": "uuid",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "createdAt": {
                            "format": "date-time",
                            "type": "string"
                          },
                          "conditions": {
                            "type": "array",
                            "items": {
                              "type": "object",
                              "required": [
                                "id",
                                "teamId",
                                "flowId",
                                "groupIndex",
                                "type",
                                "operator",
                                "value",
                                "createdAt"
                              ],
                              "properties": {
                                "id": {
                                  "format": "uuid",
                                  "type": "string"
                                },
                                "teamId": {
                                  "format": "uuid",
                                  "type": "string"
                                },
                                "flowId": {
                                  "format": "uuid",
                                  "type": "string"
                                },
                                "groupIndex": {
                                  "type": "integer"
                                },
                                "type": {
                                  "type": "string"
                                },
                                "operator": {
                                  "type": "string"
                                },
                                "value": {
                                  "type": "string"
                                },
                                "createdAt": {
                                  "format": "date-time",
                                  "type": "string"
                                }
                              }
                            }
                          },
                          "landings": {
                            "type": "array",
                            "items": {
                              "type": "object",
                              "required": [
                                "id",
                                "teamId",
                                "flowId",
                                "pageId",
                                "weight",
                                "isEnabled"
                              ],
                              "properties": {
                                "id": {
                                  "format": "uuid",
                                  "type": "string"
                                },
                                "teamId": {
                                  "format": "uuid",
                                  "type": "string"
                                },
                                "flowId": {
                                  "format": "uuid",
                                  "type": "string"
                                },
                                "pageId": {
                                  "format": "uuid",
                                  "type": "string"
                                },
                                "weight": {
                                  "type": "integer"
                                },
                                "isEnabled": {
                                  "type": "boolean"
                                }
                              }
                            }
                          },
                          "offers": {
                            "type": "array",
                            "items": {
                              "type": "object",
                              "required": [
                                "id",
                                "teamId",
                                "flowId",
                                "offerId",
                                "weight",
                                "isEnabled"
                              ],
                              "properties": {
                                "id": {
                                  "format": "uuid",
                                  "type": "string"
                                },
                                "teamId": {
                                  "format": "uuid",
                                  "type": "string"
                                },
                                "flowId": {
                                  "format": "uuid",
                                  "type": "string"
                                },
                                "offerId": {
                                  "format": "uuid",
                                  "type": "string"
                                },
                                "weight": {
                                  "type": "integer"
                                },
                                "isEnabled": {
                                  "type": "boolean"
                                }
                              }
                            }
                          },
                          "black_pages": {
                            "type": "array",
                            "items": {
                              "type": "object",
                              "required": [
                                "id",
                                "teamId",
                                "flowId",
                                "pageId",
                                "weight",
                                "isEnabled",
                                "orderIdx"
                              ],
                              "properties": {
                                "id": {
                                  "format": "uuid",
                                  "type": "string"
                                },
                                "teamId": {
                                  "format": "uuid",
                                  "type": "string"
                                },
                                "flowId": {
                                  "format": "uuid",
                                  "type": "string"
                                },
                                "pageId": {
                                  "format": "uuid",
                                  "type": "string"
                                },
                                "weight": {
                                  "type": "integer"
                                },
                                "isEnabled": {
                                  "type": "boolean"
                                },
                                "orderIdx": {
                                  "type": "integer"
                                }
                              }
                            }
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      },
      "put": {
        "operationId": "putApiV1TrackerCloakerCampaignsByIdFlows",
        "summary": "Sync Tracker & Cloaker campaign flows",
        "tags": [
          "tracker-cloaker"
        ],
        "description": "Atomically replaces the campaign flow graph: deletes existing flows and their nested conditions, landings, offers, and black pages, then recreates them from the request body.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "flows"
                ],
                "properties": {
                  "flows": {
                    "minItems": 1,
                    "type": "array",
                    "items": {
                      "additionalProperties": false,
                      "type": "object",
                      "required": [
                        "name",
                        "order"
                      ],
                      "properties": {
                        "name": {
                          "minLength": 1,
                          "maxLength": 200,
                          "type": "string"
                        },
                        "order": {
                          "minimum": 0,
                          "type": "integer"
                        },
                        "type": {
                          "type": "string",
                          "enum": [
                            "landing"
                          ]
                        },
                        "condition_logic": {
                          "anyOf": [
                            {
                              "type": "string",
                              "enum": [
                                "AND"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "OR"
                              ]
                            }
                          ]
                        },
                        "is_default": {
                          "type": "boolean"
                        },
                        "black_page_id": {
                          "anyOf": [
                            {
                              "format": "uuid",
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "conditions": {
                          "type": "array",
                          "items": {
                            "additionalProperties": false,
                            "type": "object",
                            "required": [
                              "type",
                              "operator",
                              "value"
                            ],
                            "properties": {
                              "group_index": {
                                "minimum": 0,
                                "type": "integer"
                              },
                              "type": {
                                "anyOf": [
                                  {
                                    "type": "string",
                                    "enum": [
                                      "bot_verdict"
                                    ]
                                  },
                                  {
                                    "type": "string",
                                    "enum": [
                                      "browser"
                                    ]
                                  },
                                  {
                                    "type": "string",
                                    "enum": [
                                      "connection_type"
                                    ]
                                  },
                                  {
                                    "type": "string",
                                    "enum": [
                                      "country"
                                    ]
                                  },
                                  {
                                    "type": "string",
                                    "enum": [
                                      "day_of_week"
                                    ]
                                  },
                                  {
                                    "type": "string",
                                    "enum": [
                                      "device_type"
                                    ]
                                  },
                                  {
                                    "type": "string",
                                    "enum": [
                                      "hour_of_day"
                                    ]
                                  },
                                  {
                                    "type": "string",
                                    "enum": [
                                      "isp"
                                    ]
                                  },
                                  {
                                    "type": "string",
                                    "enum": [
                                      "language"
                                    ]
                                  },
                                  {
                                    "type": "string",
                                    "enum": [
                                      "os"
                                    ]
                                  },
                                  {
                                    "type": "string",
                                    "enum": [
                                      "referrer"
                                    ]
                                  },
                                  {
                                    "type": "string",
                                    "enum": [
                                      "return_visits"
                                    ]
                                  }
                                ]
                              },
                              "operator": {
                                "anyOf": [
                                  {
                                    "type": "string",
                                    "enum": [
                                      "is"
                                    ]
                                  },
                                  {
                                    "type": "string",
                                    "enum": [
                                      "is_not"
                                    ]
                                  },
                                  {
                                    "type": "string",
                                    "enum": [
                                      "contains"
                                    ]
                                  },
                                  {
                                    "type": "string",
                                    "enum": [
                                      "in"
                                    ]
                                  },
                                  {
                                    "type": "string",
                                    "enum": [
                                      "not_in"
                                    ]
                                  },
                                  {
                                    "type": "string",
                                    "enum": [
                                      "gte"
                                    ]
                                  },
                                  {
                                    "type": "string",
                                    "enum": [
                                      "lte"
                                    ]
                                  }
                                ]
                              },
                              "value": {
                                "minLength": 1,
                                "maxLength": 2000,
                                "type": "string"
                              }
                            }
                          }
                        },
                        "landings": {
                          "type": "array",
                          "items": {
                            "additionalProperties": false,
                            "type": "object",
                            "required": [
                              "page_id"
                            ],
                            "properties": {
                              "page_id": {
                                "format": "uuid",
                                "type": "string"
                              },
                              "weight": {
                                "minimum": 1,
                                "type": "integer"
                              },
                              "is_enabled": {
                                "type": "boolean"
                              }
                            }
                          }
                        },
                        "offers": {
                          "type": "array",
                          "items": {
                            "additionalProperties": false,
                            "type": "object",
                            "required": [
                              "offer_id"
                            ],
                            "properties": {
                              "offer_id": {
                                "format": "uuid",
                                "type": "string"
                              },
                              "weight": {
                                "minimum": 1,
                                "type": "integer"
                              },
                              "is_enabled": {
                                "type": "boolean"
                              }
                            }
                          }
                        },
                        "black_pages": {
                          "type": "array",
                          "items": {
                            "additionalProperties": false,
                            "type": "object",
                            "required": [
                              "page_id"
                            ],
                            "properties": {
                              "page_id": {
                                "format": "uuid",
                                "type": "string"
                              },
                              "weight": {
                                "minimum": 1,
                                "type": "integer"
                              },
                              "is_enabled": {
                                "type": "boolean"
                              },
                              "order_idx": {
                                "minimum": 0,
                                "type": "integer"
                              }
                            }
                          }
                        }
                      }
                    }
                  },
                  "white_page_id": {
                    "anyOf": [
                      {
                        "format": "uuid",
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          },
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "header",
            "name": "x-team-id",
            "required": false,
            "description": "Destination workspace team id."
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "flows"
                  ],
                  "properties": {
                    "flows": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "id",
                          "teamId",
                          "campaignId",
                          "name",
                          "order",
                          "type",
                          "conditionLogic",
                          "isDefault",
                          "blackPageId",
                          "createdAt"
                        ],
                        "properties": {
                          "id": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "teamId": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "campaignId": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "name": {
                            "type": "string"
                          },
                          "order": {
                            "type": "integer"
                          },
                          "type": {
                            "type": "string"
                          },
                          "conditionLogic": {
                            "type": "string"
                          },
                          "isDefault": {
                            "type": "boolean"
                          },
                          "blackPageId": {
                            "anyOf": [
                              {
                                "format": "uuid",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "createdAt": {
                            "format": "date-time",
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "anyOf": [
                    {
                      "description": "Explicit destination workspace required: send the x-team-id header or activate a team scope for this operation.",
                      "additionalProperties": false,
                      "type": "object",
                      "required": [
                        "statusCode",
                        "error",
                        "message"
                      ],
                      "properties": {
                        "statusCode": {
                          "type": "number"
                        },
                        "error": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "code": {
                          "type": "string",
                          "enum": [
                            "SCOPE_TEAM_REQUIRED"
                          ]
                        }
                      }
                    },
                    {
                      "type": "object",
                      "required": [
                        "statusCode",
                        "error",
                        "message"
                      ],
                      "properties": {
                        "statusCode": {
                          "type": "number"
                        },
                        "error": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/tracker-cloaker/campaigns/{id}/inspect": {
      "post": {
        "operationId": "postApiV1TrackerCloakerCampaignsByIdInspect",
        "summary": "Inspect Tracker & Cloaker decision",
        "tags": [
          "tracker-cloaker"
        ],
        "description": "Replays the live click pipeline (scoring + flow engine + serve decision) for a synthetic visitor and returns a structured decision trace. Read-only — no click row is written.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "ua"
                ],
                "properties": {
                  "ip": {
                    "maxLength": 64,
                    "type": "string"
                  },
                  "ua": {
                    "maxLength": 2000,
                    "type": "string"
                  },
                  "country": {
                    "maxLength": 2,
                    "pattern": "^[A-Za-z]{2}$",
                    "type": "string"
                  },
                  "referrer": {
                    "maxLength": 2000,
                    "type": "string"
                  },
                  "returnVisitor": {
                    "type": "boolean"
                  },
                  "isp": {
                    "maxLength": 200,
                    "type": "string"
                  },
                  "isVpn": {
                    "type": "boolean"
                  },
                  "isProxy": {
                    "type": "boolean"
                  },
                  "language": {
                    "maxLength": 50,
                    "type": "string"
                  },
                  "priorVerdict": {
                    "anyOf": [
                      {
                        "type": "string",
                        "enum": [
                          "HUMAN"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "SUSPECT"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "BOT"
                        ]
                      }
                    ]
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          },
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "header",
            "name": "x-team-id",
            "required": false,
            "description": "Destination workspace team id."
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "verdict",
                    "score",
                    "reasons",
                    "enrichment",
                    "steps",
                    "matchedFlow",
                    "conditionsEvaluated",
                    "chosenLanding",
                    "chosenOffer",
                    "servedPage"
                  ],
                  "properties": {
                    "verdict": {
                      "type": "string"
                    },
                    "score": {
                      "type": "number"
                    },
                    "reasons": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "enrichment": {
                      "type": "object",
                      "required": [
                        "country",
                        "isp",
                        "asn",
                        "isDatacenter",
                        "isProxy",
                        "isResidentialProxy",
                        "isTor",
                        "isVpn",
                        "isHosting"
                      ],
                      "properties": {
                        "country": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "isp": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "asn": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "isDatacenter": {
                          "type": "boolean"
                        },
                        "isProxy": {
                          "type": "boolean"
                        },
                        "isResidentialProxy": {
                          "type": "boolean"
                        },
                        "isTor": {
                          "type": "boolean"
                        },
                        "isVpn": {
                          "type": "boolean"
                        },
                        "isHosting": {
                          "type": "boolean"
                        }
                      }
                    },
                    "steps": {
                      "type": "array",
                      "items": {
                        "additionalProperties": false,
                        "type": "object",
                        "required": [
                          "code",
                          "params",
                          "label",
                          "detail"
                        ],
                        "properties": {
                          "code": {
                            "anyOf": [
                              {
                                "type": "string",
                                "enum": [
                                  "ip_enrichment"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "enrichment_override"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "filter_membership"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "sync_scoring"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "campaign_filters"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "visitor_context"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "flow_evaluation"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "serve_decision"
                                ]
                              }
                            ]
                          },
                          "params": {
                            "type": "object",
                            "additionalProperties": {
                              "$comment": "json-value"
                            }
                          },
                          "label": {
                            "type": "string"
                          },
                          "detail": {
                            "type": "string"
                          }
                        }
                      }
                    },
                    "matchedFlow": {
                      "anyOf": [
                        {
                          "type": "object",
                          "required": [
                            "id",
                            "name",
                            "isDefault"
                          ],
                          "properties": {
                            "id": {
                              "type": "string"
                            },
                            "name": {
                              "type": "string"
                            },
                            "isDefault": {
                              "type": "boolean"
                            }
                          }
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "conditionsEvaluated": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "flowId",
                          "flowName",
                          "groupIndex",
                          "type",
                          "operator",
                          "value",
                          "matched"
                        ],
                        "properties": {
                          "flowId": {
                            "type": "string"
                          },
                          "flowName": {
                            "type": "string"
                          },
                          "groupIndex": {
                            "type": "integer"
                          },
                          "type": {
                            "type": "string"
                          },
                          "operator": {
                            "type": "string"
                          },
                          "value": {
                            "type": "string"
                          },
                          "matched": {
                            "type": "boolean"
                          }
                        }
                      }
                    },
                    "chosenLanding": {
                      "anyOf": [
                        {
                          "type": "object",
                          "required": [
                            "id",
                            "name",
                            "type"
                          ],
                          "properties": {
                            "id": {
                              "type": "string"
                            },
                            "name": {
                              "type": "string"
                            },
                            "type": {
                              "type": "string"
                            }
                          }
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "chosenOffer": {
                      "anyOf": [
                        {
                          "type": "object",
                          "required": [
                            "id",
                            "name",
                            "url",
                            "type"
                          ],
                          "properties": {
                            "id": {
                              "type": "string"
                            },
                            "name": {
                              "type": "string"
                            },
                            "url": {
                              "anyOf": [
                                {
                                  "type": "string"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "type": {
                              "type": "string"
                            }
                          }
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "servedPage": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/tracker-cloaker/capi-log": {
      "get": {
        "operationId": "getApiV1TrackerCloakerCapiLog",
        "summary": "List Tracker & Cloaker CAPI events (Facebook CAPI Log)",
        "tags": [
          "tracker-cloaker"
        ],
        "description": "Returns a paginated, team-scoped list of Conversions API dispatch attempts (tc_capi_event). All filters are optional; an empty query returns the most recent CAPI events across the team.",
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "query",
            "name": "campaign_id",
            "required": false
          },
          {
            "schema": {
              "maxLength": 40,
              "type": "string"
            },
            "in": "query",
            "name": "status",
            "required": false
          },
          {
            "schema": {
              "maxLength": 80,
              "type": "string"
            },
            "in": "query",
            "name": "event_name",
            "required": false
          },
          {
            "schema": {
              "maxLength": 100,
              "type": "string"
            },
            "in": "query",
            "name": "cid",
            "required": false
          },
          {
            "schema": {
              "maxLength": 40,
              "type": "string"
            },
            "in": "query",
            "name": "dateFrom",
            "required": false
          },
          {
            "schema": {
              "maxLength": 40,
              "type": "string"
            },
            "in": "query",
            "name": "dateTo",
            "required": false
          },
          {
            "schema": {
              "minimum": 1,
              "maximum": 200,
              "type": "integer"
            },
            "in": "query",
            "name": "limit",
            "required": false
          },
          {
            "schema": {
              "minimum": 0,
              "type": "integer"
            },
            "in": "query",
            "name": "offset",
            "required": false
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "items",
                    "total"
                  ],
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "id",
                          "teamId",
                          "clickId",
                          "conversionId",
                          "campaignId",
                          "campaignName",
                          "pixelId",
                          "eventName",
                          "status",
                          "request",
                          "response",
                          "error",
                          "createdAt"
                        ],
                        "properties": {
                          "id": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "teamId": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "clickId": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "conversionId": {
                            "anyOf": [
                              {
                                "format": "uuid",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "campaignId": {
                            "anyOf": [
                              {
                                "format": "uuid",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "campaignName": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "pixelId": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "eventName": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "status": {
                            "type": "string"
                          },
                          "request": {
                            "$comment": "json-value",
                            "description": "Arbitrary JSON value with nested arrays and objects."
                          },
                          "response": {
                            "$comment": "json-value",
                            "description": "Arbitrary JSON value with nested arrays and objects."
                          },
                          "error": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "createdAt": {
                            "format": "date-time",
                            "type": "string"
                          }
                        }
                      }
                    },
                    "total": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/tracker-cloaker/clicks": {
      "get": {
        "operationId": "getApiV1TrackerCloakerClicks",
        "summary": "List Tracker & Cloaker clicks (Traffic Log)",
        "tags": [
          "tracker-cloaker"
        ],
        "description": "Returns a paginated, team-scoped list of click rows. All filters are optional: campaign_id, verdict, country, device_type, dateFrom, dateTo, limit (default 50), offset.",
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "query",
            "name": "campaign_id",
            "required": false
          },
          {
            "schema": {
              "maxLength": 40,
              "type": "string"
            },
            "in": "query",
            "name": "verdict",
            "required": false
          },
          {
            "schema": {
              "maxLength": 10,
              "type": "string"
            },
            "in": "query",
            "name": "country",
            "required": false
          },
          {
            "schema": {
              "maxLength": 40,
              "type": "string"
            },
            "in": "query",
            "name": "device_type",
            "required": false
          },
          {
            "schema": {
              "maxLength": 40,
              "type": "string"
            },
            "in": "query",
            "name": "device",
            "required": false
          },
          {
            "schema": {
              "maxLength": 100,
              "type": "string"
            },
            "in": "query",
            "name": "reason",
            "required": false
          },
          {
            "schema": {
              "maxLength": 255,
              "type": "string"
            },
            "in": "query",
            "name": "sub_id",
            "required": false
          },
          {
            "schema": {
              "maxLength": 100,
              "type": "string"
            },
            "in": "query",
            "name": "cid",
            "required": false
          },
          {
            "schema": {
              "maxLength": 60,
              "type": "string"
            },
            "in": "query",
            "name": "ip",
            "required": false
          },
          {
            "schema": {
              "maxLength": 120,
              "type": "string"
            },
            "in": "query",
            "name": "isp",
            "required": false
          },
          {
            "schema": {
              "maxLength": 40,
              "type": "string"
            },
            "in": "query",
            "name": "dateFrom",
            "required": false
          },
          {
            "schema": {
              "maxLength": 40,
              "type": "string"
            },
            "in": "query",
            "name": "dateTo",
            "required": false
          },
          {
            "schema": {
              "minimum": 1,
              "maximum": 200,
              "type": "integer"
            },
            "in": "query",
            "name": "limit",
            "required": false
          },
          {
            "schema": {
              "minimum": 0,
              "type": "integer"
            },
            "in": "query",
            "name": "offset",
            "required": false
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "items",
                    "total"
                  ],
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "id",
                          "campaignId",
                          "flowId",
                          "landingId",
                          "offerId",
                          "ipMasked",
                          "country",
                          "isp",
                          "asn",
                          "ua",
                          "verdict",
                          "score",
                          "reasons",
                          "deviceType",
                          "os",
                          "browser",
                          "referrer",
                          "isUnique",
                          "subId1",
                          "subId2",
                          "subId3",
                          "subId4",
                          "subId5",
                          "subId6",
                          "subId7",
                          "subId8",
                          "subId9",
                          "subId10",
                          "createdAt"
                        ],
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "campaignId": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "flowId": {
                            "anyOf": [
                              {
                                "format": "uuid",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "landingId": {
                            "anyOf": [
                              {
                                "format": "uuid",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "offerId": {
                            "anyOf": [
                              {
                                "format": "uuid",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "ipMasked": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "country": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "isp": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "asn": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "ua": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "verdict": {
                            "type": "string"
                          },
                          "score": {
                            "type": "number"
                          },
                          "reasons": {
                            "anyOf": [
                              {
                                "type": "array",
                                "items": {
                                  "type": "string"
                                }
                              },
                              {
                                "description": "JSON object with nested arrays and objects.",
                                "type": "object",
                                "additionalProperties": {
                                  "$comment": "json-value",
                                  "description": "Arbitrary JSON value with nested arrays and objects."
                                }
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "deviceType": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "os": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "browser": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "referrer": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "isUnique": {
                            "type": "boolean"
                          },
                          "subId1": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "subId2": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "subId3": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "subId4": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "subId5": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "subId6": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "subId7": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "subId8": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "subId9": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "subId10": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "createdAt": {
                            "format": "date-time",
                            "type": "string"
                          }
                        }
                      }
                    },
                    "total": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/tracker-cloaker/clicks/export": {
      "get": {
        "operationId": "getApiV1TrackerCloakerClicksExport",
        "summary": "Export Tracker & Cloaker clicks (Traffic Log) as CSV",
        "tags": [
          "tracker-cloaker"
        ],
        "description": "Returns matching click rows as a CSV download. Accepts the same filters as /clicks (campaign_id, verdict, country, device_type, dateFrom, dateTo). Capped at 50k rows.",
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "query",
            "name": "campaign_id",
            "required": false
          },
          {
            "schema": {
              "maxLength": 40,
              "type": "string"
            },
            "in": "query",
            "name": "verdict",
            "required": false
          },
          {
            "schema": {
              "maxLength": 10,
              "type": "string"
            },
            "in": "query",
            "name": "country",
            "required": false
          },
          {
            "schema": {
              "maxLength": 40,
              "type": "string"
            },
            "in": "query",
            "name": "device_type",
            "required": false
          },
          {
            "schema": {
              "maxLength": 40,
              "type": "string"
            },
            "in": "query",
            "name": "dateFrom",
            "required": false
          },
          {
            "schema": {
              "maxLength": 40,
              "type": "string"
            },
            "in": "query",
            "name": "dateTo",
            "required": false
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/tracker-cloaker/clicks/{id}": {
      "get": {
        "operationId": "getApiV1TrackerCloakerClicksById",
        "summary": "Get one Tracker & Cloaker click (Find by Click ID)",
        "tags": [
          "tracker-cloaker"
        ],
        "description": "Returns the full detail of a single click (all columns) plus its related conversions and CAPI events (matched by click_id), team-scoped. 404 if the click is not found in an accessible team.",
        "parameters": [
          {
            "schema": {
              "minLength": 1,
              "maxLength": 100,
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "click",
                    "conversions",
                    "capiEvents"
                  ],
                  "properties": {
                    "click": {
                      "type": "object",
                      "required": [
                        "id",
                        "teamId",
                        "campaignId",
                        "flowId",
                        "landingId",
                        "offerId",
                        "ip",
                        "ipMasked",
                        "ua",
                        "country",
                        "isp",
                        "asn",
                        "verdict",
                        "score",
                        "reasons",
                        "params",
                        "referrer",
                        "deviceType",
                        "os",
                        "browser",
                        "fbclid",
                        "fbp",
                        "subId1",
                        "subId2",
                        "subId3",
                        "subId4",
                        "subId5",
                        "subId6",
                        "subId7",
                        "subId8",
                        "subId9",
                        "subId10",
                        "currency",
                        "cost",
                        "isUnique",
                        "createdAt"
                      ],
                      "properties": {
                        "id": {
                          "type": "string"
                        },
                        "teamId": {
                          "format": "uuid",
                          "type": "string"
                        },
                        "campaignId": {
                          "format": "uuid",
                          "type": "string"
                        },
                        "flowId": {
                          "anyOf": [
                            {
                              "format": "uuid",
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "landingId": {
                          "anyOf": [
                            {
                              "format": "uuid",
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "offerId": {
                          "anyOf": [
                            {
                              "format": "uuid",
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "ip": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "ipMasked": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "ua": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "country": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "isp": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "asn": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "verdict": {
                          "type": "string"
                        },
                        "score": {
                          "type": "number"
                        },
                        "reasons": {
                          "anyOf": [
                            {
                              "type": "array",
                              "items": {
                                "type": "string"
                              }
                            },
                            {
                              "description": "JSON object with nested arrays and objects.",
                              "type": "object",
                              "additionalProperties": {
                                "$comment": "json-value",
                                "description": "Arbitrary JSON value with nested arrays and objects."
                              }
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "params": {
                          "$comment": "json-value",
                          "description": "Arbitrary JSON value with nested arrays and objects."
                        },
                        "referrer": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "deviceType": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "os": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "browser": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "fbclid": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "fbp": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "subId1": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "subId2": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "subId3": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "subId4": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "subId5": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "subId6": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "subId7": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "subId8": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "subId9": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "subId10": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "currency": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "cost": {
                          "anyOf": [
                            {
                              "type": "number"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "isUnique": {
                          "type": "boolean"
                        },
                        "createdAt": {
                          "format": "date-time",
                          "type": "string"
                        }
                      }
                    },
                    "conversions": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "id",
                          "teamId",
                          "clickId",
                          "status",
                          "payout",
                          "currency",
                          "orderId",
                          "source",
                          "capiSent",
                          "postbackForwarded",
                          "createdAt"
                        ],
                        "properties": {
                          "id": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "teamId": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "clickId": {
                            "type": "string"
                          },
                          "status": {
                            "type": "string"
                          },
                          "payout": {
                            "anyOf": [
                              {
                                "type": "number"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "currency": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "orderId": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "source": {
                            "type": "string"
                          },
                          "capiSent": {
                            "type": "boolean"
                          },
                          "postbackForwarded": {
                            "type": "boolean"
                          },
                          "createdAt": {
                            "format": "date-time",
                            "type": "string"
                          }
                        }
                      }
                    },
                    "capiEvents": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "id",
                          "teamId",
                          "clickId",
                          "conversionId",
                          "campaignId",
                          "pixelId",
                          "eventName",
                          "status",
                          "request",
                          "response",
                          "error",
                          "createdAt"
                        ],
                        "properties": {
                          "id": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "teamId": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "clickId": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "conversionId": {
                            "anyOf": [
                              {
                                "format": "uuid",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "campaignId": {
                            "anyOf": [
                              {
                                "format": "uuid",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "pixelId": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "eventName": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "status": {
                            "type": "string"
                          },
                          "request": {
                            "$comment": "json-value",
                            "description": "Arbitrary JSON value with nested arrays and objects."
                          },
                          "response": {
                            "$comment": "json-value",
                            "description": "Arbitrary JSON value with nested arrays and objects."
                          },
                          "error": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "createdAt": {
                            "format": "date-time",
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/tracker-cloaker/conversions": {
      "get": {
        "operationId": "getApiV1TrackerCloakerConversions",
        "summary": "List Tracker & Cloaker conversions",
        "tags": [
          "tracker-cloaker"
        ],
        "description": "Returns a paginated list of conversions for the current team. All filters are optional; an empty query returns the most recent conversions across the team.",
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "query",
            "name": "campaign_id",
            "required": false
          },
          {
            "schema": {
              "maxLength": 40,
              "type": "string"
            },
            "in": "query",
            "name": "status",
            "required": false
          },
          {
            "schema": {
              "maxLength": 10,
              "type": "string"
            },
            "in": "query",
            "name": "currency",
            "required": false
          },
          {
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "enum": [
                    "yes"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "no"
                  ]
                }
              ]
            },
            "in": "query",
            "name": "late",
            "required": false
          },
          {
            "schema": {
              "maxLength": 100,
              "type": "string"
            },
            "in": "query",
            "name": "cid",
            "required": false
          },
          {
            "schema": {
              "maxLength": 60,
              "type": "string"
            },
            "in": "query",
            "name": "ip",
            "required": false
          },
          {
            "schema": {
              "maxLength": 10,
              "type": "string"
            },
            "in": "query",
            "name": "country",
            "required": false
          },
          {
            "schema": {
              "maxLength": 40,
              "type": "string"
            },
            "in": "query",
            "name": "dateFrom",
            "required": false
          },
          {
            "schema": {
              "maxLength": 40,
              "type": "string"
            },
            "in": "query",
            "name": "dateTo",
            "required": false
          },
          {
            "schema": {
              "minimum": 1,
              "maximum": 100,
              "type": "integer"
            },
            "in": "query",
            "name": "limit",
            "required": false
          },
          {
            "schema": {
              "minimum": 0,
              "type": "integer"
            },
            "in": "query",
            "name": "offset",
            "required": false
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "items",
                    "total"
                  ],
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "id",
                          "teamId",
                          "clickId",
                          "status",
                          "payout",
                          "currency",
                          "orderId",
                          "source",
                          "capiSent",
                          "postbackForwarded",
                          "campaignId",
                          "campaignName",
                          "clickCountry",
                          "clickIpMasked",
                          "clickIsp",
                          "clickVerdict",
                          "lateConversion",
                          "subId1",
                          "subId2",
                          "subId3",
                          "subId4",
                          "subId5",
                          "subId6",
                          "subId7",
                          "subId8",
                          "subId9",
                          "subId10",
                          "createdAt"
                        ],
                        "properties": {
                          "id": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "teamId": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "clickId": {
                            "type": "string"
                          },
                          "status": {
                            "type": "string"
                          },
                          "payout": {
                            "anyOf": [
                              {
                                "type": "number"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "currency": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "orderId": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "source": {
                            "type": "string"
                          },
                          "capiSent": {
                            "type": "boolean"
                          },
                          "postbackForwarded": {
                            "type": "boolean"
                          },
                          "campaignId": {
                            "anyOf": [
                              {
                                "format": "uuid",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "campaignName": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "clickCountry": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "clickIpMasked": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "clickIsp": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "clickVerdict": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "lateConversion": {
                            "type": "boolean"
                          },
                          "subId1": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "subId2": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "subId3": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "subId4": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "subId5": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "subId6": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "subId7": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "subId8": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "subId9": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "subId10": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "createdAt": {
                            "format": "date-time",
                            "type": "string"
                          }
                        }
                      }
                    },
                    "total": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/tracker-cloaker/conversions/export": {
      "get": {
        "operationId": "getApiV1TrackerCloakerConversionsExport",
        "summary": "Export Tracker & Cloaker conversions as CSV",
        "tags": [
          "tracker-cloaker"
        ],
        "description": "Returns matching conversions as a CSV download. Accepts the same filters as /conversions (campaign_id, status, dateFrom, dateTo). Capped at 50k rows.",
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "query",
            "name": "campaign_id",
            "required": false
          },
          {
            "schema": {
              "maxLength": 40,
              "type": "string"
            },
            "in": "query",
            "name": "status",
            "required": false
          },
          {
            "schema": {
              "maxLength": 40,
              "type": "string"
            },
            "in": "query",
            "name": "dateFrom",
            "required": false
          },
          {
            "schema": {
              "maxLength": 40,
              "type": "string"
            },
            "in": "query",
            "name": "dateTo",
            "required": false
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/tracker-cloaker/conversions/{id}": {
      "delete": {
        "operationId": "deleteApiV1TrackerCloakerConversionsById",
        "summary": "Delete one Tracker & Cloaker conversion",
        "tags": [
          "tracker-cloaker"
        ],
        "description": "Deletes a single conversion by id, team-scoped. 404 if the conversion is not in an accessible team.",
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          },
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "header",
            "name": "x-team-id",
            "required": false,
            "description": "Destination workspace team id."
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "deleted"
                  ],
                  "properties": {
                    "deleted": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Explicit destination workspace required: send the x-team-id header or activate a team scope for this operation.",
            "content": {
              "application/json": {
                "schema": {
                  "description": "Explicit destination workspace required: send the x-team-id header or activate a team scope for this operation.",
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "SCOPE_TEAM_REQUIRED"
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/tracker-cloaker/conversions/bulk-delete": {
      "post": {
        "operationId": "postApiV1TrackerCloakerConversionsBulkDelete",
        "summary": "Bulk-delete Tracker & Cloaker conversions by click_id",
        "tags": [
          "tracker-cloaker"
        ],
        "description": "Deletes every conversion tied to any of the supplied click_ids, team-scoped. The body accepts either a `click_ids` array or a pasted `text` blob tokenized on whitespace/commas/semicolons (capped at 5000). Returns { deleted, requested, missingClickIds }.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "properties": {
                  "click_ids": {
                    "type": "array",
                    "items": {
                      "maxLength": 100,
                      "type": "string"
                    }
                  },
                  "text": {
                    "maxLength": 500000,
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "header",
            "name": "x-team-id",
            "required": false,
            "description": "Destination workspace team id."
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "deleted",
                    "requested",
                    "missingClickIds"
                  ],
                  "properties": {
                    "deleted": {
                      "type": "number"
                    },
                    "requested": {
                      "type": "number"
                    },
                    "missingClickIds": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "anyOf": [
                    {
                      "description": "Explicit destination workspace required: send the x-team-id header or activate a team scope for this operation.",
                      "additionalProperties": false,
                      "type": "object",
                      "required": [
                        "statusCode",
                        "error",
                        "message"
                      ],
                      "properties": {
                        "statusCode": {
                          "type": "number"
                        },
                        "error": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "code": {
                          "type": "string",
                          "enum": [
                            "SCOPE_TEAM_REQUIRED"
                          ]
                        }
                      }
                    },
                    {
                      "type": "object",
                      "required": [
                        "statusCode",
                        "error",
                        "message"
                      ],
                      "properties": {
                        "statusCode": {
                          "type": "number"
                        },
                        "error": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/tracker-cloaker/domains": {
      "get": {
        "operationId": "getApiV1TrackerCloakerDomains",
        "summary": "List Tracker & Cloaker domains",
        "tags": [
          "tracker-cloaker"
        ],
        "description": "Returns all Tracker & Cloaker domains for the current team.",
        "parameters": [
          {
            "schema": {
              "maxLength": 50,
              "type": "string"
            },
            "in": "query",
            "name": "status",
            "required": false
          },
          {
            "schema": {
              "minimum": 1,
              "maximum": 100,
              "type": "integer"
            },
            "in": "query",
            "name": "limit",
            "required": false
          },
          {
            "schema": {
              "minimum": 0,
              "type": "integer"
            },
            "in": "query",
            "name": "offset",
            "required": false
          },
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "header",
            "name": "x-team-id",
            "required": false,
            "description": "Destination workspace team id."
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "items",
                    "total"
                  ],
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "id",
                          "teamId",
                          "domain",
                          "importMethod",
                          "status",
                          "zoneId",
                          "nameservers",
                          "serverIp",
                          "expiresAt",
                          "errorMessage",
                          "verificationToken",
                          "verificationRecordName",
                          "verificationRecordValue",
                          "ownershipVerifiedAt",
                          "createdAt"
                        ],
                        "properties": {
                          "id": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "teamId": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "domain": {
                            "type": "string"
                          },
                          "importMethod": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "status": {
                            "type": "string"
                          },
                          "zoneId": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "nameservers": {
                            "anyOf": [
                              {
                                "$comment": "json-value",
                                "description": "Arbitrary JSON value with nested arrays and objects."
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "serverIp": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "expiresAt": {
                            "anyOf": [
                              {
                                "format": "date-time",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "errorMessage": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "verificationToken": {
                            "type": "string"
                          },
                          "verificationRecordName": {
                            "type": "string"
                          },
                          "verificationRecordValue": {
                            "type": "string"
                          },
                          "ownershipVerifiedAt": {
                            "anyOf": [
                              {
                                "format": "date-time",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "createdAt": {
                            "format": "date-time",
                            "type": "string"
                          },
                          "campaignCount": {
                            "type": "number"
                          }
                        }
                      }
                    },
                    "total": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Explicit destination workspace required: send the x-team-id header or activate a team scope for this operation.",
            "content": {
              "application/json": {
                "schema": {
                  "description": "Explicit destination workspace required: send the x-team-id header or activate a team scope for this operation.",
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "SCOPE_TEAM_REQUIRED"
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "postApiV1TrackerCloakerDomains",
        "summary": "Create a Tracker & Cloaker domain",
        "tags": [
          "tracker-cloaker"
        ],
        "description": "Creates a pending domain with a team-scoped TXT ownership challenge. A different team can reclaim only an unverified pending A-record row by proving its issued challenge.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "domain"
                ],
                "properties": {
                  "domain": {
                    "minLength": 1,
                    "maxLength": 255,
                    "type": "string"
                  },
                  "team_id": {
                    "anyOf": [
                      {
                        "format": "uuid",
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "verification_token": {
                    "minLength": 32,
                    "maxLength": 128,
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "header",
            "name": "x-team-id",
            "required": false,
            "description": "Destination workspace team id."
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "201": {
            "description": "Resource created",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "id",
                    "teamId",
                    "domain",
                    "importMethod",
                    "status",
                    "zoneId",
                    "nameservers",
                    "serverIp",
                    "expiresAt",
                    "errorMessage",
                    "verificationToken",
                    "verificationRecordName",
                    "verificationRecordValue",
                    "ownershipVerifiedAt",
                    "createdAt"
                  ],
                  "properties": {
                    "id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "teamId": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "domain": {
                      "type": "string"
                    },
                    "importMethod": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "status": {
                      "type": "string"
                    },
                    "zoneId": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "nameservers": {
                      "anyOf": [
                        {
                          "$comment": "json-value",
                          "description": "Arbitrary JSON value with nested arrays and objects."
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "serverIp": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "expiresAt": {
                      "anyOf": [
                        {
                          "format": "date-time",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "errorMessage": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "verificationToken": {
                      "type": "string"
                    },
                    "verificationRecordName": {
                      "type": "string"
                    },
                    "verificationRecordValue": {
                      "type": "string"
                    },
                    "ownershipVerifiedAt": {
                      "anyOf": [
                        {
                          "format": "date-time",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "createdAt": {
                      "format": "date-time",
                      "type": "string"
                    },
                    "campaignCount": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "202": {
            "description": "Accepted - processing asynchronously",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "claimRequired",
                    "domain",
                    "verificationToken",
                    "verificationRecordName",
                    "verificationRecordValue",
                    "expiresAt"
                  ],
                  "properties": {
                    "claimRequired": {
                      "type": "boolean",
                      "enum": [
                        true
                      ]
                    },
                    "domain": {
                      "type": "string"
                    },
                    "verificationToken": {
                      "type": "string"
                    },
                    "verificationRecordName": {
                      "type": "string"
                    },
                    "verificationRecordValue": {
                      "type": "string"
                    },
                    "expiresAt": {
                      "format": "date-time",
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "anyOf": [
                    {
                      "description": "Explicit destination workspace required: send the x-team-id header or activate a team scope for this operation.",
                      "additionalProperties": false,
                      "type": "object",
                      "required": [
                        "statusCode",
                        "error",
                        "message"
                      ],
                      "properties": {
                        "statusCode": {
                          "type": "number"
                        },
                        "error": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "code": {
                          "type": "string",
                          "enum": [
                            "SCOPE_TEAM_REQUIRED"
                          ]
                        }
                      }
                    },
                    {
                      "type": "object",
                      "required": [
                        "statusCode",
                        "error",
                        "message"
                      ],
                      "properties": {
                        "statusCode": {
                          "type": "number"
                        },
                        "error": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "Conflict - resource state prevents the operation",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/tracker-cloaker/domains/{id}": {
      "get": {
        "operationId": "getApiV1TrackerCloakerDomainsById",
        "summary": "Get a Tracker & Cloaker domain",
        "tags": [
          "tracker-cloaker"
        ],
        "description": "Returns details for a specific Tracker & Cloaker domain.",
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          },
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "header",
            "name": "x-team-id",
            "required": false,
            "description": "Destination workspace team id."
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "id",
                    "teamId",
                    "domain",
                    "importMethod",
                    "status",
                    "zoneId",
                    "nameservers",
                    "serverIp",
                    "expiresAt",
                    "errorMessage",
                    "verificationToken",
                    "verificationRecordName",
                    "verificationRecordValue",
                    "ownershipVerifiedAt",
                    "createdAt"
                  ],
                  "properties": {
                    "id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "teamId": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "domain": {
                      "type": "string"
                    },
                    "importMethod": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "status": {
                      "type": "string"
                    },
                    "zoneId": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "nameservers": {
                      "anyOf": [
                        {
                          "$comment": "json-value",
                          "description": "Arbitrary JSON value with nested arrays and objects."
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "serverIp": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "expiresAt": {
                      "anyOf": [
                        {
                          "format": "date-time",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "errorMessage": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "verificationToken": {
                      "type": "string"
                    },
                    "verificationRecordName": {
                      "type": "string"
                    },
                    "verificationRecordValue": {
                      "type": "string"
                    },
                    "ownershipVerifiedAt": {
                      "anyOf": [
                        {
                          "format": "date-time",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "createdAt": {
                      "format": "date-time",
                      "type": "string"
                    },
                    "campaignCount": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Explicit destination workspace required: send the x-team-id header or activate a team scope for this operation.",
            "content": {
              "application/json": {
                "schema": {
                  "description": "Explicit destination workspace required: send the x-team-id header or activate a team scope for this operation.",
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "SCOPE_TEAM_REQUIRED"
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      },
      "patch": {
        "operationId": "patchApiV1TrackerCloakerDomainsById",
        "summary": "Update a Tracker & Cloaker domain",
        "tags": [
          "tracker-cloaker"
        ],
        "description": "Updates the operator-selected import method. DNS verification status and provider metadata are managed server-side.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "properties": {
                  "import_method": {
                    "anyOf": [
                      {
                        "type": "string",
                        "enum": [
                          "a_record"
                        ]
                      },
                      {
                        "type": "null"
                      }
                    ]
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          },
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "header",
            "name": "x-team-id",
            "required": false,
            "description": "Destination workspace team id."
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "id",
                    "teamId",
                    "domain",
                    "importMethod",
                    "status",
                    "zoneId",
                    "nameservers",
                    "serverIp",
                    "expiresAt",
                    "errorMessage",
                    "verificationToken",
                    "verificationRecordName",
                    "verificationRecordValue",
                    "ownershipVerifiedAt",
                    "createdAt"
                  ],
                  "properties": {
                    "id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "teamId": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "domain": {
                      "type": "string"
                    },
                    "importMethod": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "status": {
                      "type": "string"
                    },
                    "zoneId": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "nameservers": {
                      "anyOf": [
                        {
                          "$comment": "json-value",
                          "description": "Arbitrary JSON value with nested arrays and objects."
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "serverIp": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "expiresAt": {
                      "anyOf": [
                        {
                          "format": "date-time",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "errorMessage": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "verificationToken": {
                      "type": "string"
                    },
                    "verificationRecordName": {
                      "type": "string"
                    },
                    "verificationRecordValue": {
                      "type": "string"
                    },
                    "ownershipVerifiedAt": {
                      "anyOf": [
                        {
                          "format": "date-time",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "createdAt": {
                      "format": "date-time",
                      "type": "string"
                    },
                    "campaignCount": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "anyOf": [
                    {
                      "description": "Explicit destination workspace required: send the x-team-id header or activate a team scope for this operation.",
                      "additionalProperties": false,
                      "type": "object",
                      "required": [
                        "statusCode",
                        "error",
                        "message"
                      ],
                      "properties": {
                        "statusCode": {
                          "type": "number"
                        },
                        "error": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "code": {
                          "type": "string",
                          "enum": [
                            "SCOPE_TEAM_REQUIRED"
                          ]
                        }
                      }
                    },
                    {
                      "type": "object",
                      "required": [
                        "statusCode",
                        "error",
                        "message"
                      ],
                      "properties": {
                        "statusCode": {
                          "type": "number"
                        },
                        "error": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      },
      "delete": {
        "operationId": "deleteApiV1TrackerCloakerDomainsById",
        "summary": "Delete a Tracker & Cloaker domain",
        "tags": [
          "tracker-cloaker"
        ],
        "description": "Deletes a Tracker & Cloaker domain.",
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          },
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "header",
            "name": "x-team-id",
            "required": false,
            "description": "Destination workspace team id."
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "deleted"
                  ],
                  "properties": {
                    "deleted": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "anyOf": [
                    {
                      "description": "Explicit destination workspace required: send the x-team-id header or activate a team scope for this operation.",
                      "additionalProperties": false,
                      "type": "object",
                      "required": [
                        "statusCode",
                        "error",
                        "message"
                      ],
                      "properties": {
                        "statusCode": {
                          "type": "number"
                        },
                        "error": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "code": {
                          "type": "string",
                          "enum": [
                            "SCOPE_TEAM_REQUIRED"
                          ]
                        }
                      }
                    },
                    {
                      "type": "object",
                      "required": [
                        "statusCode",
                        "error",
                        "message"
                      ],
                      "properties": {
                        "statusCode": {
                          "type": "number"
                        },
                        "error": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "Conflict - resource state prevents the operation",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/tracker-cloaker/domains/platform-subdomain/config": {
      "get": {
        "operationId": "getApiV1TrackerCloakerDomainsPlatformSubdomainConfig",
        "summary": "Platform subdomain availability",
        "tags": [
          "tracker-cloaker"
        ],
        "description": "Reports whether platform-hosted subdomains are available (base suffix configured) and the base suffix appended to a chosen label.",
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "header",
            "name": "x-team-id",
            "required": false,
            "description": "Destination workspace team id."
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "available",
                    "base"
                  ],
                  "properties": {
                    "available": {
                      "type": "boolean"
                    },
                    "base": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Explicit destination workspace required: send the x-team-id header or activate a team scope for this operation.",
            "content": {
              "application/json": {
                "schema": {
                  "description": "Explicit destination workspace required: send the x-team-id header or activate a team scope for this operation.",
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "SCOPE_TEAM_REQUIRED"
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/tracker-cloaker/domains/platform-subdomain": {
      "post": {
        "operationId": "postApiV1TrackerCloakerDomainsPlatformSubdomain",
        "summary": "Claim a platform-hosted subdomain",
        "tags": [
          "tracker-cloaker"
        ],
        "description": "Issues a ready-to-use subdomain under the platform base suffix (e.g. label.wevion.ai) for the team, active immediately with no DNS setup or server IP. The label is validated against a reserved-word list.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "label"
                ],
                "properties": {
                  "label": {
                    "minLength": 3,
                    "maxLength": 63,
                    "type": "string"
                  },
                  "team_id": {
                    "anyOf": [
                      {
                        "format": "uuid",
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "header",
            "name": "x-team-id",
            "required": false,
            "description": "Destination workspace team id."
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "201": {
            "description": "Resource created",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "id",
                    "teamId",
                    "domain",
                    "importMethod",
                    "status",
                    "zoneId",
                    "nameservers",
                    "serverIp",
                    "expiresAt",
                    "errorMessage",
                    "verificationToken",
                    "verificationRecordName",
                    "verificationRecordValue",
                    "ownershipVerifiedAt",
                    "createdAt"
                  ],
                  "properties": {
                    "id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "teamId": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "domain": {
                      "type": "string"
                    },
                    "importMethod": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "status": {
                      "type": "string"
                    },
                    "zoneId": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "nameservers": {
                      "anyOf": [
                        {
                          "$comment": "json-value",
                          "description": "Arbitrary JSON value with nested arrays and objects."
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "serverIp": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "expiresAt": {
                      "anyOf": [
                        {
                          "format": "date-time",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "errorMessage": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "verificationToken": {
                      "type": "string"
                    },
                    "verificationRecordName": {
                      "type": "string"
                    },
                    "verificationRecordValue": {
                      "type": "string"
                    },
                    "ownershipVerifiedAt": {
                      "anyOf": [
                        {
                          "format": "date-time",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "createdAt": {
                      "format": "date-time",
                      "type": "string"
                    },
                    "campaignCount": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "anyOf": [
                    {
                      "description": "Explicit destination workspace required: send the x-team-id header or activate a team scope for this operation.",
                      "additionalProperties": false,
                      "type": "object",
                      "required": [
                        "statusCode",
                        "error",
                        "message"
                      ],
                      "properties": {
                        "statusCode": {
                          "type": "number"
                        },
                        "error": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "code": {
                          "type": "string",
                          "enum": [
                            "SCOPE_TEAM_REQUIRED"
                          ]
                        }
                      }
                    },
                    {
                      "type": "object",
                      "required": [
                        "statusCode",
                        "error",
                        "message"
                      ],
                      "properties": {
                        "statusCode": {
                          "type": "number"
                        },
                        "error": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "Conflict - resource state prevents the operation",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/tracker-cloaker/domains/{id}/verify": {
      "post": {
        "operationId": "postApiV1TrackerCloakerDomainsByIdVerify",
        "summary": "Verify a Tracker & Cloaker domain",
        "tags": [
          "tracker-cloaker"
        ],
        "description": "Activates a direct A-record only after its TXT ownership challenge is proven. An exact team-owned Cloudflare zone or an in-app NameSilo purchase is accepted as server-side ownership proof.",
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          },
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "header",
            "name": "x-team-id",
            "required": false,
            "description": "Destination workspace team id."
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "id",
                    "domain",
                    "status",
                    "verified",
                    "message"
                  ],
                  "properties": {
                    "id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "domain": {
                      "type": "string"
                    },
                    "status": {
                      "type": "string"
                    },
                    "verified": {
                      "type": "boolean"
                    },
                    "message": {
                      "type": "string"
                    },
                    "resolvedIp": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "resolvedIps": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "serverIp": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "viaCloudflare": {
                      "type": "boolean"
                    },
                    "txtVerified": {
                      "type": "boolean"
                    },
                    "verificationRecordName": {
                      "type": "string"
                    },
                    "verificationRecordValue": {
                      "type": "string"
                    },
                    "dnsRecords": {
                      "anyOf": [
                        {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "required": [
                              "recordId",
                              "type",
                              "host",
                              "value",
                              "ttl",
                              "distance"
                            ],
                            "properties": {
                              "recordId": {
                                "type": "string"
                              },
                              "type": {
                                "type": "string"
                              },
                              "host": {
                                "type": "string"
                              },
                              "value": {
                                "type": "string"
                              },
                              "ttl": {
                                "type": "number"
                              },
                              "distance": {
                                "type": "number"
                              }
                            }
                          }
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "availability": {
                      "anyOf": [
                        {
                          "type": "object",
                          "required": [
                            "available",
                            "price"
                          ],
                          "properties": {
                            "available": {
                              "type": "boolean"
                            },
                            "price": {
                              "anyOf": [
                                {
                                  "type": "number"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            }
                          }
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "anyOf": [
                    {
                      "description": "Explicit destination workspace required: send the x-team-id header or activate a team scope for this operation.",
                      "additionalProperties": false,
                      "type": "object",
                      "required": [
                        "statusCode",
                        "error",
                        "message"
                      ],
                      "properties": {
                        "statusCode": {
                          "type": "number"
                        },
                        "error": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "code": {
                          "type": "string",
                          "enum": [
                            "SCOPE_TEAM_REQUIRED"
                          ]
                        }
                      }
                    },
                    {
                      "type": "object",
                      "required": [
                        "statusCode",
                        "error",
                        "message"
                      ],
                      "properties": {
                        "statusCode": {
                          "type": "number"
                        },
                        "error": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/tracker-cloaker/domains/check-availability": {
      "get": {
        "operationId": "getApiV1TrackerCloakerDomainsCheckAvailability",
        "summary": "Check domain availability",
        "tags": [
          "tracker-cloaker"
        ],
        "description": "Checks whether a domain is available for registration via Namesilo.",
        "parameters": [
          {
            "schema": {
              "minLength": 1,
              "maxLength": 255,
              "type": "string"
            },
            "in": "query",
            "name": "domain",
            "required": true
          },
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "header",
            "name": "x-team-id",
            "required": false,
            "description": "Destination workspace team id."
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "domain",
                    "available"
                  ],
                  "properties": {
                    "domain": {
                      "type": "string"
                    },
                    "available": {
                      "type": "boolean"
                    },
                    "price": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "anyOf": [
                    {
                      "description": "Explicit destination workspace required: send the x-team-id header or activate a team scope for this operation.",
                      "additionalProperties": false,
                      "type": "object",
                      "required": [
                        "statusCode",
                        "error",
                        "message"
                      ],
                      "properties": {
                        "statusCode": {
                          "type": "number"
                        },
                        "error": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "code": {
                          "type": "string",
                          "enum": [
                            "SCOPE_TEAM_REQUIRED"
                          ]
                        }
                      }
                    },
                    {
                      "type": "object",
                      "required": [
                        "statusCode",
                        "error",
                        "message"
                      ],
                      "properties": {
                        "statusCode": {
                          "type": "number"
                        },
                        "error": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "502": {
            "description": "Bad gateway - upstream provider failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "postApiV1TrackerCloakerDomainsCheckAvailability",
        "summary": "Bulk check domain availability",
        "tags": [
          "tracker-cloaker"
        ],
        "description": "Checks availability for multiple domains via Namesilo (max 20).",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "domains"
                ],
                "properties": {
                  "domains": {
                    "minItems": 1,
                    "maxItems": 20,
                    "type": "array",
                    "items": {
                      "minLength": 1,
                      "maxLength": 255,
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "header",
            "name": "x-team-id",
            "required": false,
            "description": "Destination workspace team id."
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "results"
                  ],
                  "properties": {
                    "results": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "domain",
                          "available",
                          "price"
                        ],
                        "properties": {
                          "domain": {
                            "type": "string"
                          },
                          "available": {
                            "type": "boolean"
                          },
                          "price": {
                            "anyOf": [
                              {
                                "type": "number"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "error": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "anyOf": [
                    {
                      "description": "Explicit destination workspace required: send the x-team-id header or activate a team scope for this operation.",
                      "additionalProperties": false,
                      "type": "object",
                      "required": [
                        "statusCode",
                        "error",
                        "message"
                      ],
                      "properties": {
                        "statusCode": {
                          "type": "number"
                        },
                        "error": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "code": {
                          "type": "string",
                          "enum": [
                            "SCOPE_TEAM_REQUIRED"
                          ]
                        }
                      }
                    },
                    {
                      "type": "object",
                      "required": [
                        "statusCode",
                        "error",
                        "message"
                      ],
                      "properties": {
                        "statusCode": {
                          "type": "number"
                        },
                        "error": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/tracker-cloaker/domains/register": {
      "post": {
        "operationId": "postApiV1TrackerCloakerDomainsRegister",
        "summary": "Register a domain via Namesilo",
        "tags": [
          "tracker-cloaker"
        ],
        "description": "Registers a domain through Namesilo (paid). Requires confirm:true to proceed.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "domain"
                ],
                "properties": {
                  "domain": {
                    "minLength": 1,
                    "maxLength": 255,
                    "type": "string"
                  },
                  "years": {
                    "minimum": 1,
                    "maximum": 10,
                    "type": "integer"
                  },
                  "confirm": {
                    "type": "boolean"
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "header",
            "name": "x-team-id",
            "required": false,
            "description": "Destination workspace team id."
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "201": {
            "description": "Resource created",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "orderId",
                    "domain"
                  ],
                  "properties": {
                    "orderId": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "domain": {
                      "type": "object",
                      "required": [
                        "id",
                        "teamId",
                        "domain",
                        "importMethod",
                        "status",
                        "zoneId",
                        "nameservers",
                        "serverIp",
                        "expiresAt",
                        "errorMessage",
                        "verificationToken",
                        "verificationRecordName",
                        "verificationRecordValue",
                        "ownershipVerifiedAt",
                        "createdAt"
                      ],
                      "properties": {
                        "id": {
                          "format": "uuid",
                          "type": "string"
                        },
                        "teamId": {
                          "format": "uuid",
                          "type": "string"
                        },
                        "domain": {
                          "type": "string"
                        },
                        "importMethod": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "status": {
                          "type": "string"
                        },
                        "zoneId": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "nameservers": {
                          "anyOf": [
                            {
                              "$comment": "json-value",
                              "description": "Arbitrary JSON value with nested arrays and objects."
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "serverIp": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "expiresAt": {
                          "anyOf": [
                            {
                              "format": "date-time",
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "errorMessage": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "verificationToken": {
                          "type": "string"
                        },
                        "verificationRecordName": {
                          "type": "string"
                        },
                        "verificationRecordValue": {
                          "type": "string"
                        },
                        "ownershipVerifiedAt": {
                          "anyOf": [
                            {
                              "format": "date-time",
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "createdAt": {
                          "format": "date-time",
                          "type": "string"
                        },
                        "campaignCount": {
                          "type": "number"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "anyOf": [
                    {
                      "description": "Explicit destination workspace required: send the x-team-id header or activate a team scope for this operation.",
                      "additionalProperties": false,
                      "type": "object",
                      "required": [
                        "statusCode",
                        "error",
                        "message"
                      ],
                      "properties": {
                        "statusCode": {
                          "type": "number"
                        },
                        "error": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "code": {
                          "type": "string",
                          "enum": [
                            "SCOPE_TEAM_REQUIRED"
                          ]
                        }
                      }
                    },
                    {
                      "type": "object",
                      "required": [
                        "statusCode",
                        "error",
                        "message"
                      ],
                      "properties": {
                        "statusCode": {
                          "type": "number"
                        },
                        "error": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "Conflict - resource state prevents the operation",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "502": {
            "description": "Bad gateway - upstream provider failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/tracker-cloaker/domains/import": {
      "post": {
        "operationId": "postApiV1TrackerCloakerDomainsImport",
        "summary": "Bulk import domains (A-record)",
        "tags": [
          "tracker-cloaker"
        ],
        "description": "Inserts pending_dns rows for A-record domains (max 50). Each row must also pass its TXT ownership challenge before activation.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "domains"
                ],
                "properties": {
                  "domains": {
                    "minItems": 1,
                    "maxItems": 50,
                    "type": "array",
                    "items": {
                      "minLength": 1,
                      "maxLength": 255,
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "header",
            "name": "x-team-id",
            "required": false,
            "description": "Destination workspace team id."
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "inserted",
                    "skipped"
                  ],
                  "properties": {
                    "inserted": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "skipped": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "anyOf": [
                    {
                      "description": "Explicit destination workspace required: send the x-team-id header or activate a team scope for this operation.",
                      "additionalProperties": false,
                      "type": "object",
                      "required": [
                        "statusCode",
                        "error",
                        "message"
                      ],
                      "properties": {
                        "statusCode": {
                          "type": "number"
                        },
                        "error": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "code": {
                          "type": "string",
                          "enum": [
                            "SCOPE_TEAM_REQUIRED"
                          ]
                        }
                      }
                    },
                    {
                      "type": "object",
                      "required": [
                        "statusCode",
                        "error",
                        "message"
                      ],
                      "properties": {
                        "statusCode": {
                          "type": "number"
                        },
                        "error": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/tracker-cloaker/domains/{id}/auto-link-cf": {
      "post": {
        "operationId": "postApiV1TrackerCloakerDomainsByIdAutoLinkCf",
        "summary": "Auto-link a Cloudflare zone",
        "tags": [
          "tracker-cloaker"
        ],
        "description": "Finds the Cloudflare zone for the domain and stores its zone id + nameservers.",
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          },
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "header",
            "name": "x-team-id",
            "required": false,
            "description": "Destination workspace team id."
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "ok"
                  ],
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    },
                    "zoneId": {
                      "type": "string"
                    },
                    "nameservers": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "zoneStatus": {
                      "type": "string"
                    },
                    "alreadyLinked": {
                      "type": "boolean"
                    },
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "anyOf": [
                    {
                      "description": "Explicit destination workspace required: send the x-team-id header or activate a team scope for this operation.",
                      "additionalProperties": false,
                      "type": "object",
                      "required": [
                        "statusCode",
                        "error",
                        "message"
                      ],
                      "properties": {
                        "statusCode": {
                          "type": "number"
                        },
                        "error": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "code": {
                          "type": "string",
                          "enum": [
                            "SCOPE_TEAM_REQUIRED"
                          ]
                        }
                      }
                    },
                    {
                      "type": "object",
                      "required": [
                        "statusCode",
                        "error",
                        "message"
                      ],
                      "properties": {
                        "statusCode": {
                          "type": "number"
                        },
                        "error": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/tracker-cloaker/domains/{id}/apply-cf-profile": {
      "post": {
        "operationId": "postApiV1TrackerCloakerDomainsByIdApplyCfProfile",
        "summary": "Apply Cloudflare cloaker profile",
        "tags": [
          "tracker-cloaker"
        ],
        "description": "Applies the cloaker hardening zone settings (cache/minify/bot-fight/etc.) to the domain zone.",
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          },
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "header",
            "name": "x-team-id",
            "required": false,
            "description": "Destination workspace team id."
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "ok"
                  ],
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    },
                    "domain": {
                      "type": "string"
                    },
                    "report": {
                      "type": "object",
                      "required": [
                        "applied",
                        "skipped",
                        "errors"
                      ],
                      "properties": {
                        "applied": {
                          "type": "array",
                          "items": {
                            "type": "string"
                          }
                        },
                        "skipped": {
                          "type": "array",
                          "items": {
                            "type": "string"
                          }
                        },
                        "errors": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "required": [
                              "setting",
                              "error"
                            ],
                            "properties": {
                              "setting": {
                                "type": "string"
                              },
                              "error": {
                                "type": "string"
                              }
                            }
                          }
                        }
                      }
                    },
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "anyOf": [
                    {
                      "description": "Explicit destination workspace required: send the x-team-id header or activate a team scope for this operation.",
                      "additionalProperties": false,
                      "type": "object",
                      "required": [
                        "statusCode",
                        "error",
                        "message"
                      ],
                      "properties": {
                        "statusCode": {
                          "type": "number"
                        },
                        "error": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "code": {
                          "type": "string",
                          "enum": [
                            "SCOPE_TEAM_REQUIRED"
                          ]
                        }
                      }
                    },
                    {
                      "type": "object",
                      "required": [
                        "statusCode",
                        "error",
                        "message"
                      ],
                      "properties": {
                        "statusCode": {
                          "type": "number"
                        },
                        "error": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/tracker-cloaker/domains/apply-cf-profile-all": {
      "post": {
        "operationId": "postApiV1TrackerCloakerDomainsApplyCfProfileAll",
        "summary": "Apply Cloudflare cloaker profile to all linked domains",
        "tags": [
          "tracker-cloaker"
        ],
        "description": "Applies the cloaker hardening profile to every domain that has a Cloudflare zone linked.",
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "header",
            "name": "x-team-id",
            "required": false,
            "description": "Destination workspace team id."
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "results"
                  ],
                  "properties": {
                    "results": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "domain",
                          "ok"
                        ],
                        "properties": {
                          "domain": {
                            "type": "string"
                          },
                          "ok": {
                            "type": "boolean"
                          },
                          "report": {
                            "type": "object",
                            "required": [
                              "applied",
                              "skipped",
                              "errors"
                            ],
                            "properties": {
                              "applied": {
                                "type": "array",
                                "items": {
                                  "type": "string"
                                }
                              },
                              "skipped": {
                                "type": "array",
                                "items": {
                                  "type": "string"
                                }
                              },
                              "errors": {
                                "type": "array",
                                "items": {
                                  "type": "object",
                                  "required": [
                                    "setting",
                                    "error"
                                  ],
                                  "properties": {
                                    "setting": {
                                      "type": "string"
                                    },
                                    "error": {
                                      "type": "string"
                                    }
                                  }
                                }
                              }
                            }
                          },
                          "error": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "anyOf": [
                    {
                      "description": "Explicit destination workspace required: send the x-team-id header or activate a team scope for this operation.",
                      "additionalProperties": false,
                      "type": "object",
                      "required": [
                        "statusCode",
                        "error",
                        "message"
                      ],
                      "properties": {
                        "statusCode": {
                          "type": "number"
                        },
                        "error": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "code": {
                          "type": "string",
                          "enum": [
                            "SCOPE_TEAM_REQUIRED"
                          ]
                        }
                      }
                    },
                    {
                      "type": "object",
                      "required": [
                        "statusCode",
                        "error",
                        "message"
                      ],
                      "properties": {
                        "statusCode": {
                          "type": "number"
                        },
                        "error": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/tracker-cloaker/domains/{id}/dns": {
      "post": {
        "operationId": "postApiV1TrackerCloakerDomainsByIdDns",
        "summary": "Add a DNS record",
        "tags": [
          "tracker-cloaker"
        ],
        "description": "Adds a DNS record to a Tracker & Cloaker domain via Namesilo.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "rrtype",
                  "rrhost",
                  "rrvalue"
                ],
                "properties": {
                  "rrtype": {
                    "minLength": 1,
                    "maxLength": 10,
                    "type": "string"
                  },
                  "rrhost": {
                    "maxLength": 255,
                    "type": "string"
                  },
                  "rrvalue": {
                    "minLength": 1,
                    "maxLength": 500,
                    "type": "string"
                  },
                  "rrttl": {
                    "minimum": 60,
                    "maximum": 2592000,
                    "type": "integer"
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          },
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "header",
            "name": "x-team-id",
            "required": false,
            "description": "Destination workspace team id."
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "recordId"
                  ],
                  "properties": {
                    "recordId": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "anyOf": [
                    {
                      "description": "Explicit destination workspace required: send the x-team-id header or activate a team scope for this operation.",
                      "additionalProperties": false,
                      "type": "object",
                      "required": [
                        "statusCode",
                        "error",
                        "message"
                      ],
                      "properties": {
                        "statusCode": {
                          "type": "number"
                        },
                        "error": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "code": {
                          "type": "string",
                          "enum": [
                            "SCOPE_TEAM_REQUIRED"
                          ]
                        }
                      }
                    },
                    {
                      "type": "object",
                      "required": [
                        "statusCode",
                        "error",
                        "message"
                      ],
                      "properties": {
                        "statusCode": {
                          "type": "number"
                        },
                        "error": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "502": {
            "description": "Bad gateway - upstream provider failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/tracker-cloaker/filter-lists": {
      "get": {
        "operationId": "getApiV1TrackerCloakerFilterLists",
        "summary": "List Tracker & Cloaker filter lists",
        "tags": [
          "tracker-cloaker"
        ],
        "description": "Returns all filter lists for the current team.",
        "parameters": [
          {
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "enum": [
                    "ua"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "ip"
                  ]
                }
              ]
            },
            "in": "query",
            "name": "type",
            "required": false
          },
          {
            "schema": {
              "minimum": 1,
              "maximum": 100,
              "type": "integer"
            },
            "in": "query",
            "name": "limit",
            "required": false
          },
          {
            "schema": {
              "minimum": 0,
              "type": "integer"
            },
            "in": "query",
            "name": "offset",
            "required": false
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "items",
                    "total"
                  ],
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "id",
                          "teamId",
                          "name",
                          "type",
                          "entries",
                          "createdAt"
                        ],
                        "properties": {
                          "id": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "teamId": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "name": {
                            "type": "string"
                          },
                          "type": {
                            "type": "string"
                          },
                          "entries": {
                            "type": "array",
                            "items": {
                              "type": "string"
                            }
                          },
                          "createdAt": {
                            "format": "date-time",
                            "type": "string"
                          }
                        }
                      }
                    },
                    "total": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "postApiV1TrackerCloakerFilterLists",
        "summary": "Create a Tracker & Cloaker filter list",
        "tags": [
          "tracker-cloaker"
        ],
        "description": "Creates a new filter list for the current team.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "name",
                  "type"
                ],
                "properties": {
                  "name": {
                    "minLength": 1,
                    "maxLength": 200,
                    "type": "string"
                  },
                  "type": {
                    "anyOf": [
                      {
                        "type": "string",
                        "enum": [
                          "ua"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "ip"
                        ]
                      }
                    ]
                  },
                  "entries": {
                    "maxItems": 10000,
                    "type": "array",
                    "items": {
                      "minLength": 1,
                      "maxLength": 200,
                      "type": "string"
                    }
                  },
                  "team_id": {
                    "format": "uuid",
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "header",
            "name": "x-team-id",
            "required": false,
            "description": "Destination workspace team id."
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "201": {
            "description": "Resource created",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "id",
                    "teamId",
                    "name",
                    "type",
                    "entries",
                    "createdAt"
                  ],
                  "properties": {
                    "id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "teamId": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "name": {
                      "type": "string"
                    },
                    "type": {
                      "type": "string"
                    },
                    "entries": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "createdAt": {
                      "format": "date-time",
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Explicit destination workspace required: send the x-team-id header or activate a team scope for this operation.",
            "content": {
              "application/json": {
                "schema": {
                  "description": "Explicit destination workspace required: send the x-team-id header or activate a team scope for this operation.",
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "SCOPE_TEAM_REQUIRED"
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/tracker-cloaker/filter-lists/{id}": {
      "get": {
        "operationId": "getApiV1TrackerCloakerFilterListsById",
        "summary": "Get a Tracker & Cloaker filter list",
        "tags": [
          "tracker-cloaker"
        ],
        "description": "Returns details for a specific filter list.",
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "id",
                    "teamId",
                    "name",
                    "type",
                    "entries",
                    "createdAt"
                  ],
                  "properties": {
                    "id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "teamId": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "name": {
                      "type": "string"
                    },
                    "type": {
                      "type": "string"
                    },
                    "entries": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "createdAt": {
                      "format": "date-time",
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      },
      "put": {
        "operationId": "putApiV1TrackerCloakerFilterListsById",
        "summary": "Update a Tracker & Cloaker filter list",
        "tags": [
          "tracker-cloaker"
        ],
        "description": "Updates an existing filter list.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "properties": {
                  "name": {
                    "minLength": 1,
                    "maxLength": 200,
                    "type": "string"
                  },
                  "type": {
                    "anyOf": [
                      {
                        "type": "string",
                        "enum": [
                          "ua"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "ip"
                        ]
                      }
                    ]
                  },
                  "entries": {
                    "maxItems": 10000,
                    "type": "array",
                    "items": {
                      "minLength": 1,
                      "maxLength": 200,
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          },
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "header",
            "name": "x-team-id",
            "required": false,
            "description": "Destination workspace team id."
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "id",
                    "teamId",
                    "name",
                    "type",
                    "entries",
                    "createdAt"
                  ],
                  "properties": {
                    "id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "teamId": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "name": {
                      "type": "string"
                    },
                    "type": {
                      "type": "string"
                    },
                    "entries": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "createdAt": {
                      "format": "date-time",
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Explicit destination workspace required: send the x-team-id header or activate a team scope for this operation.",
            "content": {
              "application/json": {
                "schema": {
                  "description": "Explicit destination workspace required: send the x-team-id header or activate a team scope for this operation.",
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "SCOPE_TEAM_REQUIRED"
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      },
      "delete": {
        "operationId": "deleteApiV1TrackerCloakerFilterListsById",
        "summary": "Delete a Tracker & Cloaker filter list",
        "tags": [
          "tracker-cloaker"
        ],
        "description": "Permanently deletes a filter list.",
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          },
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "header",
            "name": "x-team-id",
            "required": false,
            "description": "Destination workspace team id."
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "deleted"
                  ],
                  "properties": {
                    "deleted": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Explicit destination workspace required: send the x-team-id header or activate a team scope for this operation.",
            "content": {
              "application/json": {
                "schema": {
                  "description": "Explicit destination workspace required: send the x-team-id header or activate a team scope for this operation.",
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "SCOPE_TEAM_REQUIRED"
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/tracker-cloaker/forms": {
      "get": {
        "operationId": "getApiV1TrackerCloakerForms",
        "summary": "List Tracker & Cloaker forms",
        "tags": [
          "tracker-cloaker"
        ],
        "description": "Returns lead-capture forms for the current team. Archived forms are hidden by default; pass an explicit status filter to select a specific state.",
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "query",
            "name": "advertiser_id",
            "required": false
          },
          {
            "schema": {
              "maxLength": 40,
              "type": "string"
            },
            "in": "query",
            "name": "status",
            "required": false
          },
          {
            "schema": {
              "minimum": 1,
              "maximum": 100,
              "type": "integer"
            },
            "in": "query",
            "name": "limit",
            "required": false
          },
          {
            "schema": {
              "minimum": 0,
              "type": "integer"
            },
            "in": "query",
            "name": "offset",
            "required": false
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "items",
                    "total"
                  ],
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "id",
                          "teamId",
                          "advertiserId",
                          "productId",
                          "name",
                          "fields",
                          "theme",
                          "smsEnabled",
                          "smsTemplate",
                          "smsTriggerStatuses",
                          "phoneValidationEnabled",
                          "phoneCountryCode",
                          "includeFingerprint",
                          "tyLandingId",
                          "status",
                          "createdAt",
                          "updatedAt"
                        ],
                        "properties": {
                          "id": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "teamId": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "advertiserId": {
                            "anyOf": [
                              {
                                "format": "uuid",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "productId": {
                            "anyOf": [
                              {
                                "format": "uuid",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "name": {
                            "type": "string"
                          },
                          "fields": {
                            "anyOf": [
                              {
                                "type": "array",
                                "items": {
                                  "additionalProperties": true,
                                  "type": "object",
                                  "required": [
                                    "key",
                                    "label",
                                    "type"
                                  ],
                                  "properties": {
                                    "key": {
                                      "type": "string"
                                    },
                                    "label": {
                                      "type": "string"
                                    },
                                    "type": {
                                      "type": "string"
                                    },
                                    "required": {
                                      "type": "boolean"
                                    },
                                    "placeholder": {
                                      "anyOf": [
                                        {
                                          "type": "string"
                                        },
                                        {
                                          "type": "null"
                                        }
                                      ]
                                    },
                                    "options": {
                                      "type": "array",
                                      "items": {
                                        "type": "string"
                                      }
                                    }
                                  }
                                }
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "theme": {
                            "anyOf": [
                              {
                                "description": "JSON object with nested arrays and objects.",
                                "type": "object",
                                "additionalProperties": {
                                  "$comment": "json-value",
                                  "description": "Arbitrary JSON value with nested arrays and objects."
                                }
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "smsEnabled": {
                            "type": "boolean"
                          },
                          "smsTemplate": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "smsTriggerStatuses": {
                            "type": "array",
                            "items": {
                              "type": "string"
                            }
                          },
                          "phoneValidationEnabled": {
                            "type": "boolean"
                          },
                          "phoneCountryCode": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "includeFingerprint": {
                            "type": "boolean"
                          },
                          "tyLandingId": {
                            "anyOf": [
                              {
                                "format": "uuid",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "status": {
                            "type": "string"
                          },
                          "createdAt": {
                            "format": "date-time",
                            "type": "string"
                          },
                          "updatedAt": {
                            "anyOf": [
                              {
                                "format": "date-time",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          }
                        }
                      }
                    },
                    "total": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "postApiV1TrackerCloakerForms",
        "summary": "Create a Tracker & Cloaker form",
        "tags": [
          "tracker-cloaker"
        ],
        "description": "Creates a new lead-capture form for the current team.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "name"
                ],
                "properties": {
                  "name": {
                    "minLength": 1,
                    "maxLength": 200,
                    "type": "string"
                  },
                  "team_id": {
                    "format": "uuid",
                    "type": "string"
                  },
                  "advertiser_id": {
                    "anyOf": [
                      {
                        "format": "uuid",
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "product_id": {
                    "anyOf": [
                      {
                        "format": "uuid",
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "fields": {
                    "anyOf": [
                      {
                        "maxItems": 60,
                        "type": "array",
                        "items": {
                          "anyOf": [
                            {
                              "additionalProperties": false,
                              "type": "object",
                              "required": [
                                "label",
                                "type",
                                "key"
                              ],
                              "properties": {
                                "label": {
                                  "maxLength": 200,
                                  "type": "string"
                                },
                                "type": {
                                  "anyOf": [
                                    {
                                      "type": "string",
                                      "enum": [
                                        "text"
                                      ]
                                    },
                                    {
                                      "type": "string",
                                      "enum": [
                                        "email"
                                      ]
                                    },
                                    {
                                      "type": "string",
                                      "enum": [
                                        "tel"
                                      ]
                                    },
                                    {
                                      "type": "string",
                                      "enum": [
                                        "number"
                                      ]
                                    },
                                    {
                                      "type": "string",
                                      "enum": [
                                        "textarea"
                                      ]
                                    },
                                    {
                                      "type": "string",
                                      "enum": [
                                        "select"
                                      ]
                                    },
                                    {
                                      "type": "string",
                                      "enum": [
                                        "checkbox"
                                      ]
                                    },
                                    {
                                      "type": "string",
                                      "enum": [
                                        "hidden"
                                      ]
                                    }
                                  ]
                                },
                                "required": {
                                  "type": "boolean"
                                },
                                "placeholder": {
                                  "anyOf": [
                                    {
                                      "maxLength": 500,
                                      "type": "string"
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "options": {
                                  "maxItems": 100,
                                  "type": "array",
                                  "items": {
                                    "maxLength": 500,
                                    "type": "string"
                                  }
                                },
                                "key": {
                                  "minLength": 1,
                                  "maxLength": 64,
                                  "pattern": "^[A-Za-z_][A-Za-z0-9_]{0,63}$",
                                  "type": "string"
                                },
                                "name": {
                                  "minLength": 1,
                                  "maxLength": 64,
                                  "pattern": "^[A-Za-z_][A-Za-z0-9_]{0,63}$",
                                  "type": "string"
                                },
                                "id": {
                                  "minLength": 1,
                                  "maxLength": 64,
                                  "pattern": "^[A-Za-z_][A-Za-z0-9_]{0,63}$",
                                  "type": "string"
                                }
                              }
                            },
                            {
                              "additionalProperties": false,
                              "type": "object",
                              "required": [
                                "label",
                                "type",
                                "name"
                              ],
                              "properties": {
                                "label": {
                                  "maxLength": 200,
                                  "type": "string"
                                },
                                "type": {
                                  "anyOf": [
                                    {
                                      "type": "string",
                                      "enum": [
                                        "text"
                                      ]
                                    },
                                    {
                                      "type": "string",
                                      "enum": [
                                        "email"
                                      ]
                                    },
                                    {
                                      "type": "string",
                                      "enum": [
                                        "tel"
                                      ]
                                    },
                                    {
                                      "type": "string",
                                      "enum": [
                                        "number"
                                      ]
                                    },
                                    {
                                      "type": "string",
                                      "enum": [
                                        "textarea"
                                      ]
                                    },
                                    {
                                      "type": "string",
                                      "enum": [
                                        "select"
                                      ]
                                    },
                                    {
                                      "type": "string",
                                      "enum": [
                                        "checkbox"
                                      ]
                                    },
                                    {
                                      "type": "string",
                                      "enum": [
                                        "hidden"
                                      ]
                                    }
                                  ]
                                },
                                "required": {
                                  "type": "boolean"
                                },
                                "placeholder": {
                                  "anyOf": [
                                    {
                                      "maxLength": 500,
                                      "type": "string"
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "options": {
                                  "maxItems": 100,
                                  "type": "array",
                                  "items": {
                                    "maxLength": 500,
                                    "type": "string"
                                  }
                                },
                                "name": {
                                  "minLength": 1,
                                  "maxLength": 64,
                                  "pattern": "^[A-Za-z_][A-Za-z0-9_]{0,63}$",
                                  "type": "string"
                                },
                                "key": {
                                  "minLength": 1,
                                  "maxLength": 64,
                                  "pattern": "^[A-Za-z_][A-Za-z0-9_]{0,63}$",
                                  "type": "string"
                                },
                                "id": {
                                  "minLength": 1,
                                  "maxLength": 64,
                                  "pattern": "^[A-Za-z_][A-Za-z0-9_]{0,63}$",
                                  "type": "string"
                                }
                              }
                            },
                            {
                              "additionalProperties": false,
                              "type": "object",
                              "required": [
                                "label",
                                "type",
                                "id"
                              ],
                              "properties": {
                                "label": {
                                  "maxLength": 200,
                                  "type": "string"
                                },
                                "type": {
                                  "anyOf": [
                                    {
                                      "type": "string",
                                      "enum": [
                                        "text"
                                      ]
                                    },
                                    {
                                      "type": "string",
                                      "enum": [
                                        "email"
                                      ]
                                    },
                                    {
                                      "type": "string",
                                      "enum": [
                                        "tel"
                                      ]
                                    },
                                    {
                                      "type": "string",
                                      "enum": [
                                        "number"
                                      ]
                                    },
                                    {
                                      "type": "string",
                                      "enum": [
                                        "textarea"
                                      ]
                                    },
                                    {
                                      "type": "string",
                                      "enum": [
                                        "select"
                                      ]
                                    },
                                    {
                                      "type": "string",
                                      "enum": [
                                        "checkbox"
                                      ]
                                    },
                                    {
                                      "type": "string",
                                      "enum": [
                                        "hidden"
                                      ]
                                    }
                                  ]
                                },
                                "required": {
                                  "type": "boolean"
                                },
                                "placeholder": {
                                  "anyOf": [
                                    {
                                      "maxLength": 500,
                                      "type": "string"
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "options": {
                                  "maxItems": 100,
                                  "type": "array",
                                  "items": {
                                    "maxLength": 500,
                                    "type": "string"
                                  }
                                },
                                "id": {
                                  "minLength": 1,
                                  "maxLength": 64,
                                  "pattern": "^[A-Za-z_][A-Za-z0-9_]{0,63}$",
                                  "type": "string"
                                },
                                "key": {
                                  "minLength": 1,
                                  "maxLength": 64,
                                  "pattern": "^[A-Za-z_][A-Za-z0-9_]{0,63}$",
                                  "type": "string"
                                },
                                "name": {
                                  "minLength": 1,
                                  "maxLength": 64,
                                  "pattern": "^[A-Za-z_][A-Za-z0-9_]{0,63}$",
                                  "type": "string"
                                }
                              }
                            }
                          ]
                        }
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "theme": {
                    "anyOf": [
                      {
                        "description": "JSON object with nested arrays and objects.",
                        "type": "object",
                        "additionalProperties": {
                          "$comment": "json-value",
                          "description": "Arbitrary JSON value with nested arrays and objects."
                        }
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "sms_enabled": {
                    "type": "boolean"
                  },
                  "sms_template": {
                    "anyOf": [
                      {
                        "maxLength": 1000,
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "sms_trigger_statuses": {
                    "anyOf": [
                      {
                        "type": "array",
                        "items": {
                          "maxLength": 40,
                          "type": "string"
                        }
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "phone_validation_enabled": {
                    "type": "boolean"
                  },
                  "phone_country_code": {
                    "anyOf": [
                      {
                        "maxLength": 2,
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "include_fingerprint": {
                    "type": "boolean"
                  },
                  "ty_landing_id": {
                    "anyOf": [
                      {
                        "format": "uuid",
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "status": {
                    "anyOf": [
                      {
                        "type": "string",
                        "enum": [
                          "active"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "paused"
                        ]
                      }
                    ]
                  },
                  "redirect_url": {
                    "anyOf": [
                      {
                        "format": "uri",
                        "maxLength": 2048,
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "success_message": {
                    "anyOf": [
                      {
                        "maxLength": 2000,
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "header",
            "name": "x-team-id",
            "required": false,
            "description": "Destination workspace team id."
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "201": {
            "description": "Resource created",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "id",
                    "teamId",
                    "advertiserId",
                    "productId",
                    "name",
                    "fields",
                    "theme",
                    "smsEnabled",
                    "smsTemplate",
                    "smsTriggerStatuses",
                    "phoneValidationEnabled",
                    "phoneCountryCode",
                    "includeFingerprint",
                    "tyLandingId",
                    "status",
                    "createdAt",
                    "updatedAt"
                  ],
                  "properties": {
                    "id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "teamId": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "advertiserId": {
                      "anyOf": [
                        {
                          "format": "uuid",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "productId": {
                      "anyOf": [
                        {
                          "format": "uuid",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "name": {
                      "type": "string"
                    },
                    "fields": {
                      "anyOf": [
                        {
                          "type": "array",
                          "items": {
                            "additionalProperties": true,
                            "type": "object",
                            "required": [
                              "key",
                              "label",
                              "type"
                            ],
                            "properties": {
                              "key": {
                                "type": "string"
                              },
                              "label": {
                                "type": "string"
                              },
                              "type": {
                                "type": "string"
                              },
                              "required": {
                                "type": "boolean"
                              },
                              "placeholder": {
                                "anyOf": [
                                  {
                                    "type": "string"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "options": {
                                "type": "array",
                                "items": {
                                  "type": "string"
                                }
                              }
                            }
                          }
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "theme": {
                      "anyOf": [
                        {
                          "description": "JSON object with nested arrays and objects.",
                          "type": "object",
                          "additionalProperties": {
                            "$comment": "json-value",
                            "description": "Arbitrary JSON value with nested arrays and objects."
                          }
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "smsEnabled": {
                      "type": "boolean"
                    },
                    "smsTemplate": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "smsTriggerStatuses": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "phoneValidationEnabled": {
                      "type": "boolean"
                    },
                    "phoneCountryCode": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "includeFingerprint": {
                      "type": "boolean"
                    },
                    "tyLandingId": {
                      "anyOf": [
                        {
                          "format": "uuid",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "status": {
                      "type": "string"
                    },
                    "createdAt": {
                      "format": "date-time",
                      "type": "string"
                    },
                    "updatedAt": {
                      "anyOf": [
                        {
                          "format": "date-time",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "anyOf": [
                    {
                      "description": "Explicit destination workspace required: send the x-team-id header or activate a team scope for this operation.",
                      "additionalProperties": false,
                      "type": "object",
                      "required": [
                        "statusCode",
                        "error",
                        "message"
                      ],
                      "properties": {
                        "statusCode": {
                          "type": "number"
                        },
                        "error": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "code": {
                          "type": "string",
                          "enum": [
                            "SCOPE_TEAM_REQUIRED"
                          ]
                        }
                      }
                    },
                    {
                      "type": "object",
                      "required": [
                        "statusCode",
                        "error",
                        "message"
                      ],
                      "properties": {
                        "statusCode": {
                          "type": "number"
                        },
                        "error": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/tracker-cloaker/forms/{id}": {
      "get": {
        "operationId": "getApiV1TrackerCloakerFormsById",
        "summary": "Get a Tracker & Cloaker form",
        "tags": [
          "tracker-cloaker"
        ],
        "description": "Returns details for a specific form.",
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "id",
                    "teamId",
                    "advertiserId",
                    "productId",
                    "name",
                    "fields",
                    "theme",
                    "smsEnabled",
                    "smsTemplate",
                    "smsTriggerStatuses",
                    "phoneValidationEnabled",
                    "phoneCountryCode",
                    "includeFingerprint",
                    "tyLandingId",
                    "status",
                    "createdAt",
                    "updatedAt"
                  ],
                  "properties": {
                    "id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "teamId": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "advertiserId": {
                      "anyOf": [
                        {
                          "format": "uuid",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "productId": {
                      "anyOf": [
                        {
                          "format": "uuid",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "name": {
                      "type": "string"
                    },
                    "fields": {
                      "anyOf": [
                        {
                          "type": "array",
                          "items": {
                            "additionalProperties": true,
                            "type": "object",
                            "required": [
                              "key",
                              "label",
                              "type"
                            ],
                            "properties": {
                              "key": {
                                "type": "string"
                              },
                              "label": {
                                "type": "string"
                              },
                              "type": {
                                "type": "string"
                              },
                              "required": {
                                "type": "boolean"
                              },
                              "placeholder": {
                                "anyOf": [
                                  {
                                    "type": "string"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "options": {
                                "type": "array",
                                "items": {
                                  "type": "string"
                                }
                              }
                            }
                          }
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "theme": {
                      "anyOf": [
                        {
                          "description": "JSON object with nested arrays and objects.",
                          "type": "object",
                          "additionalProperties": {
                            "$comment": "json-value",
                            "description": "Arbitrary JSON value with nested arrays and objects."
                          }
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "smsEnabled": {
                      "type": "boolean"
                    },
                    "smsTemplate": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "smsTriggerStatuses": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "phoneValidationEnabled": {
                      "type": "boolean"
                    },
                    "phoneCountryCode": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "includeFingerprint": {
                      "type": "boolean"
                    },
                    "tyLandingId": {
                      "anyOf": [
                        {
                          "format": "uuid",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "status": {
                      "type": "string"
                    },
                    "createdAt": {
                      "format": "date-time",
                      "type": "string"
                    },
                    "updatedAt": {
                      "anyOf": [
                        {
                          "format": "date-time",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      },
      "put": {
        "operationId": "putApiV1TrackerCloakerFormsById",
        "summary": "Update a Tracker & Cloaker form",
        "tags": [
          "tracker-cloaker"
        ],
        "description": "Updates an existing form.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "properties": {
                  "name": {
                    "minLength": 1,
                    "maxLength": 200,
                    "type": "string"
                  },
                  "advertiser_id": {
                    "anyOf": [
                      {
                        "format": "uuid",
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "product_id": {
                    "anyOf": [
                      {
                        "format": "uuid",
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "fields": {
                    "anyOf": [
                      {
                        "maxItems": 60,
                        "type": "array",
                        "items": {
                          "anyOf": [
                            {
                              "additionalProperties": false,
                              "type": "object",
                              "required": [
                                "label",
                                "type",
                                "key"
                              ],
                              "properties": {
                                "label": {
                                  "maxLength": 200,
                                  "type": "string"
                                },
                                "type": {
                                  "anyOf": [
                                    {
                                      "type": "string",
                                      "enum": [
                                        "text"
                                      ]
                                    },
                                    {
                                      "type": "string",
                                      "enum": [
                                        "email"
                                      ]
                                    },
                                    {
                                      "type": "string",
                                      "enum": [
                                        "tel"
                                      ]
                                    },
                                    {
                                      "type": "string",
                                      "enum": [
                                        "number"
                                      ]
                                    },
                                    {
                                      "type": "string",
                                      "enum": [
                                        "textarea"
                                      ]
                                    },
                                    {
                                      "type": "string",
                                      "enum": [
                                        "select"
                                      ]
                                    },
                                    {
                                      "type": "string",
                                      "enum": [
                                        "checkbox"
                                      ]
                                    },
                                    {
                                      "type": "string",
                                      "enum": [
                                        "hidden"
                                      ]
                                    }
                                  ]
                                },
                                "required": {
                                  "type": "boolean"
                                },
                                "placeholder": {
                                  "anyOf": [
                                    {
                                      "maxLength": 500,
                                      "type": "string"
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "options": {
                                  "maxItems": 100,
                                  "type": "array",
                                  "items": {
                                    "maxLength": 500,
                                    "type": "string"
                                  }
                                },
                                "key": {
                                  "minLength": 1,
                                  "maxLength": 64,
                                  "pattern": "^[A-Za-z_][A-Za-z0-9_]{0,63}$",
                                  "type": "string"
                                },
                                "name": {
                                  "minLength": 1,
                                  "maxLength": 64,
                                  "pattern": "^[A-Za-z_][A-Za-z0-9_]{0,63}$",
                                  "type": "string"
                                },
                                "id": {
                                  "minLength": 1,
                                  "maxLength": 64,
                                  "pattern": "^[A-Za-z_][A-Za-z0-9_]{0,63}$",
                                  "type": "string"
                                }
                              }
                            },
                            {
                              "additionalProperties": false,
                              "type": "object",
                              "required": [
                                "label",
                                "type",
                                "name"
                              ],
                              "properties": {
                                "label": {
                                  "maxLength": 200,
                                  "type": "string"
                                },
                                "type": {
                                  "anyOf": [
                                    {
                                      "type": "string",
                                      "enum": [
                                        "text"
                                      ]
                                    },
                                    {
                                      "type": "string",
                                      "enum": [
                                        "email"
                                      ]
                                    },
                                    {
                                      "type": "string",
                                      "enum": [
                                        "tel"
                                      ]
                                    },
                                    {
                                      "type": "string",
                                      "enum": [
                                        "number"
                                      ]
                                    },
                                    {
                                      "type": "string",
                                      "enum": [
                                        "textarea"
                                      ]
                                    },
                                    {
                                      "type": "string",
                                      "enum": [
                                        "select"
                                      ]
                                    },
                                    {
                                      "type": "string",
                                      "enum": [
                                        "checkbox"
                                      ]
                                    },
                                    {
                                      "type": "string",
                                      "enum": [
                                        "hidden"
                                      ]
                                    }
                                  ]
                                },
                                "required": {
                                  "type": "boolean"
                                },
                                "placeholder": {
                                  "anyOf": [
                                    {
                                      "maxLength": 500,
                                      "type": "string"
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "options": {
                                  "maxItems": 100,
                                  "type": "array",
                                  "items": {
                                    "maxLength": 500,
                                    "type": "string"
                                  }
                                },
                                "name": {
                                  "minLength": 1,
                                  "maxLength": 64,
                                  "pattern": "^[A-Za-z_][A-Za-z0-9_]{0,63}$",
                                  "type": "string"
                                },
                                "key": {
                                  "minLength": 1,
                                  "maxLength": 64,
                                  "pattern": "^[A-Za-z_][A-Za-z0-9_]{0,63}$",
                                  "type": "string"
                                },
                                "id": {
                                  "minLength": 1,
                                  "maxLength": 64,
                                  "pattern": "^[A-Za-z_][A-Za-z0-9_]{0,63}$",
                                  "type": "string"
                                }
                              }
                            },
                            {
                              "additionalProperties": false,
                              "type": "object",
                              "required": [
                                "label",
                                "type",
                                "id"
                              ],
                              "properties": {
                                "label": {
                                  "maxLength": 200,
                                  "type": "string"
                                },
                                "type": {
                                  "anyOf": [
                                    {
                                      "type": "string",
                                      "enum": [
                                        "text"
                                      ]
                                    },
                                    {
                                      "type": "string",
                                      "enum": [
                                        "email"
                                      ]
                                    },
                                    {
                                      "type": "string",
                                      "enum": [
                                        "tel"
                                      ]
                                    },
                                    {
                                      "type": "string",
                                      "enum": [
                                        "number"
                                      ]
                                    },
                                    {
                                      "type": "string",
                                      "enum": [
                                        "textarea"
                                      ]
                                    },
                                    {
                                      "type": "string",
                                      "enum": [
                                        "select"
                                      ]
                                    },
                                    {
                                      "type": "string",
                                      "enum": [
                                        "checkbox"
                                      ]
                                    },
                                    {
                                      "type": "string",
                                      "enum": [
                                        "hidden"
                                      ]
                                    }
                                  ]
                                },
                                "required": {
                                  "type": "boolean"
                                },
                                "placeholder": {
                                  "anyOf": [
                                    {
                                      "maxLength": 500,
                                      "type": "string"
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "options": {
                                  "maxItems": 100,
                                  "type": "array",
                                  "items": {
                                    "maxLength": 500,
                                    "type": "string"
                                  }
                                },
                                "id": {
                                  "minLength": 1,
                                  "maxLength": 64,
                                  "pattern": "^[A-Za-z_][A-Za-z0-9_]{0,63}$",
                                  "type": "string"
                                },
                                "key": {
                                  "minLength": 1,
                                  "maxLength": 64,
                                  "pattern": "^[A-Za-z_][A-Za-z0-9_]{0,63}$",
                                  "type": "string"
                                },
                                "name": {
                                  "minLength": 1,
                                  "maxLength": 64,
                                  "pattern": "^[A-Za-z_][A-Za-z0-9_]{0,63}$",
                                  "type": "string"
                                }
                              }
                            }
                          ]
                        }
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "theme": {
                    "anyOf": [
                      {
                        "description": "JSON object with nested arrays and objects.",
                        "type": "object",
                        "additionalProperties": {
                          "$comment": "json-value",
                          "description": "Arbitrary JSON value with nested arrays and objects."
                        }
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "sms_enabled": {
                    "type": "boolean"
                  },
                  "sms_template": {
                    "anyOf": [
                      {
                        "maxLength": 1000,
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "sms_trigger_statuses": {
                    "anyOf": [
                      {
                        "type": "array",
                        "items": {
                          "maxLength": 40,
                          "type": "string"
                        }
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "phone_validation_enabled": {
                    "type": "boolean"
                  },
                  "phone_country_code": {
                    "anyOf": [
                      {
                        "maxLength": 2,
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "include_fingerprint": {
                    "type": "boolean"
                  },
                  "ty_landing_id": {
                    "anyOf": [
                      {
                        "format": "uuid",
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "status": {
                    "anyOf": [
                      {
                        "type": "string",
                        "enum": [
                          "active"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "paused"
                        ]
                      }
                    ]
                  },
                  "redirect_url": {
                    "anyOf": [
                      {
                        "format": "uri",
                        "maxLength": 2048,
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "success_message": {
                    "anyOf": [
                      {
                        "maxLength": 2000,
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          },
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "header",
            "name": "x-team-id",
            "required": false,
            "description": "Destination workspace team id."
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "id",
                    "teamId",
                    "advertiserId",
                    "productId",
                    "name",
                    "fields",
                    "theme",
                    "smsEnabled",
                    "smsTemplate",
                    "smsTriggerStatuses",
                    "phoneValidationEnabled",
                    "phoneCountryCode",
                    "includeFingerprint",
                    "tyLandingId",
                    "status",
                    "createdAt",
                    "updatedAt"
                  ],
                  "properties": {
                    "id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "teamId": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "advertiserId": {
                      "anyOf": [
                        {
                          "format": "uuid",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "productId": {
                      "anyOf": [
                        {
                          "format": "uuid",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "name": {
                      "type": "string"
                    },
                    "fields": {
                      "anyOf": [
                        {
                          "type": "array",
                          "items": {
                            "additionalProperties": true,
                            "type": "object",
                            "required": [
                              "key",
                              "label",
                              "type"
                            ],
                            "properties": {
                              "key": {
                                "type": "string"
                              },
                              "label": {
                                "type": "string"
                              },
                              "type": {
                                "type": "string"
                              },
                              "required": {
                                "type": "boolean"
                              },
                              "placeholder": {
                                "anyOf": [
                                  {
                                    "type": "string"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "options": {
                                "type": "array",
                                "items": {
                                  "type": "string"
                                }
                              }
                            }
                          }
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "theme": {
                      "anyOf": [
                        {
                          "description": "JSON object with nested arrays and objects.",
                          "type": "object",
                          "additionalProperties": {
                            "$comment": "json-value",
                            "description": "Arbitrary JSON value with nested arrays and objects."
                          }
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "smsEnabled": {
                      "type": "boolean"
                    },
                    "smsTemplate": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "smsTriggerStatuses": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "phoneValidationEnabled": {
                      "type": "boolean"
                    },
                    "phoneCountryCode": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "includeFingerprint": {
                      "type": "boolean"
                    },
                    "tyLandingId": {
                      "anyOf": [
                        {
                          "format": "uuid",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "status": {
                      "type": "string"
                    },
                    "createdAt": {
                      "format": "date-time",
                      "type": "string"
                    },
                    "updatedAt": {
                      "anyOf": [
                        {
                          "format": "date-time",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "anyOf": [
                    {
                      "description": "Explicit destination workspace required: send the x-team-id header or activate a team scope for this operation.",
                      "additionalProperties": false,
                      "type": "object",
                      "required": [
                        "statusCode",
                        "error",
                        "message"
                      ],
                      "properties": {
                        "statusCode": {
                          "type": "number"
                        },
                        "error": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "code": {
                          "type": "string",
                          "enum": [
                            "SCOPE_TEAM_REQUIRED"
                          ]
                        }
                      }
                    },
                    {
                      "type": "object",
                      "required": [
                        "statusCode",
                        "error",
                        "message"
                      ],
                      "properties": {
                        "statusCode": {
                          "type": "number"
                        },
                        "error": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      },
      "delete": {
        "operationId": "deleteApiV1TrackerCloakerFormsById",
        "summary": "Delete a Tracker & Cloaker form",
        "tags": [
          "tracker-cloaker"
        ],
        "description": "Soft-deletes a form by setting its status to archived.",
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          },
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "header",
            "name": "x-team-id",
            "required": false,
            "description": "Destination workspace team id."
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "deleted"
                  ],
                  "properties": {
                    "deleted": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Explicit destination workspace required: send the x-team-id header or activate a team scope for this operation.",
            "content": {
              "application/json": {
                "schema": {
                  "description": "Explicit destination workspace required: send the x-team-id header or activate a team scope for this operation.",
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "SCOPE_TEAM_REQUIRED"
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/tracker-cloaker/forms/{id}/leads": {
      "get": {
        "operationId": "getApiV1TrackerCloakerFormsByIdLeads",
        "summary": "List leads for a Tracker & Cloaker form",
        "tags": [
          "tracker-cloaker"
        ],
        "description": "Returns captured leads for a specific form, newest first.",
        "parameters": [
          {
            "schema": {
              "maxLength": 40,
              "type": "string"
            },
            "in": "query",
            "name": "status",
            "required": false
          },
          {
            "schema": {
              "minimum": 1,
              "maximum": 500,
              "type": "integer"
            },
            "in": "query",
            "name": "limit",
            "required": false
          },
          {
            "schema": {
              "minimum": 0,
              "type": "integer"
            },
            "in": "query",
            "name": "offset",
            "required": false
          },
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "items",
                    "total"
                  ],
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "id",
                          "teamId",
                          "formId",
                          "clickId",
                          "data",
                          "status",
                          "advertiserResponse",
                          "createdAt"
                        ],
                        "properties": {
                          "id": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "teamId": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "formId": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "clickId": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "data": {
                            "anyOf": [
                              {
                                "type": "object",
                                "additionalProperties": {
                                  "$comment": "json-value"
                                }
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "status": {
                            "type": "string"
                          },
                          "advertiserResponse": {
                            "anyOf": [
                              {
                                "additionalProperties": true,
                                "type": "object",
                                "required": [
                                  "ok",
                                  "status",
                                  "response",
                                  "error"
                                ],
                                "properties": {
                                  "ok": {
                                    "type": "boolean"
                                  },
                                  "status": {
                                    "anyOf": [
                                      {
                                        "type": "number"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "response": {
                                    "anyOf": [
                                      {
                                        "type": "string"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "error": {
                                    "anyOf": [
                                      {
                                        "type": "string"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  }
                                }
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "createdAt": {
                            "format": "date-time",
                            "type": "string"
                          }
                        }
                      }
                    },
                    "total": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/tracker-cloaker/forms/{id}/leads/export": {
      "get": {
        "operationId": "getApiV1TrackerCloakerFormsByIdLeadsExport",
        "summary": "Export leads for a Tracker & Cloaker form as CSV",
        "tags": [
          "tracker-cloaker"
        ],
        "description": "Returns a form's captured leads as a CSV download. Columns are built dynamically from the union of lead.data keys, plus created_at and status. Capped at 50k rows.",
        "parameters": [
          {
            "schema": {
              "maxLength": 40,
              "type": "string"
            },
            "in": "query",
            "name": "status",
            "required": false
          },
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/tracker-cloaker/integrations/meta/status": {
      "get": {
        "operationId": "getApiV1TrackerCloakerIntegrationsMetaStatus",
        "summary": "Meta integration connection status",
        "tags": [
          "tracker-cloaker"
        ],
        "description": "Returns whether a Meta access token is configured (stored setting or env) and, best-effort, the connected account name from Graph /me.",
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "query",
            "name": "team_id",
            "required": false
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "connected"
                  ],
                  "properties": {
                    "connected": {
                      "type": "boolean"
                    },
                    "name": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/tracker-cloaker/integrations/meta/ad-accounts": {
      "get": {
        "operationId": "getApiV1TrackerCloakerIntegrationsMetaAdAccounts",
        "summary": "List Meta ad accounts",
        "tags": [
          "tracker-cloaker"
        ],
        "description": "Calls Graph /me/adaccounts with the configured token. Returns an EMPTY array when no token, none available, or on any Meta error — never fails.",
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "query",
            "name": "team_id",
            "required": false
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "items"
                  ],
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "account_id",
                          "name"
                        ],
                        "properties": {
                          "account_id": {
                            "type": "string"
                          },
                          "name": {
                            "type": "string"
                          },
                          "currency": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "timezone": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "account_status": {
                            "anyOf": [
                              {
                                "type": "number"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "lifetime_spend": {
                            "anyOf": [
                              {
                                "type": "number"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "excluded": {
                            "type": "boolean"
                          },
                          "excluded_reason": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "last_synced_at": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/tracker-cloaker/integrations/meta/pixels": {
      "get": {
        "operationId": "getApiV1TrackerCloakerIntegrationsMetaPixels",
        "summary": "List Meta pixels",
        "tags": [
          "tracker-cloaker"
        ],
        "description": "Calls Graph /act_<id>/adspixels for each connected ad account and returns the deduped pixels. Returns an EMPTY array when no token, none available, or on any Meta error — never fails.",
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "query",
            "name": "team_id",
            "required": false
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "items"
                  ],
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "account_id",
                          "id",
                          "name"
                        ],
                        "properties": {
                          "account_id": {
                            "type": "string"
                          },
                          "id": {
                            "type": "string"
                          },
                          "name": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/tracker-cloaker/integrations/meta/sync-accounts": {
      "post": {
        "operationId": "postApiV1TrackerCloakerIntegrationsMetaSyncAccounts",
        "summary": "Sync Meta ad accounts",
        "tags": [
          "tracker-cloaker"
        ],
        "description": "Fetches /me/adaccounts and upserts ad accounts (currency/timezone/status). Accounts that disappear are marked excluded (meta_disabled).",
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "query",
            "name": "team_id",
            "required": false
          },
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "header",
            "name": "x-team-id",
            "required": false,
            "description": "Destination workspace team id."
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "ok",
                    "synced",
                    "items"
                  ],
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    },
                    "synced": {
                      "type": "number"
                    },
                    "reason": {
                      "type": "string"
                    },
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "account_id",
                          "name"
                        ],
                        "properties": {
                          "account_id": {
                            "type": "string"
                          },
                          "name": {
                            "type": "string"
                          },
                          "currency": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "timezone": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "account_status": {
                            "anyOf": [
                              {
                                "type": "number"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "lifetime_spend": {
                            "anyOf": [
                              {
                                "type": "number"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "excluded": {
                            "type": "boolean"
                          },
                          "excluded_reason": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "last_synced_at": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Explicit destination workspace required: send the x-team-id header or activate a team scope for this operation.",
            "content": {
              "application/json": {
                "schema": {
                  "description": "Explicit destination workspace required: send the x-team-id header or activate a team scope for this operation.",
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "SCOPE_TEAM_REQUIRED"
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/tracker-cloaker/integrations/meta/test": {
      "post": {
        "operationId": "postApiV1TrackerCloakerIntegrationsMetaTest",
        "summary": "Test Meta connection",
        "tags": [
          "tracker-cloaker"
        ],
        "description": "Round-trips Graph /me with the stored token and returns the connected id + name.",
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "query",
            "name": "team_id",
            "required": false
          },
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "header",
            "name": "x-team-id",
            "required": false,
            "description": "Destination workspace team id."
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "ok"
                  ],
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    },
                    "id": {
                      "type": "string"
                    },
                    "name": {
                      "type": "string"
                    },
                    "reason": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Explicit destination workspace required: send the x-team-id header or activate a team scope for this operation.",
            "content": {
              "application/json": {
                "schema": {
                  "description": "Explicit destination workspace required: send the x-team-id header or activate a team scope for this operation.",
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "SCOPE_TEAM_REQUIRED"
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/tracker-cloaker/integrations/meta/ad-accounts/{accountId}/exclude": {
      "post": {
        "operationId": "postApiV1TrackerCloakerIntegrationsMetaAdAccountsByAccountIdExclude",
        "summary": "Exclude a Meta ad account from spend pull",
        "tags": [
          "tracker-cloaker"
        ],
        "description": "Exclude a Meta ad account from spend attribution for this team.",
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "query",
            "name": "team_id",
            "required": false
          },
          {
            "schema": {
              "minLength": 1,
              "maxLength": 100,
              "type": "string"
            },
            "in": "path",
            "name": "accountId",
            "required": true
          },
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "header",
            "name": "x-team-id",
            "required": false,
            "description": "Destination workspace team id."
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "ok"
                  ],
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Explicit destination workspace required: send the x-team-id header or activate a team scope for this operation.",
            "content": {
              "application/json": {
                "schema": {
                  "description": "Explicit destination workspace required: send the x-team-id header or activate a team scope for this operation.",
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "SCOPE_TEAM_REQUIRED"
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/tracker-cloaker/integrations/meta/ad-accounts/{accountId}/restore": {
      "post": {
        "operationId": "postApiV1TrackerCloakerIntegrationsMetaAdAccountsByAccountIdRestore",
        "summary": "Restore a previously excluded Meta ad account",
        "tags": [
          "tracker-cloaker"
        ],
        "description": "Restore a previously excluded Meta ad account.",
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "query",
            "name": "team_id",
            "required": false
          },
          {
            "schema": {
              "minLength": 1,
              "maxLength": 100,
              "type": "string"
            },
            "in": "path",
            "name": "accountId",
            "required": true
          },
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "header",
            "name": "x-team-id",
            "required": false,
            "description": "Destination workspace team id."
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "ok"
                  ],
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Explicit destination workspace required: send the x-team-id header or activate a team scope for this operation.",
            "content": {
              "application/json": {
                "schema": {
                  "description": "Explicit destination workspace required: send the x-team-id header or activate a team scope for this operation.",
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "SCOPE_TEAM_REQUIRED"
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/tracker-cloaker/integrations/meta/connect": {
      "post": {
        "operationId": "postApiV1TrackerCloakerIntegrationsMetaConnect",
        "summary": "Connect Meta by storing an access token",
        "tags": [
          "tracker-cloaker"
        ],
        "description": "Stores the access token in tc_app_setting key 'meta_access_token' (encrypted/masked) and returns the resulting connection status.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "token"
                ],
                "properties": {
                  "token": {
                    "minLength": 1,
                    "maxLength": 4096,
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "query",
            "name": "team_id",
            "required": false
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "connected"
                  ],
                  "properties": {
                    "connected": {
                      "type": "boolean"
                    },
                    "name": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "anyOf": [
                    {
                      "description": "Explicit destination workspace required: send the x-team-id header or activate a team scope for this operation.",
                      "additionalProperties": false,
                      "type": "object",
                      "required": [
                        "statusCode",
                        "error",
                        "message"
                      ],
                      "properties": {
                        "statusCode": {
                          "type": "number"
                        },
                        "error": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "code": {
                          "type": "string",
                          "enum": [
                            "SCOPE_TEAM_REQUIRED"
                          ]
                        }
                      }
                    },
                    {
                      "type": "object",
                      "required": [
                        "statusCode",
                        "error",
                        "message"
                      ],
                      "properties": {
                        "statusCode": {
                          "type": "number"
                        },
                        "error": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/tracker-cloaker/integrations/meta/mappings": {
      "get": {
        "operationId": "getApiV1TrackerCloakerIntegrationsMetaMappings",
        "summary": "List Meta campaign mappings",
        "tags": [
          "tracker-cloaker"
        ],
        "description": "Returns the team-scoped tc_meta_mapping rows (tc campaign -> Meta ad account / campaign).",
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "query",
            "name": "team_id",
            "required": false
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "items"
                  ],
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "id",
                          "campaign_id",
                          "meta_ad_account_id",
                          "meta_campaign_id",
                          "meta_campaign_name",
                          "created_at"
                        ],
                        "properties": {
                          "id": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "campaign_id": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "meta_ad_account_id": {
                            "type": "string"
                          },
                          "meta_campaign_id": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "meta_campaign_name": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "created_at": {
                            "format": "date-time",
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "postApiV1TrackerCloakerIntegrationsMetaMappings",
        "summary": "Create a Meta campaign mapping",
        "tags": [
          "tracker-cloaker"
        ],
        "description": "Maps a tc campaign to a Meta ad account (and optionally a Meta campaign).",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "campaign_id",
                  "meta_ad_account_id"
                ],
                "properties": {
                  "campaign_id": {
                    "format": "uuid",
                    "type": "string"
                  },
                  "meta_ad_account_id": {
                    "minLength": 1,
                    "maxLength": 100,
                    "type": "string"
                  },
                  "meta_campaign_id": {
                    "anyOf": [
                      {
                        "maxLength": 100,
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "meta_campaign_name": {
                    "anyOf": [
                      {
                        "maxLength": 300,
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "query",
            "name": "team_id",
            "required": false
          },
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "header",
            "name": "x-team-id",
            "required": false,
            "description": "Destination workspace team id."
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "201": {
            "description": "Resource created",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "id",
                    "campaign_id",
                    "meta_ad_account_id",
                    "meta_campaign_id",
                    "meta_campaign_name",
                    "created_at"
                  ],
                  "properties": {
                    "id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "campaign_id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "meta_ad_account_id": {
                      "type": "string"
                    },
                    "meta_campaign_id": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "meta_campaign_name": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "created_at": {
                      "format": "date-time",
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "anyOf": [
                    {
                      "description": "Explicit destination workspace required: send the x-team-id header or activate a team scope for this operation.",
                      "additionalProperties": false,
                      "type": "object",
                      "required": [
                        "statusCode",
                        "error",
                        "message"
                      ],
                      "properties": {
                        "statusCode": {
                          "type": "number"
                        },
                        "error": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "code": {
                          "type": "string",
                          "enum": [
                            "SCOPE_TEAM_REQUIRED"
                          ]
                        }
                      }
                    },
                    {
                      "type": "object",
                      "required": [
                        "statusCode",
                        "error",
                        "message"
                      ],
                      "properties": {
                        "statusCode": {
                          "type": "number"
                        },
                        "error": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "Conflict - resource state prevents the operation",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/tracker-cloaker/integrations/meta/mappings/{id}": {
      "delete": {
        "operationId": "deleteApiV1TrackerCloakerIntegrationsMetaMappingsById",
        "summary": "Delete a Meta campaign mapping",
        "tags": [
          "tracker-cloaker"
        ],
        "description": "Removes a team-scoped tc_meta_mapping row by id.",
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "query",
            "name": "team_id",
            "required": false
          },
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          },
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "header",
            "name": "x-team-id",
            "required": false,
            "description": "Destination workspace team id."
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "ok"
                  ],
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Explicit destination workspace required: send the x-team-id header or activate a team scope for this operation.",
            "content": {
              "application/json": {
                "schema": {
                  "description": "Explicit destination workspace required: send the x-team-id header or activate a team scope for this operation.",
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "SCOPE_TEAM_REQUIRED"
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/tracker-cloaker/integrations/meta/spend-pull": {
      "post": {
        "operationId": "postApiV1TrackerCloakerIntegrationsMetaSpendPull",
        "summary": "Pull Meta spend",
        "tags": [
          "tracker-cloaker"
        ],
        "description": "Fetches /insights per mapped ad account and upserts daily cost onto tc_stats_daily. Defaults to a rolling 3-day window; accepts an explicit since/until (YYYY-MM-DD) backfill range. Degrades gracefully — never 500s.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "properties": {
                  "since": {
                    "minLength": 10,
                    "maxLength": 10,
                    "type": "string"
                  },
                  "until": {
                    "minLength": 10,
                    "maxLength": 10,
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "query",
            "name": "team_id",
            "required": false
          },
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "header",
            "name": "x-team-id",
            "required": false,
            "description": "Destination workspace team id."
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "ok",
                    "skipped"
                  ],
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    },
                    "skipped": {
                      "type": "boolean"
                    },
                    "reason": {
                      "type": "string"
                    },
                    "accounts": {
                      "type": "number"
                    },
                    "rows": {
                      "type": "number"
                    },
                    "failures": {
                      "type": "number"
                    },
                    "since": {
                      "type": "string"
                    },
                    "until": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "anyOf": [
                    {
                      "description": "Explicit destination workspace required: send the x-team-id header or activate a team scope for this operation.",
                      "additionalProperties": false,
                      "type": "object",
                      "required": [
                        "statusCode",
                        "error",
                        "message"
                      ],
                      "properties": {
                        "statusCode": {
                          "type": "number"
                        },
                        "error": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "code": {
                          "type": "string",
                          "enum": [
                            "SCOPE_TEAM_REQUIRED"
                          ]
                        }
                      }
                    },
                    {
                      "type": "object",
                      "required": [
                        "statusCode",
                        "error",
                        "message"
                      ],
                      "properties": {
                        "statusCode": {
                          "type": "number"
                        },
                        "error": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "Conflict - resource state prevents the operation",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/tracker-cloaker/integrations/meta/spend-pull/status": {
      "get": {
        "operationId": "getApiV1TrackerCloakerIntegrationsMetaSpendPullStatus",
        "summary": "Meta spend pull status",
        "tags": [
          "tracker-cloaker"
        ],
        "description": "Returns whether a spend pull is running plus stats from the last completed run.",
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "query",
            "name": "team_id",
            "required": false
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "running",
                    "last"
                  ],
                  "properties": {
                    "running": {
                      "type": "boolean"
                    },
                    "last": {
                      "anyOf": [
                        {
                          "type": "object",
                          "required": [
                            "ok",
                            "accounts",
                            "rows",
                            "failures",
                            "since",
                            "until",
                            "finishedAt"
                          ],
                          "properties": {
                            "ok": {
                              "type": "boolean"
                            },
                            "accounts": {
                              "type": "number"
                            },
                            "rows": {
                              "type": "number"
                            },
                            "failures": {
                              "type": "number"
                            },
                            "since": {
                              "anyOf": [
                                {
                                  "type": "string"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "until": {
                              "anyOf": [
                                {
                                  "type": "string"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "finishedAt": {
                              "type": "string"
                            }
                          }
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/tracker-cloaker/landing-pages/{id}/bundle": {
      "post": {
        "operationId": "postApiV1TrackerCloakerLandingPagesByIdBundle",
        "summary": "Upload a landing page bundle (folder or ZIP)",
        "tags": [
          "tracker-cloaker"
        ],
        "description": "Accepts either a ZIP archive or the individual files of a folder (each part named with its bundle-relative path) and publishes them as the landing page's next bundle version. The files are then served from /tc/lp/{id}/v{version}/, so a re-upload never has to invalidate a cache.",
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          },
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "header",
            "name": "x-team-id",
            "required": false,
            "description": "Destination workspace team id."
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "201": {
            "description": "Resource created",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "version",
                    "entry_file",
                    "file_count",
                    "total_bytes"
                  ],
                  "properties": {
                    "version": {
                      "type": "number"
                    },
                    "entry_file": {
                      "type": "string"
                    },
                    "file_count": {
                      "type": "number"
                    },
                    "total_bytes": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Explicit destination workspace required: send the x-team-id header or activate a team scope for this operation.",
            "content": {
              "application/json": {
                "schema": {
                  "description": "Explicit destination workspace required: send the x-team-id header or activate a team scope for this operation.",
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "SCOPE_TEAM_REQUIRED"
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "413": {
            "description": "Payload too large",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "415": {
            "description": "Response 415",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "422": {
            "description": "Unprocessable entity - semantic validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/tracker-cloaker/landing-pages": {
      "get": {
        "operationId": "getApiV1TrackerCloakerLandingPages",
        "summary": "List Tracker & Cloaker landing pages",
        "tags": [
          "tracker-cloaker"
        ],
        "description": "Returns landing pages for the current team. Archived pages are hidden by default; pass an explicit status filter to select a specific state.",
        "parameters": [
          {
            "schema": {
              "maxLength": 50,
              "type": "string"
            },
            "in": "query",
            "name": "type",
            "required": false
          },
          {
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "enum": [
                    "active"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "paused"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "archived"
                  ]
                }
              ]
            },
            "in": "query",
            "name": "status",
            "required": false
          },
          {
            "schema": {
              "maxLength": 200,
              "type": "string"
            },
            "in": "query",
            "name": "search",
            "required": false
          },
          {
            "schema": {
              "minimum": 1,
              "maximum": 100,
              "type": "integer"
            },
            "in": "query",
            "name": "limit",
            "required": false
          },
          {
            "schema": {
              "minimum": 0,
              "type": "integer"
            },
            "in": "query",
            "name": "offset",
            "required": false
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "items",
                    "total"
                  ],
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "id",
                          "name",
                          "type",
                          "html",
                          "external_url",
                          "original_url",
                          "template_id",
                          "template_vars",
                          "status",
                          "category",
                          "tags",
                          "created_at",
                          "updated_at"
                        ],
                        "properties": {
                          "id": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "name": {
                            "type": "string"
                          },
                          "type": {
                            "type": "string"
                          },
                          "html": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "external_url": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "original_url": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "template_id": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "template_vars": {
                            "anyOf": [
                              {
                                "$comment": "json-value",
                                "description": "Arbitrary JSON value with nested arrays and objects."
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "status": {
                            "anyOf": [
                              {
                                "type": "string",
                                "enum": [
                                  "active"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "paused"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "archived"
                                ]
                              }
                            ]
                          },
                          "category": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "tags": {
                            "anyOf": [
                              {
                                "$comment": "json-value",
                                "description": "Arbitrary JSON value with nested arrays and objects."
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "created_at": {
                            "format": "date-time",
                            "type": "string"
                          },
                          "updated_at": {
                            "anyOf": [
                              {
                                "format": "date-time",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          }
                        }
                      }
                    },
                    "total": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "postApiV1TrackerCloakerLandingPages",
        "summary": "Create a Tracker & Cloaker landing page",
        "tags": [
          "tracker-cloaker"
        ],
        "description": "Creates a new landing page for the current team.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "name"
                ],
                "properties": {
                  "name": {
                    "minLength": 1,
                    "maxLength": 200,
                    "type": "string"
                  },
                  "type": {
                    "maxLength": 50,
                    "type": "string"
                  },
                  "html": {
                    "anyOf": [
                      {
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "external_url": {
                    "anyOf": [
                      {
                        "format": "uri",
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "original_url": {
                    "anyOf": [
                      {
                        "format": "uri",
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "template_id": {
                    "anyOf": [
                      {
                        "maxLength": 200,
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "template_vars": {
                    "description": "JSON object with nested arrays and objects.",
                    "type": "object",
                    "additionalProperties": {
                      "$comment": "json-value",
                      "description": "Arbitrary JSON value with nested arrays and objects."
                    }
                  },
                  "status": {
                    "anyOf": [
                      {
                        "type": "string",
                        "enum": [
                          "active"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "paused"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "archived"
                        ]
                      }
                    ]
                  },
                  "category": {
                    "anyOf": [
                      {
                        "maxLength": 200,
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "tags": {
                    "$comment": "json-value",
                    "description": "Arbitrary JSON value with nested arrays and objects."
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "header",
            "name": "x-team-id",
            "required": false,
            "description": "Destination workspace team id."
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "201": {
            "description": "Resource created",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "id",
                    "name",
                    "type",
                    "html",
                    "external_url",
                    "original_url",
                    "template_id",
                    "template_vars",
                    "status",
                    "category",
                    "tags",
                    "created_at",
                    "updated_at"
                  ],
                  "properties": {
                    "id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "name": {
                      "type": "string"
                    },
                    "type": {
                      "type": "string"
                    },
                    "html": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "external_url": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "original_url": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "template_id": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "template_vars": {
                      "anyOf": [
                        {
                          "$comment": "json-value",
                          "description": "Arbitrary JSON value with nested arrays and objects."
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "status": {
                      "anyOf": [
                        {
                          "type": "string",
                          "enum": [
                            "active"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "paused"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "archived"
                          ]
                        }
                      ]
                    },
                    "category": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "tags": {
                      "anyOf": [
                        {
                          "$comment": "json-value",
                          "description": "Arbitrary JSON value with nested arrays and objects."
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "created_at": {
                      "format": "date-time",
                      "type": "string"
                    },
                    "updated_at": {
                      "anyOf": [
                        {
                          "format": "date-time",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Explicit destination workspace required: send the x-team-id header or activate a team scope for this operation.",
            "content": {
              "application/json": {
                "schema": {
                  "description": "Explicit destination workspace required: send the x-team-id header or activate a team scope for this operation.",
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "SCOPE_TEAM_REQUIRED"
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/tracker-cloaker/landing-pages/{id}": {
      "get": {
        "operationId": "getApiV1TrackerCloakerLandingPagesById",
        "summary": "Get a Tracker & Cloaker landing page",
        "tags": [
          "tracker-cloaker"
        ],
        "description": "Returns details for a specific landing page.",
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "id",
                    "name",
                    "type",
                    "html",
                    "external_url",
                    "original_url",
                    "template_id",
                    "template_vars",
                    "status",
                    "category",
                    "tags",
                    "created_at",
                    "updated_at"
                  ],
                  "properties": {
                    "id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "name": {
                      "type": "string"
                    },
                    "type": {
                      "type": "string"
                    },
                    "html": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "external_url": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "original_url": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "template_id": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "template_vars": {
                      "anyOf": [
                        {
                          "$comment": "json-value",
                          "description": "Arbitrary JSON value with nested arrays and objects."
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "status": {
                      "anyOf": [
                        {
                          "type": "string",
                          "enum": [
                            "active"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "paused"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "archived"
                          ]
                        }
                      ]
                    },
                    "category": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "tags": {
                      "anyOf": [
                        {
                          "$comment": "json-value",
                          "description": "Arbitrary JSON value with nested arrays and objects."
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "created_at": {
                      "format": "date-time",
                      "type": "string"
                    },
                    "updated_at": {
                      "anyOf": [
                        {
                          "format": "date-time",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      },
      "patch": {
        "operationId": "patchApiV1TrackerCloakerLandingPagesById",
        "summary": "Update a Tracker & Cloaker landing page",
        "tags": [
          "tracker-cloaker"
        ],
        "description": "Updates an existing landing page.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "properties": {
                  "name": {
                    "minLength": 1,
                    "maxLength": 200,
                    "type": "string"
                  },
                  "type": {
                    "maxLength": 50,
                    "type": "string"
                  },
                  "html": {
                    "anyOf": [
                      {
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "external_url": {
                    "anyOf": [
                      {
                        "format": "uri",
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "original_url": {
                    "anyOf": [
                      {
                        "format": "uri",
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "template_id": {
                    "anyOf": [
                      {
                        "maxLength": 200,
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "template_vars": {
                    "description": "JSON object with nested arrays and objects.",
                    "type": "object",
                    "additionalProperties": {
                      "$comment": "json-value",
                      "description": "Arbitrary JSON value with nested arrays and objects."
                    }
                  },
                  "status": {
                    "anyOf": [
                      {
                        "type": "string",
                        "enum": [
                          "active"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "paused"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "archived"
                        ]
                      }
                    ]
                  },
                  "category": {
                    "anyOf": [
                      {
                        "maxLength": 200,
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "tags": {
                    "$comment": "json-value",
                    "description": "Arbitrary JSON value with nested arrays and objects."
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          },
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "header",
            "name": "x-team-id",
            "required": false,
            "description": "Destination workspace team id."
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "id",
                    "name",
                    "type",
                    "html",
                    "external_url",
                    "original_url",
                    "template_id",
                    "template_vars",
                    "status",
                    "category",
                    "tags",
                    "created_at",
                    "updated_at"
                  ],
                  "properties": {
                    "id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "name": {
                      "type": "string"
                    },
                    "type": {
                      "type": "string"
                    },
                    "html": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "external_url": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "original_url": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "template_id": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "template_vars": {
                      "anyOf": [
                        {
                          "$comment": "json-value",
                          "description": "Arbitrary JSON value with nested arrays and objects."
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "status": {
                      "anyOf": [
                        {
                          "type": "string",
                          "enum": [
                            "active"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "paused"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "archived"
                          ]
                        }
                      ]
                    },
                    "category": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "tags": {
                      "anyOf": [
                        {
                          "$comment": "json-value",
                          "description": "Arbitrary JSON value with nested arrays and objects."
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "created_at": {
                      "format": "date-time",
                      "type": "string"
                    },
                    "updated_at": {
                      "anyOf": [
                        {
                          "format": "date-time",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Explicit destination workspace required: send the x-team-id header or activate a team scope for this operation.",
            "content": {
              "application/json": {
                "schema": {
                  "description": "Explicit destination workspace required: send the x-team-id header or activate a team scope for this operation.",
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "SCOPE_TEAM_REQUIRED"
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      },
      "delete": {
        "operationId": "deleteApiV1TrackerCloakerLandingPagesById",
        "summary": "Delete a Tracker & Cloaker landing page",
        "tags": [
          "tracker-cloaker"
        ],
        "description": "Archives a landing page (soft delete via status).",
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          },
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "header",
            "name": "x-team-id",
            "required": false,
            "description": "Destination workspace team id."
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "deleted"
                  ],
                  "properties": {
                    "deleted": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Explicit destination workspace required: send the x-team-id header or activate a team scope for this operation.",
            "content": {
              "application/json": {
                "schema": {
                  "description": "Explicit destination workspace required: send the x-team-id header or activate a team scope for this operation.",
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "SCOPE_TEAM_REQUIRED"
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/tracker-cloaker/landing-pages/import": {
      "post": {
        "operationId": "postApiV1TrackerCloakerLandingPagesImport",
        "summary": "Import a landing page from a URL",
        "tags": [
          "tracker-cloaker"
        ],
        "description": "Fetches the page HTML, rewrites it to stay self-contained, and saves it as an imported landing page.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "url"
                ],
                "properties": {
                  "url": {
                    "format": "uri",
                    "maxLength": 2048,
                    "type": "string"
                  },
                  "name": {
                    "minLength": 1,
                    "maxLength": 200,
                    "type": "string"
                  },
                  "host_assets": {
                    "type": "boolean"
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "header",
            "name": "x-team-id",
            "required": false,
            "description": "Destination workspace team id."
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "201": {
            "description": "Resource created",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "id",
                    "name",
                    "type",
                    "html",
                    "external_url",
                    "original_url",
                    "template_id",
                    "template_vars",
                    "status",
                    "category",
                    "tags",
                    "created_at",
                    "updated_at"
                  ],
                  "properties": {
                    "id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "name": {
                      "type": "string"
                    },
                    "type": {
                      "type": "string"
                    },
                    "html": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "external_url": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "original_url": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "template_id": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "template_vars": {
                      "anyOf": [
                        {
                          "$comment": "json-value",
                          "description": "Arbitrary JSON value with nested arrays and objects."
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "status": {
                      "anyOf": [
                        {
                          "type": "string",
                          "enum": [
                            "active"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "paused"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "archived"
                          ]
                        }
                      ]
                    },
                    "category": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "tags": {
                      "anyOf": [
                        {
                          "$comment": "json-value",
                          "description": "Arbitrary JSON value with nested arrays and objects."
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "created_at": {
                      "format": "date-time",
                      "type": "string"
                    },
                    "updated_at": {
                      "anyOf": [
                        {
                          "format": "date-time",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Explicit destination workspace required: send the x-team-id header or activate a team scope for this operation.",
            "content": {
              "application/json": {
                "schema": {
                  "description": "Explicit destination workspace required: send the x-team-id header or activate a team scope for this operation.",
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "SCOPE_TEAM_REQUIRED"
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "422": {
            "description": "Unprocessable entity - semantic validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/tracker-cloaker/landing-pages/generate-ai": {
      "post": {
        "operationId": "postApiV1TrackerCloakerLandingPagesGenerateAi",
        "summary": "AI-generate a landing page",
        "tags": [
          "tracker-cloaker"
        ],
        "description": "Generates a complete standalone HTML landing page with Anthropic and saves it.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "niche"
                ],
                "properties": {
                  "niche": {
                    "minLength": 1,
                    "maxLength": 200,
                    "type": "string"
                  },
                  "pageType": {
                    "maxLength": 100,
                    "type": "string"
                  },
                  "tone": {
                    "maxLength": 100,
                    "type": "string"
                  },
                  "name": {
                    "minLength": 1,
                    "maxLength": 200,
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "header",
            "name": "x-team-id",
            "required": false,
            "description": "Destination workspace team id."
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "201": {
            "description": "Resource created",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "id",
                    "name",
                    "type",
                    "html",
                    "external_url",
                    "original_url",
                    "template_id",
                    "template_vars",
                    "status",
                    "category",
                    "tags",
                    "created_at",
                    "updated_at"
                  ],
                  "properties": {
                    "id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "name": {
                      "type": "string"
                    },
                    "type": {
                      "type": "string"
                    },
                    "html": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "external_url": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "original_url": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "template_id": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "template_vars": {
                      "anyOf": [
                        {
                          "$comment": "json-value",
                          "description": "Arbitrary JSON value with nested arrays and objects."
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "status": {
                      "anyOf": [
                        {
                          "type": "string",
                          "enum": [
                            "active"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "paused"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "archived"
                          ]
                        }
                      ]
                    },
                    "category": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "tags": {
                      "anyOf": [
                        {
                          "$comment": "json-value",
                          "description": "Arbitrary JSON value with nested arrays and objects."
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "created_at": {
                      "format": "date-time",
                      "type": "string"
                    },
                    "updated_at": {
                      "anyOf": [
                        {
                          "format": "date-time",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Explicit destination workspace required: send the x-team-id header or activate a team scope for this operation.",
            "content": {
              "application/json": {
                "schema": {
                  "description": "Explicit destination workspace required: send the x-team-id header or activate a team scope for this operation.",
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "SCOPE_TEAM_REQUIRED"
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "502": {
            "description": "Bad gateway - upstream provider failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/tracker-cloaker/landing-pages/generate-ecomm": {
      "post": {
        "operationId": "postApiV1TrackerCloakerLandingPagesGenerateEcomm",
        "summary": "Generate an advertorial / e-commerce landing page",
        "tags": [
          "tracker-cloaker"
        ],
        "description": "Builds an advertorial HTML page (hero, price, rating, testimonials, FAQ) with real Pexels imagery and saves it.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "product_name",
                  "headline",
                  "body_text",
                  "cta_text",
                  "cta_url"
                ],
                "properties": {
                  "product_name": {
                    "minLength": 1,
                    "maxLength": 200,
                    "type": "string"
                  },
                  "headline": {
                    "minLength": 1,
                    "maxLength": 300,
                    "type": "string"
                  },
                  "body_text": {
                    "minLength": 1,
                    "maxLength": 8000,
                    "type": "string"
                  },
                  "cta_text": {
                    "minLength": 1,
                    "maxLength": 120,
                    "type": "string"
                  },
                  "cta_url": {
                    "minLength": 1,
                    "maxLength": 2048,
                    "type": "string"
                  },
                  "image_query": {
                    "maxLength": 200,
                    "type": "string"
                  },
                  "image_count": {
                    "minimum": 1,
                    "maximum": 8,
                    "type": "integer"
                  },
                  "price": {
                    "maxLength": 40,
                    "type": "string"
                  },
                  "rating": {
                    "minimum": 0,
                    "maximum": 5,
                    "type": "number"
                  },
                  "name": {
                    "minLength": 1,
                    "maxLength": 200,
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "header",
            "name": "x-team-id",
            "required": false,
            "description": "Destination workspace team id."
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "201": {
            "description": "Resource created",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "id",
                    "name",
                    "type",
                    "html",
                    "external_url",
                    "original_url",
                    "template_id",
                    "template_vars",
                    "status",
                    "category",
                    "tags",
                    "created_at",
                    "updated_at"
                  ],
                  "properties": {
                    "id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "name": {
                      "type": "string"
                    },
                    "type": {
                      "type": "string"
                    },
                    "html": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "external_url": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "original_url": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "template_id": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "template_vars": {
                      "anyOf": [
                        {
                          "$comment": "json-value",
                          "description": "Arbitrary JSON value with nested arrays and objects."
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "status": {
                      "anyOf": [
                        {
                          "type": "string",
                          "enum": [
                            "active"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "paused"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "archived"
                          ]
                        }
                      ]
                    },
                    "category": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "tags": {
                      "anyOf": [
                        {
                          "$comment": "json-value",
                          "description": "Arbitrary JSON value with nested arrays and objects."
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "created_at": {
                      "format": "date-time",
                      "type": "string"
                    },
                    "updated_at": {
                      "anyOf": [
                        {
                          "format": "date-time",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Explicit destination workspace required: send the x-team-id header or activate a team scope for this operation.",
            "content": {
              "application/json": {
                "schema": {
                  "description": "Explicit destination workspace required: send the x-team-id header or activate a team scope for this operation.",
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "SCOPE_TEAM_REQUIRED"
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/tracker-cloaker/leads": {
      "get": {
        "operationId": "getApiV1TrackerCloakerLeads",
        "summary": "List Tracker & Cloaker leads (Database)",
        "tags": [
          "tracker-cloaker"
        ],
        "description": "Returns a paginated, team-scoped list of leads across all forms. All filters are optional (form_id, status, dateFrom, dateTo); an empty query returns the most recent leads across the team.",
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "query",
            "name": "form_id",
            "required": false
          },
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "query",
            "name": "campaign_id",
            "required": false
          },
          {
            "schema": {
              "maxLength": 120,
              "type": "string"
            },
            "in": "query",
            "name": "category",
            "required": false
          },
          {
            "schema": {
              "maxLength": 200,
              "type": "string"
            },
            "in": "query",
            "name": "search",
            "required": false
          },
          {
            "schema": {
              "maxLength": 40,
              "type": "string"
            },
            "in": "query",
            "name": "status",
            "required": false
          },
          {
            "schema": {
              "maxLength": 40,
              "type": "string"
            },
            "in": "query",
            "name": "dateFrom",
            "required": false
          },
          {
            "schema": {
              "maxLength": 40,
              "type": "string"
            },
            "in": "query",
            "name": "dateTo",
            "required": false
          },
          {
            "schema": {
              "minimum": 1,
              "maximum": 100,
              "type": "integer"
            },
            "in": "query",
            "name": "limit",
            "required": false
          },
          {
            "schema": {
              "minimum": 0,
              "type": "integer"
            },
            "in": "query",
            "name": "offset",
            "required": false
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "items",
                    "total"
                  ],
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "id",
                          "teamId",
                          "formId",
                          "formName",
                          "clickId",
                          "status",
                          "data",
                          "campaignId",
                          "campaignName",
                          "category",
                          "advertiserId",
                          "advertiserName",
                          "postbackStatus",
                          "createdAt"
                        ],
                        "properties": {
                          "id": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "teamId": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "formId": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "formName": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "clickId": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "status": {
                            "type": "string"
                          },
                          "data": {
                            "description": "JSON object with nested arrays and objects.",
                            "type": "object",
                            "additionalProperties": {
                              "$comment": "json-value",
                              "description": "Arbitrary JSON value with nested arrays and objects."
                            }
                          },
                          "campaignId": {
                            "anyOf": [
                              {
                                "format": "uuid",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "campaignName": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "category": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "advertiserId": {
                            "anyOf": [
                              {
                                "format": "uuid",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "advertiserName": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "postbackStatus": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "createdAt": {
                            "format": "date-time",
                            "type": "string"
                          }
                        }
                      }
                    },
                    "total": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/tracker-cloaker/leads/export": {
      "get": {
        "operationId": "getApiV1TrackerCloakerLeadsExport",
        "summary": "Export Tracker & Cloaker leads (Database) as CSV",
        "tags": [
          "tracker-cloaker"
        ],
        "description": "Returns matching leads as a CSV download. Accepts the same filters as /leads (form_id, status, dateFrom, dateTo). Columns are dynamic: fixed lead fields plus one column per distinct key found across the matched leads’ data. Capped at 50k rows.",
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "query",
            "name": "form_id",
            "required": false
          },
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "query",
            "name": "campaign_id",
            "required": false
          },
          {
            "schema": {
              "maxLength": 120,
              "type": "string"
            },
            "in": "query",
            "name": "category",
            "required": false
          },
          {
            "schema": {
              "maxLength": 200,
              "type": "string"
            },
            "in": "query",
            "name": "search",
            "required": false
          },
          {
            "schema": {
              "maxLength": 40,
              "type": "string"
            },
            "in": "query",
            "name": "status",
            "required": false
          },
          {
            "schema": {
              "maxLength": 40,
              "type": "string"
            },
            "in": "query",
            "name": "dateFrom",
            "required": false
          },
          {
            "schema": {
              "maxLength": 40,
              "type": "string"
            },
            "in": "query",
            "name": "dateTo",
            "required": false
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/tracker-cloaker/networks": {
      "get": {
        "operationId": "getApiV1TrackerCloakerNetworks",
        "summary": "List tracker-cloaker networks",
        "tags": [
          "tracker-cloaker"
        ],
        "description": "Returns tracker-cloaker affiliate networks for the current team. Archived networks are hidden by default; pass status=archived to list them explicitly.",
        "parameters": [
          {
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "enum": [
                    "active"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "paused"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "archived"
                  ]
                }
              ]
            },
            "in": "query",
            "name": "status",
            "required": false
          },
          {
            "schema": {
              "minimum": 1,
              "maximum": 100,
              "type": "integer"
            },
            "in": "query",
            "name": "limit",
            "required": false
          },
          {
            "schema": {
              "minimum": 0,
              "type": "integer"
            },
            "in": "query",
            "name": "offset",
            "required": false
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "items",
                    "total"
                  ],
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "id",
                          "teamId",
                          "name",
                          "description",
                          "postbackUrlTemplate",
                          "hasPostbackSecret",
                          "clickIdMacro",
                          "currencyMacro",
                          "eventIdMacro",
                          "orderIdMacro",
                          "payoutMacro",
                          "statusMacro",
                          "offerParams",
                          "postbackMaxPayout",
                          "status",
                          "createdAt"
                        ],
                        "properties": {
                          "id": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "teamId": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "name": {
                            "type": "string"
                          },
                          "description": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "postbackUrlTemplate": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "hasPostbackSecret": {
                            "type": "boolean"
                          },
                          "clickIdMacro": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "currencyMacro": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "eventIdMacro": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "orderIdMacro": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "payoutMacro": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "statusMacro": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "offerParams": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "postbackMaxPayout": {
                            "anyOf": [
                              {
                                "type": "number"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "status": {
                            "anyOf": [
                              {
                                "type": "string",
                                "enum": [
                                  "active"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "paused"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "archived"
                                ]
                              }
                            ]
                          },
                          "createdAt": {
                            "format": "date-time",
                            "type": "string"
                          }
                        }
                      }
                    },
                    "total": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "postApiV1TrackerCloakerNetworks",
        "summary": "Create tracker-cloaker network",
        "tags": [
          "tracker-cloaker"
        ],
        "description": "Creates a new tracker-cloaker affiliate network for the current team.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "name"
                ],
                "properties": {
                  "name": {
                    "minLength": 1,
                    "maxLength": 200,
                    "type": "string"
                  },
                  "description": {
                    "anyOf": [
                      {
                        "maxLength": 2000,
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "postback_url_template": {
                    "anyOf": [
                      {
                        "maxLength": 2000,
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "click_id_macro": {
                    "anyOf": [
                      {
                        "maxLength": 200,
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "currency_macro": {
                    "anyOf": [
                      {
                        "maxLength": 200,
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "event_id_macro": {
                    "anyOf": [
                      {
                        "maxLength": 200,
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "order_id_macro": {
                    "anyOf": [
                      {
                        "maxLength": 200,
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "payout_macro": {
                    "anyOf": [
                      {
                        "maxLength": 200,
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "status_macro": {
                    "anyOf": [
                      {
                        "maxLength": 200,
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "offer_params": {
                    "anyOf": [
                      {
                        "maxLength": 2000,
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "postback_max_payout": {
                    "anyOf": [
                      {
                        "minimum": 0,
                        "type": "number"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "postback_secret": {
                    "anyOf": [
                      {
                        "maxLength": 2000,
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "header",
            "name": "x-team-id",
            "required": false,
            "description": "Destination workspace team id."
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "201": {
            "description": "Resource created",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "id",
                    "teamId",
                    "name",
                    "description",
                    "postbackUrlTemplate",
                    "hasPostbackSecret",
                    "clickIdMacro",
                    "currencyMacro",
                    "eventIdMacro",
                    "orderIdMacro",
                    "payoutMacro",
                    "statusMacro",
                    "offerParams",
                    "postbackMaxPayout",
                    "status",
                    "createdAt"
                  ],
                  "properties": {
                    "id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "teamId": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "name": {
                      "type": "string"
                    },
                    "description": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "postbackUrlTemplate": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "hasPostbackSecret": {
                      "type": "boolean"
                    },
                    "clickIdMacro": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "currencyMacro": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "eventIdMacro": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "orderIdMacro": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "payoutMacro": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "statusMacro": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "offerParams": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "postbackMaxPayout": {
                      "anyOf": [
                        {
                          "type": "number"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "status": {
                      "anyOf": [
                        {
                          "type": "string",
                          "enum": [
                            "active"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "paused"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "archived"
                          ]
                        }
                      ]
                    },
                    "createdAt": {
                      "format": "date-time",
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Explicit destination workspace required: send the x-team-id header or activate a team scope for this operation.",
            "content": {
              "application/json": {
                "schema": {
                  "description": "Explicit destination workspace required: send the x-team-id header or activate a team scope for this operation.",
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "SCOPE_TEAM_REQUIRED"
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/tracker-cloaker/networks/{id}": {
      "get": {
        "operationId": "getApiV1TrackerCloakerNetworksById",
        "summary": "Get tracker-cloaker network",
        "tags": [
          "tracker-cloaker"
        ],
        "description": "Returns details for a specific tracker-cloaker network.",
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "id",
                    "teamId",
                    "name",
                    "description",
                    "postbackUrlTemplate",
                    "hasPostbackSecret",
                    "clickIdMacro",
                    "currencyMacro",
                    "eventIdMacro",
                    "orderIdMacro",
                    "payoutMacro",
                    "statusMacro",
                    "offerParams",
                    "postbackMaxPayout",
                    "status",
                    "createdAt"
                  ],
                  "properties": {
                    "id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "teamId": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "name": {
                      "type": "string"
                    },
                    "description": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "postbackUrlTemplate": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "hasPostbackSecret": {
                      "type": "boolean"
                    },
                    "clickIdMacro": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "currencyMacro": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "eventIdMacro": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "orderIdMacro": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "payoutMacro": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "statusMacro": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "offerParams": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "postbackMaxPayout": {
                      "anyOf": [
                        {
                          "type": "number"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "status": {
                      "anyOf": [
                        {
                          "type": "string",
                          "enum": [
                            "active"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "paused"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "archived"
                          ]
                        }
                      ]
                    },
                    "createdAt": {
                      "format": "date-time",
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      },
      "patch": {
        "operationId": "patchApiV1TrackerCloakerNetworksById",
        "summary": "Update tracker-cloaker network",
        "tags": [
          "tracker-cloaker"
        ],
        "description": "Updates an existing tracker-cloaker network.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "properties": {
                  "name": {
                    "minLength": 1,
                    "maxLength": 200,
                    "type": "string"
                  },
                  "description": {
                    "anyOf": [
                      {
                        "maxLength": 2000,
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "postback_url_template": {
                    "anyOf": [
                      {
                        "maxLength": 2000,
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "click_id_macro": {
                    "anyOf": [
                      {
                        "maxLength": 200,
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "currency_macro": {
                    "anyOf": [
                      {
                        "maxLength": 200,
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "event_id_macro": {
                    "anyOf": [
                      {
                        "maxLength": 200,
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "order_id_macro": {
                    "anyOf": [
                      {
                        "maxLength": 200,
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "payout_macro": {
                    "anyOf": [
                      {
                        "maxLength": 200,
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "status_macro": {
                    "anyOf": [
                      {
                        "maxLength": 200,
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "offer_params": {
                    "anyOf": [
                      {
                        "maxLength": 2000,
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "postback_max_payout": {
                    "anyOf": [
                      {
                        "minimum": 0,
                        "type": "number"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "postback_secret": {
                    "anyOf": [
                      {
                        "maxLength": 2000,
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "status": {
                    "anyOf": [
                      {
                        "type": "string",
                        "enum": [
                          "active"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "paused"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "archived"
                        ]
                      }
                    ]
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          },
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "header",
            "name": "x-team-id",
            "required": false,
            "description": "Destination workspace team id."
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "id",
                    "teamId",
                    "name",
                    "description",
                    "postbackUrlTemplate",
                    "hasPostbackSecret",
                    "clickIdMacro",
                    "currencyMacro",
                    "eventIdMacro",
                    "orderIdMacro",
                    "payoutMacro",
                    "statusMacro",
                    "offerParams",
                    "postbackMaxPayout",
                    "status",
                    "createdAt"
                  ],
                  "properties": {
                    "id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "teamId": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "name": {
                      "type": "string"
                    },
                    "description": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "postbackUrlTemplate": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "hasPostbackSecret": {
                      "type": "boolean"
                    },
                    "clickIdMacro": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "currencyMacro": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "eventIdMacro": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "orderIdMacro": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "payoutMacro": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "statusMacro": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "offerParams": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "postbackMaxPayout": {
                      "anyOf": [
                        {
                          "type": "number"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "status": {
                      "anyOf": [
                        {
                          "type": "string",
                          "enum": [
                            "active"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "paused"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "archived"
                          ]
                        }
                      ]
                    },
                    "createdAt": {
                      "format": "date-time",
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Explicit destination workspace required: send the x-team-id header or activate a team scope for this operation.",
            "content": {
              "application/json": {
                "schema": {
                  "description": "Explicit destination workspace required: send the x-team-id header or activate a team scope for this operation.",
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "SCOPE_TEAM_REQUIRED"
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      },
      "delete": {
        "operationId": "deleteApiV1TrackerCloakerNetworksById",
        "summary": "Archive tracker-cloaker network",
        "tags": [
          "tracker-cloaker"
        ],
        "description": "Soft-deletes a tracker-cloaker network by setting its status to archived.",
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          },
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "header",
            "name": "x-team-id",
            "required": false,
            "description": "Destination workspace team id."
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "archived"
                  ],
                  "properties": {
                    "archived": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Explicit destination workspace required: send the x-team-id header or activate a team scope for this operation.",
            "content": {
              "application/json": {
                "schema": {
                  "description": "Explicit destination workspace required: send the x-team-id header or activate a team scope for this operation.",
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "SCOPE_TEAM_REQUIRED"
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/tracker-cloaker/networks/{id}/postback-token": {
      "get": {
        "operationId": "getApiV1TrackerCloakerNetworksByIdPostbackToken",
        "summary": "Get a network postback token",
        "tags": [
          "tracker-cloaker"
        ],
        "description": "Returns the sensitive inbound-postback token for a network to campaign operators only.",
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          },
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "header",
            "name": "x-team-id",
            "required": false,
            "description": "Destination workspace team id."
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "postbackToken"
                  ],
                  "properties": {
                    "postbackToken": {
                      "minLength": 64,
                      "maxLength": 128,
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Explicit destination workspace required: send the x-team-id header or activate a team scope for this operation.",
            "content": {
              "application/json": {
                "schema": {
                  "description": "Explicit destination workspace required: send the x-team-id header or activate a team scope for this operation.",
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "SCOPE_TEAM_REQUIRED"
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/tracker-cloaker/networks/{id}/regenerate-postback-token": {
      "post": {
        "operationId": "postApiV1TrackerCloakerNetworksByIdRegeneratePostbackToken",
        "summary": "Regenerate network postback token",
        "tags": [
          "tracker-cloaker"
        ],
        "description": "Rotates the postback token used to authenticate inbound postbacks for a network.",
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          },
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "header",
            "name": "x-team-id",
            "required": false,
            "description": "Destination workspace team id."
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "postbackToken"
                  ],
                  "properties": {
                    "postbackToken": {
                      "minLength": 64,
                      "maxLength": 128,
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Explicit destination workspace required: send the x-team-id header or activate a team scope for this operation.",
            "content": {
              "application/json": {
                "schema": {
                  "description": "Explicit destination workspace required: send the x-team-id header or activate a team scope for this operation.",
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "SCOPE_TEAM_REQUIRED"
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/tracker-cloaker/offers/{id}/bundle": {
      "post": {
        "operationId": "postApiV1TrackerCloakerOffersByIdBundle",
        "summary": "Upload a local offer bundle (folder or ZIP)",
        "tags": [
          "tracker-cloaker"
        ],
        "description": "Accepts either a ZIP archive or the individual files of a folder (each part named with its bundle-relative path) and publishes them as the landing page's next bundle version. The files are then served from /tc/lp/{id}/v{version}/, so a re-upload never has to invalidate a cache.",
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          },
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "header",
            "name": "x-team-id",
            "required": false,
            "description": "Destination workspace team id."
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "201": {
            "description": "Resource created",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "version",
                    "entry_file",
                    "file_count",
                    "total_bytes"
                  ],
                  "properties": {
                    "version": {
                      "type": "number"
                    },
                    "entry_file": {
                      "type": "string"
                    },
                    "file_count": {
                      "type": "number"
                    },
                    "total_bytes": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Explicit destination workspace required: send the x-team-id header or activate a team scope for this operation.",
            "content": {
              "application/json": {
                "schema": {
                  "description": "Explicit destination workspace required: send the x-team-id header or activate a team scope for this operation.",
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "SCOPE_TEAM_REQUIRED"
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "413": {
            "description": "Payload too large",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "415": {
            "description": "Response 415",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "422": {
            "description": "Unprocessable entity - semantic validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/tracker-cloaker/offers": {
      "get": {
        "operationId": "getApiV1TrackerCloakerOffers",
        "summary": "List Tracker & Cloaker offers",
        "tags": [
          "tracker-cloaker"
        ],
        "description": "Returns offers for the current team. Archived offers are hidden by default; pass status=archived to list them explicitly.",
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "query",
            "name": "network_id",
            "required": false
          },
          {
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "enum": [
                    "active"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "paused"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "archived"
                  ]
                }
              ]
            },
            "in": "query",
            "name": "status",
            "required": false
          },
          {
            "schema": {
              "minimum": 1,
              "maximum": 100,
              "type": "integer"
            },
            "in": "query",
            "name": "limit",
            "required": false
          },
          {
            "schema": {
              "minimum": 0,
              "type": "integer"
            },
            "in": "query",
            "name": "offset",
            "required": false
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "items",
                    "total"
                  ],
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "id",
                          "teamId",
                          "networkId",
                          "name",
                          "type",
                          "slug",
                          "url",
                          "payoutModel",
                          "payout",
                          "hasPostbackSecret",
                          "geoTags",
                          "status",
                          "bundleVersion",
                          "bundleEntryFile",
                          "createdAt"
                        ],
                        "properties": {
                          "id": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "teamId": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "networkId": {
                            "anyOf": [
                              {
                                "format": "uuid",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "name": {
                            "type": "string"
                          },
                          "type": {
                            "type": "string"
                          },
                          "slug": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "url": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "payoutModel": {
                            "type": "string"
                          },
                          "payout": {
                            "anyOf": [
                              {
                                "type": "number"
                              },
                              {
                                "additionalProperties": {
                                  "type": "number"
                                },
                                "type": "object",
                                "properties": {
                                  "lead": {
                                    "type": "number"
                                  },
                                  "sale": {
                                    "type": "number"
                                  },
                                  "rejected": {
                                    "type": "number"
                                  }
                                }
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "hasPostbackSecret": {
                            "type": "boolean"
                          },
                          "geoTags": {
                            "anyOf": [
                              {
                                "maxItems": 500,
                                "type": "array",
                                "items": {
                                  "maxLength": 16,
                                  "type": "string"
                                }
                              },
                              {
                                "description": "JSON object with nested arrays and objects.",
                                "type": "object",
                                "additionalProperties": {
                                  "$comment": "json-value",
                                  "description": "Arbitrary JSON value with nested arrays and objects."
                                }
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "status": {
                            "anyOf": [
                              {
                                "type": "string",
                                "enum": [
                                  "active"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "paused"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "archived"
                                ]
                              }
                            ]
                          },
                          "bundleVersion": {
                            "anyOf": [
                              {
                                "type": "integer"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "bundleEntryFile": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "createdAt": {
                            "format": "date-time",
                            "type": "string"
                          }
                        }
                      }
                    },
                    "total": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "postApiV1TrackerCloakerOffers",
        "summary": "Create a Tracker & Cloaker offer",
        "tags": [
          "tracker-cloaker"
        ],
        "description": "Creates a new offer for the current team. A unique postback_token is generated server-side.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "name"
                ],
                "properties": {
                  "name": {
                    "minLength": 1,
                    "maxLength": 200,
                    "type": "string"
                  },
                  "url": {
                    "anyOf": [
                      {
                        "minLength": 1,
                        "maxLength": 4096,
                        "format": "uri",
                        "pattern": "^[Hh][Tt][Tt][Pp][Ss]?://",
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "type": {
                    "anyOf": [
                      {
                        "type": "string",
                        "enum": [
                          "external"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "local"
                        ]
                      }
                    ]
                  },
                  "slug": {
                    "anyOf": [
                      {
                        "maxLength": 120,
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "team_id": {
                    "format": "uuid",
                    "type": "string"
                  },
                  "network_id": {
                    "anyOf": [
                      {
                        "format": "uuid",
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "payout_model": {
                    "anyOf": [
                      {
                        "type": "string",
                        "enum": [
                          "cpa"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "cpl"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "revshare"
                        ]
                      }
                    ]
                  },
                  "payout": {
                    "anyOf": [
                      {
                        "additionalProperties": {
                          "type": "number"
                        },
                        "type": "object",
                        "properties": {
                          "lead": {
                            "type": "number"
                          },
                          "sale": {
                            "type": "number"
                          },
                          "rejected": {
                            "type": "number"
                          }
                        }
                      },
                      {
                        "description": "JSON object with nested arrays and objects.",
                        "type": "object",
                        "additionalProperties": {
                          "$comment": "json-value",
                          "description": "Arbitrary JSON value with nested arrays and objects."
                        }
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "geo_tags": {
                    "anyOf": [
                      {
                        "maxItems": 500,
                        "type": "array",
                        "items": {
                          "maxLength": 16,
                          "type": "string"
                        }
                      },
                      {
                        "description": "JSON object with nested arrays and objects.",
                        "type": "object",
                        "additionalProperties": {
                          "$comment": "json-value",
                          "description": "Arbitrary JSON value with nested arrays and objects."
                        }
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "status": {
                    "anyOf": [
                      {
                        "type": "string",
                        "enum": [
                          "active"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "paused"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "archived"
                        ]
                      }
                    ]
                  },
                  "postback_secret": {
                    "anyOf": [
                      {
                        "maxLength": 2000,
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "header",
            "name": "x-team-id",
            "required": false,
            "description": "Destination workspace team id."
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "201": {
            "description": "Resource created",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "id",
                    "teamId",
                    "networkId",
                    "name",
                    "type",
                    "slug",
                    "url",
                    "payoutModel",
                    "payout",
                    "hasPostbackSecret",
                    "geoTags",
                    "status",
                    "bundleVersion",
                    "bundleEntryFile",
                    "createdAt"
                  ],
                  "properties": {
                    "id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "teamId": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "networkId": {
                      "anyOf": [
                        {
                          "format": "uuid",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "name": {
                      "type": "string"
                    },
                    "type": {
                      "type": "string"
                    },
                    "slug": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "url": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "payoutModel": {
                      "type": "string"
                    },
                    "payout": {
                      "anyOf": [
                        {
                          "type": "number"
                        },
                        {
                          "additionalProperties": {
                            "type": "number"
                          },
                          "type": "object",
                          "properties": {
                            "lead": {
                              "type": "number"
                            },
                            "sale": {
                              "type": "number"
                            },
                            "rejected": {
                              "type": "number"
                            }
                          }
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "hasPostbackSecret": {
                      "type": "boolean"
                    },
                    "geoTags": {
                      "anyOf": [
                        {
                          "maxItems": 500,
                          "type": "array",
                          "items": {
                            "maxLength": 16,
                            "type": "string"
                          }
                        },
                        {
                          "description": "JSON object with nested arrays and objects.",
                          "type": "object",
                          "additionalProperties": {
                            "$comment": "json-value",
                            "description": "Arbitrary JSON value with nested arrays and objects."
                          }
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "status": {
                      "anyOf": [
                        {
                          "type": "string",
                          "enum": [
                            "active"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "paused"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "archived"
                          ]
                        }
                      ]
                    },
                    "bundleVersion": {
                      "anyOf": [
                        {
                          "type": "integer"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "bundleEntryFile": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "createdAt": {
                      "format": "date-time",
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "anyOf": [
                    {
                      "description": "Explicit destination workspace required: send the x-team-id header or activate a team scope for this operation.",
                      "additionalProperties": false,
                      "type": "object",
                      "required": [
                        "statusCode",
                        "error",
                        "message"
                      ],
                      "properties": {
                        "statusCode": {
                          "type": "number"
                        },
                        "error": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "code": {
                          "type": "string",
                          "enum": [
                            "SCOPE_TEAM_REQUIRED"
                          ]
                        }
                      }
                    },
                    {
                      "type": "object",
                      "required": [
                        "statusCode",
                        "error",
                        "message"
                      ],
                      "properties": {
                        "statusCode": {
                          "type": "number"
                        },
                        "error": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/tracker-cloaker/offers/{id}": {
      "get": {
        "operationId": "getApiV1TrackerCloakerOffersById",
        "summary": "Get a Tracker & Cloaker offer",
        "tags": [
          "tracker-cloaker"
        ],
        "description": "Returns details for a specific offer.",
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "id",
                    "teamId",
                    "networkId",
                    "name",
                    "type",
                    "slug",
                    "url",
                    "payoutModel",
                    "payout",
                    "hasPostbackSecret",
                    "geoTags",
                    "status",
                    "bundleVersion",
                    "bundleEntryFile",
                    "createdAt"
                  ],
                  "properties": {
                    "id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "teamId": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "networkId": {
                      "anyOf": [
                        {
                          "format": "uuid",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "name": {
                      "type": "string"
                    },
                    "type": {
                      "type": "string"
                    },
                    "slug": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "url": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "payoutModel": {
                      "type": "string"
                    },
                    "payout": {
                      "anyOf": [
                        {
                          "type": "number"
                        },
                        {
                          "additionalProperties": {
                            "type": "number"
                          },
                          "type": "object",
                          "properties": {
                            "lead": {
                              "type": "number"
                            },
                            "sale": {
                              "type": "number"
                            },
                            "rejected": {
                              "type": "number"
                            }
                          }
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "hasPostbackSecret": {
                      "type": "boolean"
                    },
                    "geoTags": {
                      "anyOf": [
                        {
                          "maxItems": 500,
                          "type": "array",
                          "items": {
                            "maxLength": 16,
                            "type": "string"
                          }
                        },
                        {
                          "description": "JSON object with nested arrays and objects.",
                          "type": "object",
                          "additionalProperties": {
                            "$comment": "json-value",
                            "description": "Arbitrary JSON value with nested arrays and objects."
                          }
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "status": {
                      "anyOf": [
                        {
                          "type": "string",
                          "enum": [
                            "active"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "paused"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "archived"
                          ]
                        }
                      ]
                    },
                    "bundleVersion": {
                      "anyOf": [
                        {
                          "type": "integer"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "bundleEntryFile": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "createdAt": {
                      "format": "date-time",
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      },
      "patch": {
        "operationId": "patchApiV1TrackerCloakerOffersById",
        "summary": "Update a Tracker & Cloaker offer",
        "tags": [
          "tracker-cloaker"
        ],
        "description": "Updates an existing offer.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "properties": {
                  "name": {
                    "minLength": 1,
                    "maxLength": 200,
                    "type": "string"
                  },
                  "url": {
                    "anyOf": [
                      {
                        "minLength": 1,
                        "maxLength": 4096,
                        "format": "uri",
                        "pattern": "^[Hh][Tt][Tt][Pp][Ss]?://",
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "type": {
                    "anyOf": [
                      {
                        "type": "string",
                        "enum": [
                          "external"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "local"
                        ]
                      }
                    ]
                  },
                  "slug": {
                    "anyOf": [
                      {
                        "maxLength": 120,
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "network_id": {
                    "anyOf": [
                      {
                        "format": "uuid",
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "payout_model": {
                    "anyOf": [
                      {
                        "type": "string",
                        "enum": [
                          "cpa"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "cpl"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "revshare"
                        ]
                      }
                    ]
                  },
                  "payout": {
                    "anyOf": [
                      {
                        "additionalProperties": {
                          "type": "number"
                        },
                        "type": "object",
                        "properties": {
                          "lead": {
                            "type": "number"
                          },
                          "sale": {
                            "type": "number"
                          },
                          "rejected": {
                            "type": "number"
                          }
                        }
                      },
                      {
                        "description": "JSON object with nested arrays and objects.",
                        "type": "object",
                        "additionalProperties": {
                          "$comment": "json-value",
                          "description": "Arbitrary JSON value with nested arrays and objects."
                        }
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "geo_tags": {
                    "anyOf": [
                      {
                        "maxItems": 500,
                        "type": "array",
                        "items": {
                          "maxLength": 16,
                          "type": "string"
                        }
                      },
                      {
                        "description": "JSON object with nested arrays and objects.",
                        "type": "object",
                        "additionalProperties": {
                          "$comment": "json-value",
                          "description": "Arbitrary JSON value with nested arrays and objects."
                        }
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "status": {
                    "anyOf": [
                      {
                        "type": "string",
                        "enum": [
                          "active"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "paused"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "archived"
                        ]
                      }
                    ]
                  },
                  "postback_secret": {
                    "anyOf": [
                      {
                        "maxLength": 2000,
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          },
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "header",
            "name": "x-team-id",
            "required": false,
            "description": "Destination workspace team id."
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "id",
                    "teamId",
                    "networkId",
                    "name",
                    "type",
                    "slug",
                    "url",
                    "payoutModel",
                    "payout",
                    "hasPostbackSecret",
                    "geoTags",
                    "status",
                    "bundleVersion",
                    "bundleEntryFile",
                    "createdAt"
                  ],
                  "properties": {
                    "id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "teamId": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "networkId": {
                      "anyOf": [
                        {
                          "format": "uuid",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "name": {
                      "type": "string"
                    },
                    "type": {
                      "type": "string"
                    },
                    "slug": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "url": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "payoutModel": {
                      "type": "string"
                    },
                    "payout": {
                      "anyOf": [
                        {
                          "type": "number"
                        },
                        {
                          "additionalProperties": {
                            "type": "number"
                          },
                          "type": "object",
                          "properties": {
                            "lead": {
                              "type": "number"
                            },
                            "sale": {
                              "type": "number"
                            },
                            "rejected": {
                              "type": "number"
                            }
                          }
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "hasPostbackSecret": {
                      "type": "boolean"
                    },
                    "geoTags": {
                      "anyOf": [
                        {
                          "maxItems": 500,
                          "type": "array",
                          "items": {
                            "maxLength": 16,
                            "type": "string"
                          }
                        },
                        {
                          "description": "JSON object with nested arrays and objects.",
                          "type": "object",
                          "additionalProperties": {
                            "$comment": "json-value",
                            "description": "Arbitrary JSON value with nested arrays and objects."
                          }
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "status": {
                      "anyOf": [
                        {
                          "type": "string",
                          "enum": [
                            "active"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "paused"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "archived"
                          ]
                        }
                      ]
                    },
                    "bundleVersion": {
                      "anyOf": [
                        {
                          "type": "integer"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "bundleEntryFile": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "createdAt": {
                      "format": "date-time",
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Explicit destination workspace required: send the x-team-id header or activate a team scope for this operation.",
            "content": {
              "application/json": {
                "schema": {
                  "description": "Explicit destination workspace required: send the x-team-id header or activate a team scope for this operation.",
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "SCOPE_TEAM_REQUIRED"
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      },
      "delete": {
        "operationId": "deleteApiV1TrackerCloakerOffersById",
        "summary": "Delete a Tracker & Cloaker offer",
        "tags": [
          "tracker-cloaker"
        ],
        "description": "Soft-deletes an offer by setting its status to archived.",
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          },
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "header",
            "name": "x-team-id",
            "required": false,
            "description": "Destination workspace team id."
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "deleted"
                  ],
                  "properties": {
                    "deleted": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Explicit destination workspace required: send the x-team-id header or activate a team scope for this operation.",
            "content": {
              "application/json": {
                "schema": {
                  "description": "Explicit destination workspace required: send the x-team-id header or activate a team scope for this operation.",
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "SCOPE_TEAM_REQUIRED"
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/tracker-cloaker/offers/{id}/postback-token": {
      "get": {
        "operationId": "getApiV1TrackerCloakerOffersByIdPostbackToken",
        "summary": "Get an offer postback token",
        "tags": [
          "tracker-cloaker"
        ],
        "description": "Returns the sensitive inbound-postback token for an offer to campaign operators only.",
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          },
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "header",
            "name": "x-team-id",
            "required": false,
            "description": "Destination workspace team id."
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "postbackToken"
                  ],
                  "properties": {
                    "postbackToken": {
                      "minLength": 24,
                      "maxLength": 128,
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Explicit destination workspace required: send the x-team-id header or activate a team scope for this operation.",
            "content": {
              "application/json": {
                "schema": {
                  "description": "Explicit destination workspace required: send the x-team-id header or activate a team scope for this operation.",
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "SCOPE_TEAM_REQUIRED"
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/tracker-cloaker/offers/{id}/regenerate-postback-token": {
      "post": {
        "operationId": "postApiV1TrackerCloakerOffersByIdRegeneratePostbackToken",
        "summary": "Regenerate offer postback token",
        "tags": [
          "tracker-cloaker"
        ],
        "description": "Rotates the postback token used to authenticate inbound postbacks for an offer.",
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          },
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "header",
            "name": "x-team-id",
            "required": false,
            "description": "Destination workspace team id."
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "postbackToken"
                  ],
                  "properties": {
                    "postbackToken": {
                      "minLength": 24,
                      "maxLength": 128,
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Explicit destination workspace required: send the x-team-id header or activate a team scope for this operation.",
            "content": {
              "application/json": {
                "schema": {
                  "description": "Explicit destination workspace required: send the x-team-id header or activate a team scope for this operation.",
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "SCOPE_TEAM_REQUIRED"
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/tracker-cloaker/products": {
      "get": {
        "operationId": "getApiV1TrackerCloakerProducts",
        "summary": "List tracker-cloaker products",
        "tags": [
          "tracker-cloaker"
        ],
        "description": "Returns all products for the current team, with per-product form + lead counts.",
        "parameters": [
          {
            "schema": {
              "type": "boolean"
            },
            "in": "query",
            "name": "include_archived",
            "required": false
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "items",
                    "total"
                  ],
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "id",
                          "teamId",
                          "name",
                          "status",
                          "formCount",
                          "leadCount",
                          "createdAt"
                        ],
                        "properties": {
                          "id": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "teamId": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "name": {
                            "type": "string"
                          },
                          "status": {
                            "type": "string"
                          },
                          "formCount": {
                            "type": "number"
                          },
                          "leadCount": {
                            "type": "number"
                          },
                          "createdAt": {
                            "format": "date-time",
                            "type": "string"
                          }
                        }
                      }
                    },
                    "total": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "postApiV1TrackerCloakerProducts",
        "summary": "Create a tracker-cloaker product",
        "tags": [
          "tracker-cloaker"
        ],
        "description": "Creates a product. Names are unique (case-insensitive) per team; a duplicate returns 409 with existingId.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "name"
                ],
                "properties": {
                  "name": {
                    "minLength": 1,
                    "maxLength": 100,
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "header",
            "name": "x-team-id",
            "required": false,
            "description": "Destination workspace team id."
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "201": {
            "description": "Resource created",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "id",
                    "teamId",
                    "name",
                    "status",
                    "formCount",
                    "leadCount",
                    "createdAt"
                  ],
                  "properties": {
                    "id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "teamId": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "name": {
                      "type": "string"
                    },
                    "status": {
                      "type": "string"
                    },
                    "formCount": {
                      "type": "number"
                    },
                    "leadCount": {
                      "type": "number"
                    },
                    "createdAt": {
                      "format": "date-time",
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Explicit destination workspace required: send the x-team-id header or activate a team scope for this operation.",
            "content": {
              "application/json": {
                "schema": {
                  "description": "Explicit destination workspace required: send the x-team-id header or activate a team scope for this operation.",
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "SCOPE_TEAM_REQUIRED"
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "Conflict - resource state prevents the operation",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "existingId": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "leadCount": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/tracker-cloaker/products/{id}": {
      "put": {
        "operationId": "putApiV1TrackerCloakerProductsById",
        "summary": "Update a tracker-cloaker product",
        "tags": [
          "tracker-cloaker"
        ],
        "description": "Renames or archives/restores a product.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "properties": {
                  "name": {
                    "minLength": 1,
                    "maxLength": 100,
                    "type": "string"
                  },
                  "status": {
                    "anyOf": [
                      {
                        "type": "string",
                        "enum": [
                          "active"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "archived"
                        ]
                      }
                    ]
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          },
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "header",
            "name": "x-team-id",
            "required": false,
            "description": "Destination workspace team id."
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "id",
                    "teamId",
                    "name",
                    "status",
                    "formCount",
                    "leadCount",
                    "createdAt"
                  ],
                  "properties": {
                    "id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "teamId": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "name": {
                      "type": "string"
                    },
                    "status": {
                      "type": "string"
                    },
                    "formCount": {
                      "type": "number"
                    },
                    "leadCount": {
                      "type": "number"
                    },
                    "createdAt": {
                      "format": "date-time",
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Explicit destination workspace required: send the x-team-id header or activate a team scope for this operation.",
            "content": {
              "application/json": {
                "schema": {
                  "description": "Explicit destination workspace required: send the x-team-id header or activate a team scope for this operation.",
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "SCOPE_TEAM_REQUIRED"
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "Conflict - resource state prevents the operation",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "existingId": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "leadCount": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      },
      "delete": {
        "operationId": "deleteApiV1TrackerCloakerProductsById",
        "summary": "Delete a tracker-cloaker product",
        "tags": [
          "tracker-cloaker"
        ],
        "description": "Hard-deletes a product. Blocked with 409 when leads are linked (archive instead).",
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          },
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "header",
            "name": "x-team-id",
            "required": false,
            "description": "Destination workspace team id."
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "deleted"
                  ],
                  "properties": {
                    "deleted": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Explicit destination workspace required: send the x-team-id header or activate a team scope for this operation.",
            "content": {
              "application/json": {
                "schema": {
                  "description": "Explicit destination workspace required: send the x-team-id header or activate a team scope for this operation.",
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "SCOPE_TEAM_REQUIRED"
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "Conflict - resource state prevents the operation",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "existingId": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "leadCount": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/tracker-cloaker/settings": {
      "get": {
        "operationId": "getApiV1TrackerCloakerSettings",
        "summary": "Get Tracker & Cloaker settings",
        "tags": [
          "tracker-cloaker"
        ],
        "description": "Returns the current team key-value app settings as a flat object. Encrypted values are masked.",
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "query",
            "name": "team_id",
            "required": false
          },
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "header",
            "name": "x-team-id",
            "required": false,
            "description": "Destination workspace team id."
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": {
                    "anyOf": [
                      {
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  }
                }
              }
            }
          },
          "400": {
            "description": "Explicit destination workspace required: send the x-team-id header or activate a team scope for this operation.",
            "content": {
              "application/json": {
                "schema": {
                  "description": "Explicit destination workspace required: send the x-team-id header or activate a team scope for this operation.",
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "SCOPE_TEAM_REQUIRED"
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      },
      "put": {
        "operationId": "putApiV1TrackerCloakerSettings",
        "summary": "Update Tracker & Cloaker settings",
        "tags": [
          "tracker-cloaker"
        ],
        "description": "Upserts a partial key-value map for the current team. A value equal to the mask placeholder is left unchanged.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "maxProperties": 100,
                "type": "object",
                "additionalProperties": {
                  "anyOf": [
                    {
                      "maxLength": 10000,
                      "type": "string"
                    },
                    {
                      "type": "null"
                    }
                  ]
                }
              }
            }
          }
        },
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "query",
            "name": "team_id",
            "required": false
          },
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "header",
            "name": "x-team-id",
            "required": false,
            "description": "Destination workspace team id."
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": {
                    "anyOf": [
                      {
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "anyOf": [
                    {
                      "description": "Explicit destination workspace required: send the x-team-id header or activate a team scope for this operation.",
                      "additionalProperties": false,
                      "type": "object",
                      "required": [
                        "statusCode",
                        "error",
                        "message"
                      ],
                      "properties": {
                        "statusCode": {
                          "type": "number"
                        },
                        "error": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "code": {
                          "type": "string",
                          "enum": [
                            "SCOPE_TEAM_REQUIRED"
                          ]
                        }
                      }
                    },
                    {
                      "type": "object",
                      "required": [
                        "statusCode",
                        "error",
                        "message"
                      ],
                      "properties": {
                        "statusCode": {
                          "type": "number"
                        },
                        "error": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/tracker-cloaker/stats/find": {
      "get": {
        "operationId": "getApiV1TrackerCloakerStatsFind",
        "summary": "Find by Click ID (prefix lookup across clicks, conversions, leads)",
        "tags": [
          "trackers"
        ],
        "description": "Prefix-matches a click id (min 4 chars) and returns ALL matching clicks, ALL their conversions and any tied lead-form submissions, team-scoped, with a {matches} summary.",
        "parameters": [
          {
            "schema": {
              "minLength": 4,
              "maxLength": 100,
              "type": "string"
            },
            "in": "query",
            "name": "cid",
            "required": true
          },
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "header",
            "name": "x-team-id",
            "required": false,
            "description": "Destination workspace team id."
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "matches",
                    "clicks",
                    "conversions",
                    "leads"
                  ],
                  "properties": {
                    "matches": {
                      "type": "number"
                    },
                    "clicks": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "id",
                          "teamId",
                          "campaignId",
                          "country",
                          "ipMasked",
                          "isp",
                          "verdict",
                          "score",
                          "deviceType",
                          "browser",
                          "os",
                          "isUnique",
                          "createdAt"
                        ],
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "teamId": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "campaignId": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "country": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "ipMasked": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "isp": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "verdict": {
                            "type": "string"
                          },
                          "score": {
                            "type": "number"
                          },
                          "deviceType": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "browser": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "os": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "isUnique": {
                            "type": "boolean"
                          },
                          "createdAt": {
                            "format": "date-time",
                            "type": "string"
                          }
                        }
                      }
                    },
                    "conversions": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "id",
                          "teamId",
                          "clickId",
                          "status",
                          "payout",
                          "currency",
                          "orderId",
                          "source",
                          "capiSent",
                          "postbackForwarded",
                          "createdAt"
                        ],
                        "properties": {
                          "id": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "teamId": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "clickId": {
                            "type": "string"
                          },
                          "status": {
                            "type": "string"
                          },
                          "payout": {
                            "anyOf": [
                              {
                                "type": "number"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "currency": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "orderId": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "source": {
                            "type": "string"
                          },
                          "capiSent": {
                            "type": "boolean"
                          },
                          "postbackForwarded": {
                            "type": "boolean"
                          },
                          "createdAt": {
                            "format": "date-time",
                            "type": "string"
                          }
                        }
                      }
                    },
                    "leads": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "id",
                          "teamId",
                          "formId",
                          "formName",
                          "clickId",
                          "status",
                          "data",
                          "createdAt"
                        ],
                        "properties": {
                          "id": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "teamId": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "formId": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "formName": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "clickId": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "status": {
                            "type": "string"
                          },
                          "data": {
                            "description": "JSON object with nested arrays and objects.",
                            "type": "object",
                            "additionalProperties": {
                              "$comment": "json-value",
                              "description": "Arbitrary JSON value with nested arrays and objects."
                            }
                          },
                          "createdAt": {
                            "format": "date-time",
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Explicit destination workspace required: send the x-team-id header or activate a team scope for this operation.",
            "content": {
              "application/json": {
                "schema": {
                  "description": "Explicit destination workspace required: send the x-team-id header or activate a team scope for this operation.",
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "SCOPE_TEAM_REQUIRED"
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/tracker-cloaker/stats/summary": {
      "get": {
        "operationId": "getApiV1TrackerCloakerStatsSummary",
        "summary": "Tracker-cloaker summary KPIs",
        "tags": [
          "trackers"
        ],
        "description": "Aggregated KPIs computed live from tc_click + tc_conversion for the date range.",
        "parameters": [
          {
            "schema": {
              "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
              "type": "string"
            },
            "in": "query",
            "name": "from_date",
            "required": false
          },
          {
            "schema": {
              "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
              "type": "string"
            },
            "in": "query",
            "name": "to_date",
            "required": false
          },
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "query",
            "name": "campaign_id",
            "required": false
          },
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "header",
            "name": "x-team-id",
            "required": false,
            "description": "Destination workspace team id."
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "clicks",
                    "uniqueClicks",
                    "bots",
                    "humans",
                    "suspects",
                    "leads",
                    "sales",
                    "rejected",
                    "revenue",
                    "cost",
                    "currency",
                    "mixedCurrency",
                    "ctr",
                    "approvalRate",
                    "rejectRate"
                  ],
                  "properties": {
                    "clicks": {
                      "type": "number"
                    },
                    "uniqueClicks": {
                      "type": "number"
                    },
                    "bots": {
                      "type": "number"
                    },
                    "humans": {
                      "type": "number"
                    },
                    "suspects": {
                      "type": "number"
                    },
                    "leads": {
                      "type": "number"
                    },
                    "sales": {
                      "type": "number"
                    },
                    "rejected": {
                      "type": "number"
                    },
                    "revenue": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "cost": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "currency": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "mixedCurrency": {
                      "type": "boolean"
                    },
                    "ctr": {
                      "type": "number"
                    },
                    "approvalRate": {
                      "type": "number"
                    },
                    "rejectRate": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Explicit destination workspace required: send the x-team-id header or activate a team scope for this operation.",
            "content": {
              "application/json": {
                "schema": {
                  "description": "Explicit destination workspace required: send the x-team-id header or activate a team scope for this operation.",
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "SCOPE_TEAM_REQUIRED"
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/tracker-cloaker/stats/daily": {
      "get": {
        "operationId": "getApiV1TrackerCloakerStatsDaily",
        "summary": "Tracker-cloaker daily stats",
        "tags": [
          "trackers"
        ],
        "description": "Daily breakdown computed live from tc_click + tc_conversion for the date range.",
        "parameters": [
          {
            "schema": {
              "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
              "type": "string"
            },
            "in": "query",
            "name": "from_date",
            "required": false
          },
          {
            "schema": {
              "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
              "type": "string"
            },
            "in": "query",
            "name": "to_date",
            "required": false
          },
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "query",
            "name": "campaign_id",
            "required": false
          },
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "header",
            "name": "x-team-id",
            "required": false,
            "description": "Destination workspace team id."
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "required": [
                      "date",
                      "clicks",
                      "uniqueClicks",
                      "bots",
                      "humans",
                      "suspects",
                      "leads",
                      "sales",
                      "rejected",
                      "revenue",
                      "cost",
                      "currency",
                      "mixedCurrency"
                    ],
                    "properties": {
                      "date": {
                        "format": "date",
                        "type": "string"
                      },
                      "clicks": {
                        "type": "number"
                      },
                      "uniqueClicks": {
                        "type": "number"
                      },
                      "bots": {
                        "type": "number"
                      },
                      "humans": {
                        "type": "number"
                      },
                      "suspects": {
                        "type": "number"
                      },
                      "leads": {
                        "type": "number"
                      },
                      "sales": {
                        "type": "number"
                      },
                      "rejected": {
                        "type": "number"
                      },
                      "revenue": {
                        "anyOf": [
                          {
                            "type": "string"
                          },
                          {
                            "type": "null"
                          }
                        ]
                      },
                      "cost": {
                        "anyOf": [
                          {
                            "type": "string"
                          },
                          {
                            "type": "null"
                          }
                        ]
                      },
                      "currency": {
                        "anyOf": [
                          {
                            "type": "string"
                          },
                          {
                            "type": "null"
                          }
                        ]
                      },
                      "mixedCurrency": {
                        "type": "boolean"
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Explicit destination workspace required: send the x-team-id header or activate a team scope for this operation.",
            "content": {
              "application/json": {
                "schema": {
                  "description": "Explicit destination workspace required: send the x-team-id header or activate a team scope for this operation.",
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "SCOPE_TEAM_REQUIRED"
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/tracker-cloaker/stats/by-campaign": {
      "get": {
        "operationId": "getApiV1TrackerCloakerStatsByCampaign",
        "summary": "Tracker-cloaker stats by campaign",
        "tags": [
          "trackers"
        ],
        "description": "Per-campaign KPIs (clicks, humans, bots, suspects, conversions, revenue, cost, cr, epc, roi) computed live from tc_click + tc_conversion for the date range.",
        "parameters": [
          {
            "schema": {
              "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
              "type": "string"
            },
            "in": "query",
            "name": "from_date",
            "required": false
          },
          {
            "schema": {
              "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
              "type": "string"
            },
            "in": "query",
            "name": "to_date",
            "required": false
          },
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "query",
            "name": "campaign_id",
            "required": false
          },
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "header",
            "name": "x-team-id",
            "required": false,
            "description": "Destination workspace team id."
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "required": [
                      "campaignId",
                      "name",
                      "clicks",
                      "humans",
                      "bots",
                      "suspects",
                      "conversions",
                      "revenue",
                      "cost",
                      "currency",
                      "mixedCurrency",
                      "cr",
                      "epc",
                      "roi"
                    ],
                    "properties": {
                      "campaignId": {
                        "format": "uuid",
                        "type": "string"
                      },
                      "name": {
                        "type": "string"
                      },
                      "clicks": {
                        "type": "number"
                      },
                      "humans": {
                        "type": "number"
                      },
                      "bots": {
                        "type": "number"
                      },
                      "suspects": {
                        "type": "number"
                      },
                      "conversions": {
                        "type": "number"
                      },
                      "revenue": {
                        "anyOf": [
                          {
                            "type": "number"
                          },
                          {
                            "type": "null"
                          }
                        ]
                      },
                      "cost": {
                        "anyOf": [
                          {
                            "type": "number"
                          },
                          {
                            "type": "null"
                          }
                        ]
                      },
                      "currency": {
                        "anyOf": [
                          {
                            "type": "string"
                          },
                          {
                            "type": "null"
                          }
                        ]
                      },
                      "mixedCurrency": {
                        "type": "boolean"
                      },
                      "cr": {
                        "type": "number"
                      },
                      "epc": {
                        "anyOf": [
                          {
                            "type": "number"
                          },
                          {
                            "type": "null"
                          }
                        ]
                      },
                      "roi": {
                        "anyOf": [
                          {
                            "type": "number"
                          },
                          {
                            "type": "null"
                          }
                        ]
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Explicit destination workspace required: send the x-team-id header or activate a team scope for this operation.",
            "content": {
              "application/json": {
                "schema": {
                  "description": "Explicit destination workspace required: send the x-team-id header or activate a team scope for this operation.",
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "SCOPE_TEAM_REQUIRED"
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/tracker-cloaker/stats/by-country": {
      "get": {
        "operationId": "getApiV1TrackerCloakerStatsByCountry",
        "summary": "Tracker-cloaker stats by country",
        "tags": [
          "trackers"
        ],
        "description": "Full funnel breakdown by country over tc_click + tc_conversion for the date range.",
        "parameters": [
          {
            "schema": {
              "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
              "type": "string"
            },
            "in": "query",
            "name": "from_date",
            "required": false
          },
          {
            "schema": {
              "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
              "type": "string"
            },
            "in": "query",
            "name": "to_date",
            "required": false
          },
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "query",
            "name": "campaign_id",
            "required": false
          },
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "header",
            "name": "x-team-id",
            "required": false,
            "description": "Destination workspace team id."
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "required": [
                      "key",
                      "clicks",
                      "uniqueClicks",
                      "humans",
                      "bots",
                      "approved",
                      "rejected",
                      "revenue",
                      "cost",
                      "profit",
                      "currency",
                      "mixedCurrency",
                      "cr",
                      "epc",
                      "roi"
                    ],
                    "properties": {
                      "key": {
                        "anyOf": [
                          {
                            "type": "string"
                          },
                          {
                            "type": "null"
                          }
                        ]
                      },
                      "clicks": {
                        "type": "number"
                      },
                      "uniqueClicks": {
                        "type": "number"
                      },
                      "humans": {
                        "type": "number"
                      },
                      "bots": {
                        "type": "number"
                      },
                      "approved": {
                        "type": "number"
                      },
                      "rejected": {
                        "type": "number"
                      },
                      "revenue": {
                        "anyOf": [
                          {
                            "type": "number"
                          },
                          {
                            "type": "null"
                          }
                        ]
                      },
                      "cost": {
                        "anyOf": [
                          {
                            "type": "number"
                          },
                          {
                            "type": "null"
                          }
                        ]
                      },
                      "profit": {
                        "anyOf": [
                          {
                            "type": "number"
                          },
                          {
                            "type": "null"
                          }
                        ]
                      },
                      "currency": {
                        "anyOf": [
                          {
                            "type": "string"
                          },
                          {
                            "type": "null"
                          }
                        ]
                      },
                      "mixedCurrency": {
                        "type": "boolean"
                      },
                      "cr": {
                        "type": "number"
                      },
                      "epc": {
                        "anyOf": [
                          {
                            "type": "number"
                          },
                          {
                            "type": "null"
                          }
                        ]
                      },
                      "roi": {
                        "anyOf": [
                          {
                            "type": "number"
                          },
                          {
                            "type": "null"
                          }
                        ]
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Explicit destination workspace required: send the x-team-id header or activate a team scope for this operation.",
            "content": {
              "application/json": {
                "schema": {
                  "description": "Explicit destination workspace required: send the x-team-id header or activate a team scope for this operation.",
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "SCOPE_TEAM_REQUIRED"
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/tracker-cloaker/stats/by-device": {
      "get": {
        "operationId": "getApiV1TrackerCloakerStatsByDevice",
        "summary": "Tracker-cloaker stats by device",
        "tags": [
          "trackers"
        ],
        "description": "Full funnel breakdown by device type over tc_click + tc_conversion for the date range.",
        "parameters": [
          {
            "schema": {
              "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
              "type": "string"
            },
            "in": "query",
            "name": "from_date",
            "required": false
          },
          {
            "schema": {
              "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
              "type": "string"
            },
            "in": "query",
            "name": "to_date",
            "required": false
          },
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "query",
            "name": "campaign_id",
            "required": false
          },
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "header",
            "name": "x-team-id",
            "required": false,
            "description": "Destination workspace team id."
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "required": [
                      "key",
                      "clicks",
                      "uniqueClicks",
                      "humans",
                      "bots",
                      "approved",
                      "rejected",
                      "revenue",
                      "cost",
                      "profit",
                      "currency",
                      "mixedCurrency",
                      "cr",
                      "epc",
                      "roi"
                    ],
                    "properties": {
                      "key": {
                        "anyOf": [
                          {
                            "type": "string"
                          },
                          {
                            "type": "null"
                          }
                        ]
                      },
                      "clicks": {
                        "type": "number"
                      },
                      "uniqueClicks": {
                        "type": "number"
                      },
                      "humans": {
                        "type": "number"
                      },
                      "bots": {
                        "type": "number"
                      },
                      "approved": {
                        "type": "number"
                      },
                      "rejected": {
                        "type": "number"
                      },
                      "revenue": {
                        "anyOf": [
                          {
                            "type": "number"
                          },
                          {
                            "type": "null"
                          }
                        ]
                      },
                      "cost": {
                        "anyOf": [
                          {
                            "type": "number"
                          },
                          {
                            "type": "null"
                          }
                        ]
                      },
                      "profit": {
                        "anyOf": [
                          {
                            "type": "number"
                          },
                          {
                            "type": "null"
                          }
                        ]
                      },
                      "currency": {
                        "anyOf": [
                          {
                            "type": "string"
                          },
                          {
                            "type": "null"
                          }
                        ]
                      },
                      "mixedCurrency": {
                        "type": "boolean"
                      },
                      "cr": {
                        "type": "number"
                      },
                      "epc": {
                        "anyOf": [
                          {
                            "type": "number"
                          },
                          {
                            "type": "null"
                          }
                        ]
                      },
                      "roi": {
                        "anyOf": [
                          {
                            "type": "number"
                          },
                          {
                            "type": "null"
                          }
                        ]
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Explicit destination workspace required: send the x-team-id header or activate a team scope for this operation.",
            "content": {
              "application/json": {
                "schema": {
                  "description": "Explicit destination workspace required: send the x-team-id header or activate a team scope for this operation.",
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "SCOPE_TEAM_REQUIRED"
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/tracker-cloaker/stats/by-os": {
      "get": {
        "operationId": "getApiV1TrackerCloakerStatsByOs",
        "summary": "Tracker-cloaker stats by OS",
        "tags": [
          "trackers"
        ],
        "description": "Full funnel breakdown by operating system over tc_click + tc_conversion for the date range.",
        "parameters": [
          {
            "schema": {
              "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
              "type": "string"
            },
            "in": "query",
            "name": "from_date",
            "required": false
          },
          {
            "schema": {
              "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
              "type": "string"
            },
            "in": "query",
            "name": "to_date",
            "required": false
          },
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "query",
            "name": "campaign_id",
            "required": false
          },
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "header",
            "name": "x-team-id",
            "required": false,
            "description": "Destination workspace team id."
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "required": [
                      "key",
                      "clicks",
                      "uniqueClicks",
                      "humans",
                      "bots",
                      "approved",
                      "rejected",
                      "revenue",
                      "cost",
                      "profit",
                      "currency",
                      "mixedCurrency",
                      "cr",
                      "epc",
                      "roi"
                    ],
                    "properties": {
                      "key": {
                        "anyOf": [
                          {
                            "type": "string"
                          },
                          {
                            "type": "null"
                          }
                        ]
                      },
                      "clicks": {
                        "type": "number"
                      },
                      "uniqueClicks": {
                        "type": "number"
                      },
                      "humans": {
                        "type": "number"
                      },
                      "bots": {
                        "type": "number"
                      },
                      "approved": {
                        "type": "number"
                      },
                      "rejected": {
                        "type": "number"
                      },
                      "revenue": {
                        "anyOf": [
                          {
                            "type": "number"
                          },
                          {
                            "type": "null"
                          }
                        ]
                      },
                      "cost": {
                        "anyOf": [
                          {
                            "type": "number"
                          },
                          {
                            "type": "null"
                          }
                        ]
                      },
                      "profit": {
                        "anyOf": [
                          {
                            "type": "number"
                          },
                          {
                            "type": "null"
                          }
                        ]
                      },
                      "currency": {
                        "anyOf": [
                          {
                            "type": "string"
                          },
                          {
                            "type": "null"
                          }
                        ]
                      },
                      "mixedCurrency": {
                        "type": "boolean"
                      },
                      "cr": {
                        "type": "number"
                      },
                      "epc": {
                        "anyOf": [
                          {
                            "type": "number"
                          },
                          {
                            "type": "null"
                          }
                        ]
                      },
                      "roi": {
                        "anyOf": [
                          {
                            "type": "number"
                          },
                          {
                            "type": "null"
                          }
                        ]
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Explicit destination workspace required: send the x-team-id header or activate a team scope for this operation.",
            "content": {
              "application/json": {
                "schema": {
                  "description": "Explicit destination workspace required: send the x-team-id header or activate a team scope for this operation.",
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "SCOPE_TEAM_REQUIRED"
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/tracker-cloaker/stats/by-browser": {
      "get": {
        "operationId": "getApiV1TrackerCloakerStatsByBrowser",
        "summary": "Tracker-cloaker stats by browser",
        "tags": [
          "trackers"
        ],
        "description": "Full funnel breakdown by browser over tc_click + tc_conversion for the date range.",
        "parameters": [
          {
            "schema": {
              "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
              "type": "string"
            },
            "in": "query",
            "name": "from_date",
            "required": false
          },
          {
            "schema": {
              "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
              "type": "string"
            },
            "in": "query",
            "name": "to_date",
            "required": false
          },
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "query",
            "name": "campaign_id",
            "required": false
          },
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "header",
            "name": "x-team-id",
            "required": false,
            "description": "Destination workspace team id."
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "required": [
                      "key",
                      "clicks",
                      "uniqueClicks",
                      "humans",
                      "bots",
                      "approved",
                      "rejected",
                      "revenue",
                      "cost",
                      "profit",
                      "currency",
                      "mixedCurrency",
                      "cr",
                      "epc",
                      "roi"
                    ],
                    "properties": {
                      "key": {
                        "anyOf": [
                          {
                            "type": "string"
                          },
                          {
                            "type": "null"
                          }
                        ]
                      },
                      "clicks": {
                        "type": "number"
                      },
                      "uniqueClicks": {
                        "type": "number"
                      },
                      "humans": {
                        "type": "number"
                      },
                      "bots": {
                        "type": "number"
                      },
                      "approved": {
                        "type": "number"
                      },
                      "rejected": {
                        "type": "number"
                      },
                      "revenue": {
                        "anyOf": [
                          {
                            "type": "number"
                          },
                          {
                            "type": "null"
                          }
                        ]
                      },
                      "cost": {
                        "anyOf": [
                          {
                            "type": "number"
                          },
                          {
                            "type": "null"
                          }
                        ]
                      },
                      "profit": {
                        "anyOf": [
                          {
                            "type": "number"
                          },
                          {
                            "type": "null"
                          }
                        ]
                      },
                      "currency": {
                        "anyOf": [
                          {
                            "type": "string"
                          },
                          {
                            "type": "null"
                          }
                        ]
                      },
                      "mixedCurrency": {
                        "type": "boolean"
                      },
                      "cr": {
                        "type": "number"
                      },
                      "epc": {
                        "anyOf": [
                          {
                            "type": "number"
                          },
                          {
                            "type": "null"
                          }
                        ]
                      },
                      "roi": {
                        "anyOf": [
                          {
                            "type": "number"
                          },
                          {
                            "type": "null"
                          }
                        ]
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Explicit destination workspace required: send the x-team-id header or activate a team scope for this operation.",
            "content": {
              "application/json": {
                "schema": {
                  "description": "Explicit destination workspace required: send the x-team-id header or activate a team scope for this operation.",
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "SCOPE_TEAM_REQUIRED"
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/tracker-cloaker/stats/by-isp": {
      "get": {
        "operationId": "getApiV1TrackerCloakerStatsByIsp",
        "summary": "Tracker-cloaker stats by ISP",
        "tags": [
          "trackers"
        ],
        "description": "Full funnel breakdown by ISP over tc_click + tc_conversion for the date range.",
        "parameters": [
          {
            "schema": {
              "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
              "type": "string"
            },
            "in": "query",
            "name": "from_date",
            "required": false
          },
          {
            "schema": {
              "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
              "type": "string"
            },
            "in": "query",
            "name": "to_date",
            "required": false
          },
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "query",
            "name": "campaign_id",
            "required": false
          },
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "header",
            "name": "x-team-id",
            "required": false,
            "description": "Destination workspace team id."
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "required": [
                      "key",
                      "clicks",
                      "uniqueClicks",
                      "humans",
                      "bots",
                      "approved",
                      "rejected",
                      "revenue",
                      "cost",
                      "profit",
                      "currency",
                      "mixedCurrency",
                      "cr",
                      "epc",
                      "roi"
                    ],
                    "properties": {
                      "key": {
                        "anyOf": [
                          {
                            "type": "string"
                          },
                          {
                            "type": "null"
                          }
                        ]
                      },
                      "clicks": {
                        "type": "number"
                      },
                      "uniqueClicks": {
                        "type": "number"
                      },
                      "humans": {
                        "type": "number"
                      },
                      "bots": {
                        "type": "number"
                      },
                      "approved": {
                        "type": "number"
                      },
                      "rejected": {
                        "type": "number"
                      },
                      "revenue": {
                        "anyOf": [
                          {
                            "type": "number"
                          },
                          {
                            "type": "null"
                          }
                        ]
                      },
                      "cost": {
                        "anyOf": [
                          {
                            "type": "number"
                          },
                          {
                            "type": "null"
                          }
                        ]
                      },
                      "profit": {
                        "anyOf": [
                          {
                            "type": "number"
                          },
                          {
                            "type": "null"
                          }
                        ]
                      },
                      "currency": {
                        "anyOf": [
                          {
                            "type": "string"
                          },
                          {
                            "type": "null"
                          }
                        ]
                      },
                      "mixedCurrency": {
                        "type": "boolean"
                      },
                      "cr": {
                        "type": "number"
                      },
                      "epc": {
                        "anyOf": [
                          {
                            "type": "number"
                          },
                          {
                            "type": "null"
                          }
                        ]
                      },
                      "roi": {
                        "anyOf": [
                          {
                            "type": "number"
                          },
                          {
                            "type": "null"
                          }
                        ]
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Explicit destination workspace required: send the x-team-id header or activate a team scope for this operation.",
            "content": {
              "application/json": {
                "schema": {
                  "description": "Explicit destination workspace required: send the x-team-id header or activate a team scope for this operation.",
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "SCOPE_TEAM_REQUIRED"
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/tracker-cloaker/stats/by-subid": {
      "get": {
        "operationId": "getApiV1TrackerCloakerStatsBySubid",
        "summary": "Tracker-cloaker stats by sub-ID",
        "tags": [
          "trackers"
        ],
        "description": "Click breakdown by sub_id_N (slot 1..10) over tc_click for the date range.",
        "parameters": [
          {
            "schema": {
              "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
              "type": "string"
            },
            "in": "query",
            "name": "from_date",
            "required": false
          },
          {
            "schema": {
              "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
              "type": "string"
            },
            "in": "query",
            "name": "to_date",
            "required": false
          },
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "query",
            "name": "campaign_id",
            "required": false
          },
          {
            "schema": {
              "minimum": 1,
              "maximum": 10,
              "default": 1,
              "type": "integer"
            },
            "in": "query",
            "name": "slot",
            "required": false
          },
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "header",
            "name": "x-team-id",
            "required": false,
            "description": "Destination workspace team id."
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "required": [
                      "key",
                      "clicks",
                      "uniqueClicks",
                      "humans",
                      "bots",
                      "approved",
                      "rejected",
                      "revenue",
                      "cost",
                      "profit",
                      "currency",
                      "mixedCurrency",
                      "cr",
                      "epc",
                      "roi"
                    ],
                    "properties": {
                      "key": {
                        "anyOf": [
                          {
                            "type": "string"
                          },
                          {
                            "type": "null"
                          }
                        ]
                      },
                      "clicks": {
                        "type": "number"
                      },
                      "uniqueClicks": {
                        "type": "number"
                      },
                      "humans": {
                        "type": "number"
                      },
                      "bots": {
                        "type": "number"
                      },
                      "approved": {
                        "type": "number"
                      },
                      "rejected": {
                        "type": "number"
                      },
                      "revenue": {
                        "anyOf": [
                          {
                            "type": "number"
                          },
                          {
                            "type": "null"
                          }
                        ]
                      },
                      "cost": {
                        "anyOf": [
                          {
                            "type": "number"
                          },
                          {
                            "type": "null"
                          }
                        ]
                      },
                      "profit": {
                        "anyOf": [
                          {
                            "type": "number"
                          },
                          {
                            "type": "null"
                          }
                        ]
                      },
                      "currency": {
                        "anyOf": [
                          {
                            "type": "string"
                          },
                          {
                            "type": "null"
                          }
                        ]
                      },
                      "mixedCurrency": {
                        "type": "boolean"
                      },
                      "cr": {
                        "type": "number"
                      },
                      "epc": {
                        "anyOf": [
                          {
                            "type": "number"
                          },
                          {
                            "type": "null"
                          }
                        ]
                      },
                      "roi": {
                        "anyOf": [
                          {
                            "type": "number"
                          },
                          {
                            "type": "null"
                          }
                        ]
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Explicit destination workspace required: send the x-team-id header or activate a team scope for this operation.",
            "content": {
              "application/json": {
                "schema": {
                  "description": "Explicit destination workspace required: send the x-team-id header or activate a team scope for this operation.",
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "SCOPE_TEAM_REQUIRED"
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/tracker-cloaker/stats/by-reason": {
      "get": {
        "operationId": "getApiV1TrackerCloakerStatsByReason",
        "summary": "Tracker-cloaker bleed-rate breakdown by filter reason",
        "tags": [
          "trackers"
        ],
        "description": "Histogram of the tc_click.reasons JSONB array over the date range. Returns total/filtered clicks, the overall filter rate, and per-reason count + filtered_count + pct (filtered share of total clicks). Backs the Stats \"Bleed Rate\" card and drill-down into the traffic log.",
        "parameters": [
          {
            "schema": {
              "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
              "type": "string"
            },
            "in": "query",
            "name": "from_date",
            "required": false
          },
          {
            "schema": {
              "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
              "type": "string"
            },
            "in": "query",
            "name": "to_date",
            "required": false
          },
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "query",
            "name": "campaign_id",
            "required": false
          },
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "header",
            "name": "x-team-id",
            "required": false,
            "description": "Destination workspace team id."
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "totalClicks",
                    "totalFiltered",
                    "overallFilterRate",
                    "rows"
                  ],
                  "properties": {
                    "totalClicks": {
                      "type": "number"
                    },
                    "totalFiltered": {
                      "type": "number"
                    },
                    "overallFilterRate": {
                      "type": "number"
                    },
                    "rows": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "reason",
                          "count",
                          "filteredCount",
                          "pct"
                        ],
                        "properties": {
                          "reason": {
                            "type": "string"
                          },
                          "count": {
                            "type": "number"
                          },
                          "filteredCount": {
                            "type": "number"
                          },
                          "pct": {
                            "type": "number"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Explicit destination workspace required: send the x-team-id header or activate a team scope for this operation.",
            "content": {
              "application/json": {
                "schema": {
                  "description": "Explicit destination workspace required: send the x-team-id header or activate a team scope for this operation.",
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "SCOPE_TEAM_REQUIRED"
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/tracker-cloaker/stats/by-landing": {
      "get": {
        "operationId": "getApiV1TrackerCloakerStatsByLanding",
        "summary": "Tracker-cloaker funnel breakdown by landing",
        "tags": [
          "trackers"
        ],
        "description": "Full click→conversion funnel grouped by landing (clicks, unique, humans, bots, approved/rejected conversions, revenue, cost, profit, cr, epc, roi) over the date range.",
        "parameters": [
          {
            "schema": {
              "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
              "type": "string"
            },
            "in": "query",
            "name": "from_date",
            "required": false
          },
          {
            "schema": {
              "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
              "type": "string"
            },
            "in": "query",
            "name": "to_date",
            "required": false
          },
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "query",
            "name": "campaign_id",
            "required": false
          },
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "header",
            "name": "x-team-id",
            "required": false,
            "description": "Destination workspace team id."
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "required": [
                      "key",
                      "clicks",
                      "uniqueClicks",
                      "humans",
                      "bots",
                      "approved",
                      "rejected",
                      "revenue",
                      "cost",
                      "profit",
                      "currency",
                      "mixedCurrency",
                      "cr",
                      "epc",
                      "roi"
                    ],
                    "properties": {
                      "key": {
                        "anyOf": [
                          {
                            "type": "string"
                          },
                          {
                            "type": "null"
                          }
                        ]
                      },
                      "clicks": {
                        "type": "number"
                      },
                      "uniqueClicks": {
                        "type": "number"
                      },
                      "humans": {
                        "type": "number"
                      },
                      "bots": {
                        "type": "number"
                      },
                      "approved": {
                        "type": "number"
                      },
                      "rejected": {
                        "type": "number"
                      },
                      "revenue": {
                        "anyOf": [
                          {
                            "type": "number"
                          },
                          {
                            "type": "null"
                          }
                        ]
                      },
                      "cost": {
                        "anyOf": [
                          {
                            "type": "number"
                          },
                          {
                            "type": "null"
                          }
                        ]
                      },
                      "profit": {
                        "anyOf": [
                          {
                            "type": "number"
                          },
                          {
                            "type": "null"
                          }
                        ]
                      },
                      "currency": {
                        "anyOf": [
                          {
                            "type": "string"
                          },
                          {
                            "type": "null"
                          }
                        ]
                      },
                      "mixedCurrency": {
                        "type": "boolean"
                      },
                      "cr": {
                        "type": "number"
                      },
                      "epc": {
                        "anyOf": [
                          {
                            "type": "number"
                          },
                          {
                            "type": "null"
                          }
                        ]
                      },
                      "roi": {
                        "anyOf": [
                          {
                            "type": "number"
                          },
                          {
                            "type": "null"
                          }
                        ]
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Explicit destination workspace required: send the x-team-id header or activate a team scope for this operation.",
            "content": {
              "application/json": {
                "schema": {
                  "description": "Explicit destination workspace required: send the x-team-id header or activate a team scope for this operation.",
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "SCOPE_TEAM_REQUIRED"
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/tracker-cloaker/stats/by-offer": {
      "get": {
        "operationId": "getApiV1TrackerCloakerStatsByOffer",
        "summary": "Tracker-cloaker funnel breakdown by offer",
        "tags": [
          "trackers"
        ],
        "description": "Full click→conversion funnel grouped by offer (clicks, unique, humans, bots, approved/rejected conversions, revenue, cost, profit, cr, epc, roi) over the date range.",
        "parameters": [
          {
            "schema": {
              "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
              "type": "string"
            },
            "in": "query",
            "name": "from_date",
            "required": false
          },
          {
            "schema": {
              "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
              "type": "string"
            },
            "in": "query",
            "name": "to_date",
            "required": false
          },
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "query",
            "name": "campaign_id",
            "required": false
          },
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "header",
            "name": "x-team-id",
            "required": false,
            "description": "Destination workspace team id."
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "required": [
                      "key",
                      "clicks",
                      "uniqueClicks",
                      "humans",
                      "bots",
                      "approved",
                      "rejected",
                      "revenue",
                      "cost",
                      "profit",
                      "currency",
                      "mixedCurrency",
                      "cr",
                      "epc",
                      "roi"
                    ],
                    "properties": {
                      "key": {
                        "anyOf": [
                          {
                            "type": "string"
                          },
                          {
                            "type": "null"
                          }
                        ]
                      },
                      "clicks": {
                        "type": "number"
                      },
                      "uniqueClicks": {
                        "type": "number"
                      },
                      "humans": {
                        "type": "number"
                      },
                      "bots": {
                        "type": "number"
                      },
                      "approved": {
                        "type": "number"
                      },
                      "rejected": {
                        "type": "number"
                      },
                      "revenue": {
                        "anyOf": [
                          {
                            "type": "number"
                          },
                          {
                            "type": "null"
                          }
                        ]
                      },
                      "cost": {
                        "anyOf": [
                          {
                            "type": "number"
                          },
                          {
                            "type": "null"
                          }
                        ]
                      },
                      "profit": {
                        "anyOf": [
                          {
                            "type": "number"
                          },
                          {
                            "type": "null"
                          }
                        ]
                      },
                      "currency": {
                        "anyOf": [
                          {
                            "type": "string"
                          },
                          {
                            "type": "null"
                          }
                        ]
                      },
                      "mixedCurrency": {
                        "type": "boolean"
                      },
                      "cr": {
                        "type": "number"
                      },
                      "epc": {
                        "anyOf": [
                          {
                            "type": "number"
                          },
                          {
                            "type": "null"
                          }
                        ]
                      },
                      "roi": {
                        "anyOf": [
                          {
                            "type": "number"
                          },
                          {
                            "type": "null"
                          }
                        ]
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Explicit destination workspace required: send the x-team-id header or activate a team scope for this operation.",
            "content": {
              "application/json": {
                "schema": {
                  "description": "Explicit destination workspace required: send the x-team-id header or activate a team scope for this operation.",
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "SCOPE_TEAM_REQUIRED"
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/tracker-cloaker/stats/by-flow": {
      "get": {
        "operationId": "getApiV1TrackerCloakerStatsByFlow",
        "summary": "Tracker-cloaker funnel breakdown by flow",
        "tags": [
          "trackers"
        ],
        "description": "Full click→conversion funnel grouped by flow (clicks, unique, humans, bots, approved/rejected conversions, revenue, cost, profit, cr, epc, roi) over the date range.",
        "parameters": [
          {
            "schema": {
              "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
              "type": "string"
            },
            "in": "query",
            "name": "from_date",
            "required": false
          },
          {
            "schema": {
              "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
              "type": "string"
            },
            "in": "query",
            "name": "to_date",
            "required": false
          },
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "query",
            "name": "campaign_id",
            "required": false
          },
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "header",
            "name": "x-team-id",
            "required": false,
            "description": "Destination workspace team id."
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "required": [
                      "key",
                      "clicks",
                      "uniqueClicks",
                      "humans",
                      "bots",
                      "approved",
                      "rejected",
                      "revenue",
                      "cost",
                      "profit",
                      "currency",
                      "mixedCurrency",
                      "cr",
                      "epc",
                      "roi"
                    ],
                    "properties": {
                      "key": {
                        "anyOf": [
                          {
                            "type": "string"
                          },
                          {
                            "type": "null"
                          }
                        ]
                      },
                      "clicks": {
                        "type": "number"
                      },
                      "uniqueClicks": {
                        "type": "number"
                      },
                      "humans": {
                        "type": "number"
                      },
                      "bots": {
                        "type": "number"
                      },
                      "approved": {
                        "type": "number"
                      },
                      "rejected": {
                        "type": "number"
                      },
                      "revenue": {
                        "anyOf": [
                          {
                            "type": "number"
                          },
                          {
                            "type": "null"
                          }
                        ]
                      },
                      "cost": {
                        "anyOf": [
                          {
                            "type": "number"
                          },
                          {
                            "type": "null"
                          }
                        ]
                      },
                      "profit": {
                        "anyOf": [
                          {
                            "type": "number"
                          },
                          {
                            "type": "null"
                          }
                        ]
                      },
                      "currency": {
                        "anyOf": [
                          {
                            "type": "string"
                          },
                          {
                            "type": "null"
                          }
                        ]
                      },
                      "mixedCurrency": {
                        "type": "boolean"
                      },
                      "cr": {
                        "type": "number"
                      },
                      "epc": {
                        "anyOf": [
                          {
                            "type": "number"
                          },
                          {
                            "type": "null"
                          }
                        ]
                      },
                      "roi": {
                        "anyOf": [
                          {
                            "type": "number"
                          },
                          {
                            "type": "null"
                          }
                        ]
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Explicit destination workspace required: send the x-team-id header or activate a team scope for this operation.",
            "content": {
              "application/json": {
                "schema": {
                  "description": "Explicit destination workspace required: send the x-team-id header or activate a team scope for this operation.",
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "SCOPE_TEAM_REQUIRED"
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/tracker-cloaker/stats/traffic-log": {
      "get": {
        "operationId": "getApiV1TrackerCloakerStatsTrafficLog",
        "summary": "Tracker-cloaker traffic log",
        "tags": [
          "trackers"
        ],
        "description": "Paginated raw click stream (tc_click) for the date range.",
        "parameters": [
          {
            "schema": {
              "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
              "type": "string"
            },
            "in": "query",
            "name": "from_date",
            "required": false
          },
          {
            "schema": {
              "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
              "type": "string"
            },
            "in": "query",
            "name": "to_date",
            "required": false
          },
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "query",
            "name": "campaign_id",
            "required": false
          },
          {
            "schema": {
              "maxLength": 50,
              "type": "string"
            },
            "in": "query",
            "name": "verdict",
            "required": false
          },
          {
            "schema": {
              "maxLength": 50,
              "type": "string"
            },
            "in": "query",
            "name": "device_type",
            "required": false
          },
          {
            "schema": {
              "maxLength": 10,
              "type": "string"
            },
            "in": "query",
            "name": "country",
            "required": false
          },
          {
            "schema": {
              "maxLength": 100,
              "type": "string"
            },
            "in": "query",
            "name": "reason",
            "required": false
          },
          {
            "schema": {
              "maxLength": 255,
              "type": "string"
            },
            "in": "query",
            "name": "sub_id",
            "required": false
          },
          {
            "schema": {
              "minimum": 1,
              "maximum": 200,
              "default": 50,
              "type": "integer"
            },
            "in": "query",
            "name": "limit",
            "required": false
          },
          {
            "schema": {
              "minimum": 0,
              "default": 0,
              "type": "integer"
            },
            "in": "query",
            "name": "offset",
            "required": false
          },
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "header",
            "name": "x-team-id",
            "required": false,
            "description": "Destination workspace team id."
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "items",
                    "total",
                    "limit",
                    "offset"
                  ],
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "id",
                          "campaignId",
                          "verdict",
                          "score",
                          "country",
                          "deviceType",
                          "os",
                          "browser",
                          "ipMasked",
                          "isp",
                          "asn",
                          "reasons",
                          "referrer",
                          "ua",
                          "subId1",
                          "subId2",
                          "subId3",
                          "subId4",
                          "subId5",
                          "subId6",
                          "subId7",
                          "subId8",
                          "subId9",
                          "subId10",
                          "isUnique",
                          "createdAt"
                        ],
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "campaignId": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "verdict": {
                            "type": "string"
                          },
                          "score": {
                            "type": "number"
                          },
                          "country": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "deviceType": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "os": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "browser": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "ipMasked": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "isp": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "asn": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "reasons": {
                            "type": "array",
                            "items": {
                              "type": "string"
                            }
                          },
                          "referrer": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "ua": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "subId1": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "subId2": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "subId3": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "subId4": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "subId5": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "subId6": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "subId7": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "subId8": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "subId9": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "subId10": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "isUnique": {
                            "type": "boolean"
                          },
                          "createdAt": {
                            "format": "date-time",
                            "type": "string"
                          }
                        }
                      }
                    },
                    "total": {
                      "type": "number"
                    },
                    "limit": {
                      "minimum": 1,
                      "type": "integer"
                    },
                    "offset": {
                      "minimum": 0,
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Explicit destination workspace required: send the x-team-id header or activate a team scope for this operation.",
            "content": {
              "application/json": {
                "schema": {
                  "description": "Explicit destination workspace required: send the x-team-id header or activate a team scope for this operation.",
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "SCOPE_TEAM_REQUIRED"
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/tracker-cloaker/stats/capi-summary": {
      "get": {
        "operationId": "getApiV1TrackerCloakerStatsCapiSummary",
        "summary": "Tracker-cloaker CAPI delivery summary",
        "tags": [
          "trackers"
        ],
        "description": "Facebook Conversions API delivery health rollup over tc_capi_event for the team. Defaults to the last 7 days (inclusive of today). Returns total/sent/failed/skipped counts, the last ~10 failed events, and a per-day sent/failed series.",
        "parameters": [
          {
            "schema": {
              "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
              "type": "string"
            },
            "in": "query",
            "name": "from_date",
            "required": false
          },
          {
            "schema": {
              "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
              "type": "string"
            },
            "in": "query",
            "name": "to_date",
            "required": false
          },
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "query",
            "name": "campaign_id",
            "required": false
          },
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "header",
            "name": "x-team-id",
            "required": false,
            "description": "Destination workspace team id."
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "total",
                    "sent",
                    "failed",
                    "skipped",
                    "recentErrors",
                    "daily"
                  ],
                  "properties": {
                    "total": {
                      "type": "number"
                    },
                    "sent": {
                      "type": "number"
                    },
                    "failed": {
                      "type": "number"
                    },
                    "skipped": {
                      "type": "number"
                    },
                    "recentErrors": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "created_at",
                          "event_name",
                          "error"
                        ],
                        "properties": {
                          "created_at": {
                            "format": "date-time",
                            "type": "string"
                          },
                          "event_name": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "error": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          }
                        }
                      }
                    },
                    "daily": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "date",
                          "sent",
                          "failed"
                        ],
                        "properties": {
                          "date": {
                            "format": "date",
                            "type": "string"
                          },
                          "sent": {
                            "type": "number"
                          },
                          "failed": {
                            "type": "number"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Explicit destination workspace required: send the x-team-id header or activate a team scope for this operation.",
            "content": {
              "application/json": {
                "schema": {
                  "description": "Explicit destination workspace required: send the x-team-id header or activate a team scope for this operation.",
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "SCOPE_TEAM_REQUIRED"
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/tracker-cloaker/system/status": {
      "get": {
        "operationId": "getApiV1TrackerCloakerSystemStatus",
        "summary": "Tracker-cloaker system diagnostics",
        "tags": [
          "tracker-cloaker"
        ],
        "description": "Read-only runtime diagnostics: per-team entity counts (campaigns, clicks, conversions, leads, offers, networks, domains, filter-lists), process uptime + node version, and in-process enrichment cache sizes.",
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "counts",
                    "process",
                    "cache"
                  ],
                  "properties": {
                    "counts": {
                      "type": "object",
                      "required": [
                        "campaigns",
                        "clicks",
                        "conversions",
                        "leads",
                        "offers",
                        "networks",
                        "domains",
                        "filterLists"
                      ],
                      "properties": {
                        "campaigns": {
                          "type": "number"
                        },
                        "clicks": {
                          "type": "number"
                        },
                        "conversions": {
                          "type": "number"
                        },
                        "leads": {
                          "type": "number"
                        },
                        "offers": {
                          "type": "number"
                        },
                        "networks": {
                          "type": "number"
                        },
                        "domains": {
                          "type": "number"
                        },
                        "filterLists": {
                          "type": "number"
                        }
                      }
                    },
                    "process": {
                      "type": "object",
                      "required": [
                        "uptimeSec",
                        "nodeVersion"
                      ],
                      "properties": {
                        "uptimeSec": {
                          "type": "number"
                        },
                        "nodeVersion": {
                          "type": "string"
                        }
                      }
                    },
                    "cache": {
                      "type": "object",
                      "required": [
                        "enrichment",
                        "enrichmentMax",
                        "botCidrs"
                      ],
                      "properties": {
                        "enrichment": {
                          "type": "number"
                        },
                        "enrichmentMax": {
                          "type": "number"
                        },
                        "botCidrs": {
                          "type": "number"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/tracker-cloaker/traffic-sources/presets": {
      "get": {
        "operationId": "getApiV1TrackerCloakerTrafficSourcesPresets",
        "summary": "List Tracker & Cloaker traffic-source presets",
        "tags": [
          "tracker-cloaker"
        ],
        "description": "Returns built-in URL-parameter templates for facebook/google/tiktok/taboola the UI can load into a new source.",
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "presets"
                  ],
                  "properties": {
                    "presets": {
                      "type": "object",
                      "additionalProperties": {
                        "type": "array",
                        "items": {
                          "additionalProperties": false,
                          "type": "object",
                          "properties": {
                            "sub_id_position": {
                              "minimum": 1,
                              "maximum": 10,
                              "type": "integer"
                            },
                            "position": {
                              "minimum": 1,
                              "maximum": 10,
                              "type": "integer"
                            },
                            "key": {
                              "minLength": 1,
                              "maxLength": 40,
                              "type": "string"
                            },
                            "placeholder": {
                              "maxLength": 100,
                              "type": "string"
                            },
                            "macro": {
                              "maxLength": 100,
                              "type": "string"
                            },
                            "name": {
                              "maxLength": 40,
                              "type": "string"
                            },
                            "param": {
                              "maxLength": 40,
                              "type": "string"
                            }
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/tracker-cloaker/traffic-sources": {
      "get": {
        "operationId": "getApiV1TrackerCloakerTrafficSources",
        "summary": "List Tracker & Cloaker traffic sources",
        "tags": [
          "tracker-cloaker"
        ],
        "description": "Returns all traffic sources for the current team.",
        "parameters": [
          {
            "schema": {
              "maxLength": 40,
              "type": "string"
            },
            "in": "query",
            "name": "platform",
            "required": false
          },
          {
            "schema": {
              "minimum": 1,
              "maximum": 100,
              "type": "integer"
            },
            "in": "query",
            "name": "limit",
            "required": false
          },
          {
            "schema": {
              "minimum": 0,
              "type": "integer"
            },
            "in": "query",
            "name": "offset",
            "required": false
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "items",
                    "total"
                  ],
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "id",
                          "teamId",
                          "name",
                          "platform",
                          "paramMapping",
                          "parameters",
                          "postbackUrlTemplate",
                          "isPreset",
                          "createdAt"
                        ],
                        "properties": {
                          "id": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "teamId": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "name": {
                            "type": "string"
                          },
                          "platform": {
                            "type": "string"
                          },
                          "paramMapping": {
                            "description": "Map of canonical parameter keys to traffic-source macros, or null when unset.",
                            "anyOf": [
                              {
                                "type": "object",
                                "additionalProperties": {
                                  "type": "string"
                                }
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "parameters": {
                            "type": "array",
                            "items": {
                              "additionalProperties": false,
                              "type": "object",
                              "properties": {
                                "sub_id_position": {
                                  "minimum": 1,
                                  "maximum": 10,
                                  "type": "integer"
                                },
                                "position": {
                                  "minimum": 1,
                                  "maximum": 10,
                                  "type": "integer"
                                },
                                "key": {
                                  "minLength": 1,
                                  "maxLength": 40,
                                  "type": "string"
                                },
                                "placeholder": {
                                  "maxLength": 100,
                                  "type": "string"
                                },
                                "macro": {
                                  "maxLength": 100,
                                  "type": "string"
                                },
                                "name": {
                                  "maxLength": 40,
                                  "type": "string"
                                },
                                "param": {
                                  "maxLength": 40,
                                  "type": "string"
                                }
                              }
                            }
                          },
                          "postbackUrlTemplate": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "isPreset": {
                            "type": "boolean"
                          },
                          "createdAt": {
                            "format": "date-time",
                            "type": "string"
                          }
                        }
                      }
                    },
                    "total": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "postApiV1TrackerCloakerTrafficSources",
        "summary": "Create a Tracker & Cloaker traffic source",
        "tags": [
          "tracker-cloaker"
        ],
        "description": "Creates a new traffic source for the current team.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "name",
                  "platform"
                ],
                "properties": {
                  "name": {
                    "minLength": 1,
                    "maxLength": 200,
                    "type": "string"
                  },
                  "platform": {
                    "anyOf": [
                      {
                        "type": "string",
                        "enum": [
                          "facebook"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "google"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "tiktok"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "taboola"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "outbrain"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "push"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "custom"
                        ]
                      }
                    ]
                  },
                  "team_id": {
                    "format": "uuid",
                    "type": "string"
                  },
                  "param_mapping": {
                    "anyOf": [
                      {
                        "description": "JSON object with nested arrays and objects.",
                        "type": "object",
                        "additionalProperties": {
                          "$comment": "json-value",
                          "description": "Arbitrary JSON value with nested arrays and objects."
                        }
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "parameters": {
                    "maxItems": 10,
                    "type": "array",
                    "items": {
                      "additionalProperties": false,
                      "type": "object",
                      "properties": {
                        "sub_id_position": {
                          "minimum": 1,
                          "maximum": 10,
                          "type": "integer"
                        },
                        "position": {
                          "minimum": 1,
                          "maximum": 10,
                          "type": "integer"
                        },
                        "key": {
                          "minLength": 1,
                          "maxLength": 40,
                          "type": "string"
                        },
                        "placeholder": {
                          "maxLength": 100,
                          "type": "string"
                        },
                        "macro": {
                          "maxLength": 100,
                          "type": "string"
                        },
                        "name": {
                          "maxLength": 40,
                          "type": "string"
                        },
                        "param": {
                          "maxLength": 40,
                          "type": "string"
                        }
                      }
                    }
                  },
                  "postback_url_template": {
                    "anyOf": [
                      {
                        "maxLength": 4000,
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "header",
            "name": "x-team-id",
            "required": false,
            "description": "Destination workspace team id."
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "201": {
            "description": "Resource created",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "id",
                    "teamId",
                    "name",
                    "platform",
                    "paramMapping",
                    "parameters",
                    "postbackUrlTemplate",
                    "isPreset",
                    "createdAt"
                  ],
                  "properties": {
                    "id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "teamId": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "name": {
                      "type": "string"
                    },
                    "platform": {
                      "type": "string"
                    },
                    "paramMapping": {
                      "description": "Map of canonical parameter keys to traffic-source macros, or null when unset.",
                      "anyOf": [
                        {
                          "type": "object",
                          "additionalProperties": {
                            "type": "string"
                          }
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "parameters": {
                      "type": "array",
                      "items": {
                        "additionalProperties": false,
                        "type": "object",
                        "properties": {
                          "sub_id_position": {
                            "minimum": 1,
                            "maximum": 10,
                            "type": "integer"
                          },
                          "position": {
                            "minimum": 1,
                            "maximum": 10,
                            "type": "integer"
                          },
                          "key": {
                            "minLength": 1,
                            "maxLength": 40,
                            "type": "string"
                          },
                          "placeholder": {
                            "maxLength": 100,
                            "type": "string"
                          },
                          "macro": {
                            "maxLength": 100,
                            "type": "string"
                          },
                          "name": {
                            "maxLength": 40,
                            "type": "string"
                          },
                          "param": {
                            "maxLength": 40,
                            "type": "string"
                          }
                        }
                      }
                    },
                    "postbackUrlTemplate": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "isPreset": {
                      "type": "boolean"
                    },
                    "createdAt": {
                      "format": "date-time",
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "anyOf": [
                    {
                      "description": "Explicit destination workspace required: send the x-team-id header or activate a team scope for this operation.",
                      "additionalProperties": false,
                      "type": "object",
                      "required": [
                        "statusCode",
                        "error",
                        "message"
                      ],
                      "properties": {
                        "statusCode": {
                          "type": "number"
                        },
                        "error": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "code": {
                          "type": "string",
                          "enum": [
                            "SCOPE_TEAM_REQUIRED"
                          ]
                        }
                      }
                    },
                    {
                      "type": "object",
                      "required": [
                        "statusCode",
                        "error",
                        "message"
                      ],
                      "properties": {
                        "statusCode": {
                          "type": "number"
                        },
                        "error": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/tracker-cloaker/traffic-sources/{id}": {
      "get": {
        "operationId": "getApiV1TrackerCloakerTrafficSourcesById",
        "summary": "Get a Tracker & Cloaker traffic source",
        "tags": [
          "tracker-cloaker"
        ],
        "description": "Returns details for a specific traffic source.",
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "id",
                    "teamId",
                    "name",
                    "platform",
                    "paramMapping",
                    "parameters",
                    "postbackUrlTemplate",
                    "isPreset",
                    "createdAt"
                  ],
                  "properties": {
                    "id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "teamId": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "name": {
                      "type": "string"
                    },
                    "platform": {
                      "type": "string"
                    },
                    "paramMapping": {
                      "description": "Map of canonical parameter keys to traffic-source macros, or null when unset.",
                      "anyOf": [
                        {
                          "type": "object",
                          "additionalProperties": {
                            "type": "string"
                          }
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "parameters": {
                      "type": "array",
                      "items": {
                        "additionalProperties": false,
                        "type": "object",
                        "properties": {
                          "sub_id_position": {
                            "minimum": 1,
                            "maximum": 10,
                            "type": "integer"
                          },
                          "position": {
                            "minimum": 1,
                            "maximum": 10,
                            "type": "integer"
                          },
                          "key": {
                            "minLength": 1,
                            "maxLength": 40,
                            "type": "string"
                          },
                          "placeholder": {
                            "maxLength": 100,
                            "type": "string"
                          },
                          "macro": {
                            "maxLength": 100,
                            "type": "string"
                          },
                          "name": {
                            "maxLength": 40,
                            "type": "string"
                          },
                          "param": {
                            "maxLength": 40,
                            "type": "string"
                          }
                        }
                      }
                    },
                    "postbackUrlTemplate": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "isPreset": {
                      "type": "boolean"
                    },
                    "createdAt": {
                      "format": "date-time",
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      },
      "put": {
        "operationId": "putApiV1TrackerCloakerTrafficSourcesById",
        "summary": "Update a Tracker & Cloaker traffic source",
        "tags": [
          "tracker-cloaker"
        ],
        "description": "Updates an existing traffic source.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "properties": {
                  "name": {
                    "minLength": 1,
                    "maxLength": 200,
                    "type": "string"
                  },
                  "platform": {
                    "anyOf": [
                      {
                        "type": "string",
                        "enum": [
                          "facebook"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "google"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "tiktok"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "taboola"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "outbrain"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "push"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "custom"
                        ]
                      }
                    ]
                  },
                  "param_mapping": {
                    "anyOf": [
                      {
                        "description": "JSON object with nested arrays and objects.",
                        "type": "object",
                        "additionalProperties": {
                          "$comment": "json-value",
                          "description": "Arbitrary JSON value with nested arrays and objects."
                        }
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "parameters": {
                    "maxItems": 10,
                    "type": "array",
                    "items": {
                      "additionalProperties": false,
                      "type": "object",
                      "properties": {
                        "sub_id_position": {
                          "minimum": 1,
                          "maximum": 10,
                          "type": "integer"
                        },
                        "position": {
                          "minimum": 1,
                          "maximum": 10,
                          "type": "integer"
                        },
                        "key": {
                          "minLength": 1,
                          "maxLength": 40,
                          "type": "string"
                        },
                        "placeholder": {
                          "maxLength": 100,
                          "type": "string"
                        },
                        "macro": {
                          "maxLength": 100,
                          "type": "string"
                        },
                        "name": {
                          "maxLength": 40,
                          "type": "string"
                        },
                        "param": {
                          "maxLength": 40,
                          "type": "string"
                        }
                      }
                    }
                  },
                  "postback_url_template": {
                    "anyOf": [
                      {
                        "maxLength": 4000,
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          },
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "header",
            "name": "x-team-id",
            "required": false,
            "description": "Destination workspace team id."
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "id",
                    "teamId",
                    "name",
                    "platform",
                    "paramMapping",
                    "parameters",
                    "postbackUrlTemplate",
                    "isPreset",
                    "createdAt"
                  ],
                  "properties": {
                    "id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "teamId": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "name": {
                      "type": "string"
                    },
                    "platform": {
                      "type": "string"
                    },
                    "paramMapping": {
                      "description": "Map of canonical parameter keys to traffic-source macros, or null when unset.",
                      "anyOf": [
                        {
                          "type": "object",
                          "additionalProperties": {
                            "type": "string"
                          }
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "parameters": {
                      "type": "array",
                      "items": {
                        "additionalProperties": false,
                        "type": "object",
                        "properties": {
                          "sub_id_position": {
                            "minimum": 1,
                            "maximum": 10,
                            "type": "integer"
                          },
                          "position": {
                            "minimum": 1,
                            "maximum": 10,
                            "type": "integer"
                          },
                          "key": {
                            "minLength": 1,
                            "maxLength": 40,
                            "type": "string"
                          },
                          "placeholder": {
                            "maxLength": 100,
                            "type": "string"
                          },
                          "macro": {
                            "maxLength": 100,
                            "type": "string"
                          },
                          "name": {
                            "maxLength": 40,
                            "type": "string"
                          },
                          "param": {
                            "maxLength": 40,
                            "type": "string"
                          }
                        }
                      }
                    },
                    "postbackUrlTemplate": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "isPreset": {
                      "type": "boolean"
                    },
                    "createdAt": {
                      "format": "date-time",
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "anyOf": [
                    {
                      "description": "Explicit destination workspace required: send the x-team-id header or activate a team scope for this operation.",
                      "additionalProperties": false,
                      "type": "object",
                      "required": [
                        "statusCode",
                        "error",
                        "message"
                      ],
                      "properties": {
                        "statusCode": {
                          "type": "number"
                        },
                        "error": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "code": {
                          "type": "string",
                          "enum": [
                            "SCOPE_TEAM_REQUIRED"
                          ]
                        }
                      }
                    },
                    {
                      "type": "object",
                      "required": [
                        "statusCode",
                        "error",
                        "message"
                      ],
                      "properties": {
                        "statusCode": {
                          "type": "number"
                        },
                        "error": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      },
      "delete": {
        "operationId": "deleteApiV1TrackerCloakerTrafficSourcesById",
        "summary": "Delete a Tracker & Cloaker traffic source",
        "tags": [
          "tracker-cloaker"
        ],
        "description": "Permanently deletes a traffic source.",
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          },
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "header",
            "name": "x-team-id",
            "required": false,
            "description": "Destination workspace team id."
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "deleted"
                  ],
                  "properties": {
                    "deleted": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Explicit destination workspace required: send the x-team-id header or activate a team scope for this operation.",
            "content": {
              "application/json": {
                "schema": {
                  "description": "Explicit destination workspace required: send the x-team-id header or activate a team scope for this operation.",
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "SCOPE_TEAM_REQUIRED"
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/team-branding": {
      "get": {
        "operationId": "getApiV1TeamBranding",
        "summary": "Get agency branding for the current session",
        "tags": [
          "reports"
        ],
        "description": "Returns the white-label agency branding configured for the current session, or null fields when no branding exists.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "agency_name",
                    "logo_url",
                    "primary_color",
                    "secondary_color",
                    "report_footer"
                  ],
                  "properties": {
                    "agency_name": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "logo_url": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "primary_color": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "secondary_color": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "report_footer": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      },
      "put": {
        "operationId": "putApiV1TeamBranding",
        "summary": "Update agency branding for the current session",
        "tags": [
          "reports"
        ],
        "description": "Updates white-label branding text and colors for the current owner/admin session after plan entitlement checks.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "properties": {
                  "agency_name": {
                    "anyOf": [
                      {
                        "maxLength": 255,
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "primary_color": {
                    "anyOf": [
                      {
                        "pattern": "^#[0-9A-Fa-f]{6}$",
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "secondary_color": {
                    "anyOf": [
                      {
                        "pattern": "^#[0-9A-Fa-f]{6}$",
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "report_footer": {
                    "anyOf": [
                      {
                        "maxLength": 2000,
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "agency_name",
                    "logo_url",
                    "primary_color",
                    "secondary_color",
                    "report_footer"
                  ],
                  "properties": {
                    "agency_name": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "logo_url": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "primary_color": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "secondary_color": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "report_footer": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/team-branding/logo": {
      "post": {
        "operationId": "postApiV1TeamBrandingLogo",
        "summary": "Upload agency logo (PNG/JPG/WebP, max 2MB)",
        "tags": [
          "reports"
        ],
        "description": "Uploads a raster agency logo, validates magic bytes and size, stores it locally or in S3, and saves the resulting logo URL.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "logo_url"
                  ],
                  "properties": {
                    "logo_url": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "413": {
            "description": "Payload too large",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/team/transfer-ownership": {
      "post": {
        "operationId": "postApiV1TeamTransferOwnership",
        "summary": "Transfer team ownership to another member",
        "tags": [
          "teams"
        ],
        "description": "Transfers ownership of the team to another active member. The current owner becomes a mediabuyer. Requires password verification for owners with a local credential; SSO-only owners authenticate via JWT alone.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "target_user_id"
                ],
                "properties": {
                  "target_user_id": {
                    "format": "uuid",
                    "type": "string"
                  },
                  "password": {
                    "maxLength": 128,
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "message"
                  ],
                  "properties": {
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/team/delete": {
      "post": {
        "operationId": "postApiV1TeamDelete",
        "summary": "Schedule team deletion (30 days)",
        "tags": [
          "teams"
        ],
        "description": "Schedules the team and all its members for deletion after a 30-day grace period. Requires typing \"DELETE\" as confirmation. Password is required only for owners with a local credential; SSO-only owners authenticate via JWT alone.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "confirmation"
                ],
                "properties": {
                  "password": {
                    "maxLength": 128,
                    "type": "string"
                  },
                  "confirmation": {
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "message",
                    "deletion_scheduled_at"
                  ],
                  "properties": {
                    "message": {
                      "type": "string"
                    },
                    "deletion_scheduled_at": {
                      "format": "date-time",
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/team/cancel-deletion": {
      "post": {
        "operationId": "postApiV1TeamCancelDeletion",
        "summary": "Cancel scheduled team deletion",
        "tags": [
          "teams"
        ],
        "description": "Cancels a previously scheduled team deletion for the owner and all team members.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "message"
                  ],
                  "properties": {
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/team/invite": {
      "post": {
        "operationId": "postApiV1TeamInvite",
        "summary": "Send a team invite",
        "tags": [
          "teams"
        ],
        "description": "Sends an invite email to a new or existing user to join the team with the specified role. Invite expires after 7 days.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "email",
                  "role"
                ],
                "properties": {
                  "email": {
                    "format": "email",
                    "maxLength": 255,
                    "type": "string"
                  },
                  "role": {
                    "anyOf": [
                      {
                        "type": "string",
                        "enum": [
                          "mediabuyer"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "manager"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "viewer"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "finance"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "owner"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "admin"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "member"
                        ]
                      }
                    ]
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "201": {
            "description": "Resource created",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "id",
                    "email",
                    "role",
                    "status",
                    "team_id",
                    "expires_at",
                    "created_at"
                  ],
                  "properties": {
                    "id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "email": {
                      "type": "string"
                    },
                    "role": {
                      "type": "string"
                    },
                    "status": {
                      "type": "string"
                    },
                    "team_id": {
                      "description": "RBAC team the invitee will join",
                      "anyOf": [
                        {
                          "format": "uuid",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "expires_at": {
                      "format": "date-time",
                      "type": "string"
                    },
                    "created_at": {
                      "format": "date-time",
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "current": {
                      "type": "number"
                    },
                    "max": {
                      "anyOf": [
                        {
                          "type": "number"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "current": {
                      "type": "number"
                    },
                    "max": {
                      "anyOf": [
                        {
                          "type": "number"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "Conflict - resource state prevents the operation",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "current": {
                      "type": "number"
                    },
                    "max": {
                      "anyOf": [
                        {
                          "type": "number"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "current": {
                      "type": "number"
                    },
                    "max": {
                      "anyOf": [
                        {
                          "type": "number"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/team/invites": {
      "get": {
        "operationId": "getApiV1TeamInvites",
        "summary": "List pending team invites",
        "tags": [
          "teams"
        ],
        "description": "Returns all pending and non-expired invites for the caller's team.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "items",
                    "total"
                  ],
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "id",
                          "email",
                          "role",
                          "status",
                          "team_id",
                          "expires_at",
                          "created_at"
                        ],
                        "properties": {
                          "id": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "email": {
                            "type": "string"
                          },
                          "role": {
                            "type": "string"
                          },
                          "status": {
                            "type": "string"
                          },
                          "team_id": {
                            "description": "RBAC team the invitee will join",
                            "anyOf": [
                              {
                                "format": "uuid",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "expires_at": {
                            "format": "date-time",
                            "type": "string"
                          },
                          "created_at": {
                            "format": "date-time",
                            "type": "string"
                          }
                        }
                      }
                    },
                    "total": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "current": {
                      "type": "number"
                    },
                    "max": {
                      "anyOf": [
                        {
                          "type": "number"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "current": {
                      "type": "number"
                    },
                    "max": {
                      "anyOf": [
                        {
                          "type": "number"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/team/invites/{id}": {
      "delete": {
        "operationId": "deleteApiV1TeamInvitesById",
        "summary": "Cancel a pending team invite",
        "tags": [
          "teams"
        ],
        "description": "Cancels a pending invite so it can no longer be accepted.",
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "message"
                  ],
                  "properties": {
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "current": {
                      "type": "number"
                    },
                    "max": {
                      "anyOf": [
                        {
                          "type": "number"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "current": {
                      "type": "number"
                    },
                    "max": {
                      "anyOf": [
                        {
                          "type": "number"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "current": {
                      "type": "number"
                    },
                    "max": {
                      "anyOf": [
                        {
                          "type": "number"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "current": {
                      "type": "number"
                    },
                    "max": {
                      "anyOf": [
                        {
                          "type": "number"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/team/invites/{id}/resend": {
      "post": {
        "operationId": "postApiV1TeamInvitesByIdResend",
        "summary": "Resend a pending team invite (atomic cancel + create)",
        "tags": [
          "teams"
        ],
        "description": "Atomically cancels the existing pending invite (guarded by current status) and issues a fresh one with a new token. The original is never cancelled unless the replacement is also created in the same transaction; an invite that was accepted/cancelled between request and write is rejected with 404.",
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "201": {
            "description": "Resource created",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "id",
                    "email",
                    "role",
                    "status",
                    "team_id",
                    "expires_at",
                    "created_at"
                  ],
                  "properties": {
                    "id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "email": {
                      "type": "string"
                    },
                    "role": {
                      "type": "string"
                    },
                    "status": {
                      "type": "string"
                    },
                    "team_id": {
                      "description": "RBAC team the invitee will join",
                      "anyOf": [
                        {
                          "format": "uuid",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "expires_at": {
                      "format": "date-time",
                      "type": "string"
                    },
                    "created_at": {
                      "format": "date-time",
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "current": {
                      "type": "number"
                    },
                    "max": {
                      "anyOf": [
                        {
                          "type": "number"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "current": {
                      "type": "number"
                    },
                    "max": {
                      "anyOf": [
                        {
                          "type": "number"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "current": {
                      "type": "number"
                    },
                    "max": {
                      "anyOf": [
                        {
                          "type": "number"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "current": {
                      "type": "number"
                    },
                    "max": {
                      "anyOf": [
                        {
                          "type": "number"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/team/invite/verify/{token}": {
      "get": {
        "operationId": "getApiV1TeamInviteVerifyByToken",
        "summary": "Verify a team invite token",
        "tags": [
          "teams"
        ],
        "description": "Validates an invite token and returns invite details (email, role, team name). Public endpoint, no auth required.",
        "parameters": [
          {
            "schema": {
              "minLength": 1,
              "type": "string"
            },
            "in": "path",
            "name": "token",
            "required": true
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "valid"
                  ],
                  "properties": {
                    "valid": {
                      "type": "boolean"
                    },
                    "email": {
                      "type": "string"
                    },
                    "role": {
                      "type": "string"
                    },
                    "team_name": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "inviter_name": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "user_exists": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "current": {
                      "type": "number"
                    },
                    "max": {
                      "anyOf": [
                        {
                          "type": "number"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/team/invite/accept": {
      "post": {
        "operationId": "postApiV1TeamInviteAccept",
        "summary": "Accept a team invite",
        "tags": [
          "teams"
        ],
        "description": "Accepts a team invite. For existing users, adds them to the invite's team with the invited RBAC role. For new users, creates an account with the provided name and password and enrolls it in the team.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "token"
                ],
                "properties": {
                  "token": {
                    "minLength": 1,
                    "type": "string"
                  },
                  "name": {
                    "maxLength": 255,
                    "type": "string"
                  },
                  "password": {
                    "minLength": 12,
                    "maxLength": 128,
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "message",
                    "user_id"
                  ],
                  "properties": {
                    "message": {
                      "type": "string"
                    },
                    "user_id": {
                      "format": "uuid",
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "current": {
                      "type": "number"
                    },
                    "max": {
                      "anyOf": [
                        {
                          "type": "number"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "current": {
                      "type": "number"
                    },
                    "max": {
                      "anyOf": [
                        {
                          "type": "number"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "422": {
            "description": "Unprocessable entity - semantic validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "current": {
                      "type": "number"
                    },
                    "max": {
                      "anyOf": [
                        {
                          "type": "number"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "current": {
                      "type": "number"
                    },
                    "max": {
                      "anyOf": [
                        {
                          "type": "number"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ]
      }
    },
    "/api/v1/team/knowledge": {
      "get": {
        "operationId": "getApiV1TeamKnowledge",
        "summary": "List team knowledge entries",
        "tags": [
          "team"
        ],
        "description": "Lists the shared knowledge entries of the team of the active workspace scope. Active entries are injected into every Wavo conversation of that team.",
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "items",
                    "limit"
                  ],
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "additionalProperties": false,
                        "type": "object",
                        "required": [
                          "id",
                          "team_id",
                          "title",
                          "content",
                          "is_active",
                          "created_at",
                          "updated_at"
                        ],
                        "properties": {
                          "id": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "team_id": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "title": {
                            "type": "string"
                          },
                          "content": {
                            "type": "string"
                          },
                          "is_active": {
                            "type": "boolean"
                          },
                          "created_at": {
                            "format": "date-time",
                            "type": "string"
                          },
                          "updated_at": {
                            "format": "date-time",
                            "type": "string"
                          }
                        }
                      }
                    },
                    "limit": {
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "postApiV1TeamKnowledge",
        "summary": "Create a team knowledge entry",
        "tags": [
          "team"
        ],
        "description": "Creates a shared knowledge entry on the team of the active workspace scope. Fails with 409 once that team reaches 30 entries.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "title",
                  "content"
                ],
                "properties": {
                  "title": {
                    "minLength": 1,
                    "maxLength": 200,
                    "type": "string"
                  },
                  "content": {
                    "minLength": 1,
                    "maxLength": 2000,
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "id",
                    "team_id",
                    "title",
                    "content",
                    "is_active",
                    "created_at",
                    "updated_at"
                  ],
                  "properties": {
                    "id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "team_id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "title": {
                      "type": "string"
                    },
                    "content": {
                      "type": "string"
                    },
                    "is_active": {
                      "type": "boolean"
                    },
                    "created_at": {
                      "format": "date-time",
                      "type": "string"
                    },
                    "updated_at": {
                      "format": "date-time",
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "Conflict - resource state prevents the operation",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/team/knowledge/{id}": {
      "patch": {
        "operationId": "patchApiV1TeamKnowledgeById",
        "summary": "Update a team knowledge entry",
        "tags": [
          "team"
        ],
        "description": "Updates the title, body or active flag of an entry of the active workspace scope team. Setting is_active to false keeps the entry but stops Wavo from using it.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "properties": {
                  "title": {
                    "minLength": 1,
                    "maxLength": 200,
                    "type": "string"
                  },
                  "content": {
                    "minLength": 1,
                    "maxLength": 2000,
                    "type": "string"
                  },
                  "is_active": {
                    "type": "boolean"
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "id",
                    "team_id",
                    "title",
                    "content",
                    "is_active",
                    "created_at",
                    "updated_at"
                  ],
                  "properties": {
                    "id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "team_id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "title": {
                      "type": "string"
                    },
                    "content": {
                      "type": "string"
                    },
                    "is_active": {
                      "type": "boolean"
                    },
                    "created_at": {
                      "format": "date-time",
                      "type": "string"
                    },
                    "updated_at": {
                      "format": "date-time",
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          }
        }
      },
      "delete": {
        "operationId": "deleteApiV1TeamKnowledgeById",
        "summary": "Delete a team knowledge entry",
        "tags": [
          "team"
        ],
        "description": "Permanently removes a shared knowledge entry from the active workspace scope team.",
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "deleted"
                  ],
                  "properties": {
                    "deleted": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/team-workspace": {
      "get": {
        "operationId": "getApiV1TeamWorkspace",
        "summary": "Get team workspace preset",
        "tags": [
          "workspace"
        ],
        "description": "Get the active workspace preset for the current team",
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "config",
                    "id",
                    "is_active",
                    "preset_name",
                    "profile",
                    "resolver_version",
                    "team_id"
                  ],
                  "properties": {
                    "config": {
                      "type": "object",
                      "required": [
                        "enabled_module_ids",
                        "hub_order",
                        "locked_module_ids",
                        "pinned_module_ids",
                        "policy"
                      ],
                      "properties": {
                        "enabled_module_ids": {
                          "type": "array",
                          "items": {
                            "type": "string"
                          }
                        },
                        "hub_order": {
                          "type": "array",
                          "items": {
                            "type": "string"
                          }
                        },
                        "locked_module_ids": {
                          "type": "array",
                          "items": {
                            "type": "string"
                          }
                        },
                        "pinned_module_ids": {
                          "type": "array",
                          "items": {
                            "type": "string"
                          }
                        },
                        "policy": {
                          "type": "object",
                          "required": [
                            "allow_user_hide",
                            "allow_user_pin",
                            "allow_user_reorder",
                            "allow_user_templates"
                          ],
                          "properties": {
                            "allow_user_hide": {
                              "type": "boolean"
                            },
                            "allow_user_pin": {
                              "type": "boolean"
                            },
                            "allow_user_reorder": {
                              "type": "boolean"
                            },
                            "allow_user_templates": {
                              "type": "boolean"
                            }
                          }
                        },
                        "default_conversion_source": {
                          "type": "string"
                        }
                      }
                    },
                    "id": {
                      "type": "string"
                    },
                    "is_active": {
                      "type": "boolean"
                    },
                    "preset_name": {
                      "type": "string"
                    },
                    "profile": {
                      "type": "string"
                    },
                    "resolver_version": {
                      "type": "string"
                    },
                    "team_id": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/team-workspace/profile": {
      "put": {
        "operationId": "putApiV1TeamWorkspaceProfile",
        "summary": "Update team workspace profile",
        "tags": [
          "workspace"
        ],
        "description": "Update the workspace profile for the current team",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "profile"
                ],
                "properties": {
                  "profile": {
                    "anyOf": [
                      {
                        "type": "string",
                        "enum": [
                          "affiliate"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "brand"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "agency"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "enterprise"
                        ]
                      }
                    ]
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "config",
                    "id",
                    "is_active",
                    "preset_name",
                    "profile",
                    "resolver_version",
                    "team_id"
                  ],
                  "properties": {
                    "config": {
                      "type": "object",
                      "required": [
                        "enabled_module_ids",
                        "hub_order",
                        "locked_module_ids",
                        "pinned_module_ids",
                        "policy"
                      ],
                      "properties": {
                        "enabled_module_ids": {
                          "type": "array",
                          "items": {
                            "type": "string"
                          }
                        },
                        "hub_order": {
                          "type": "array",
                          "items": {
                            "type": "string"
                          }
                        },
                        "locked_module_ids": {
                          "type": "array",
                          "items": {
                            "type": "string"
                          }
                        },
                        "pinned_module_ids": {
                          "type": "array",
                          "items": {
                            "type": "string"
                          }
                        },
                        "policy": {
                          "type": "object",
                          "required": [
                            "allow_user_hide",
                            "allow_user_pin",
                            "allow_user_reorder",
                            "allow_user_templates"
                          ],
                          "properties": {
                            "allow_user_hide": {
                              "type": "boolean"
                            },
                            "allow_user_pin": {
                              "type": "boolean"
                            },
                            "allow_user_reorder": {
                              "type": "boolean"
                            },
                            "allow_user_templates": {
                              "type": "boolean"
                            }
                          }
                        },
                        "default_conversion_source": {
                          "type": "string"
                        }
                      }
                    },
                    "id": {
                      "type": "string"
                    },
                    "is_active": {
                      "type": "boolean"
                    },
                    "preset_name": {
                      "type": "string"
                    },
                    "profile": {
                      "type": "string"
                    },
                    "resolver_version": {
                      "type": "string"
                    },
                    "team_id": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/team-workspace/preset": {
      "put": {
        "operationId": "putApiV1TeamWorkspacePreset",
        "summary": "Update team workspace preset",
        "tags": [
          "workspace"
        ],
        "description": "Update the active workspace preset configuration",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "config"
                ],
                "properties": {
                  "config": {
                    "additionalProperties": false,
                    "type": "object",
                    "required": [
                      "enabled_module_ids",
                      "hub_order",
                      "locked_module_ids",
                      "pinned_module_ids",
                      "policy"
                    ],
                    "properties": {
                      "enabled_module_ids": {
                        "maxItems": 100,
                        "type": "array",
                        "items": {
                          "maxLength": 100,
                          "type": "string"
                        }
                      },
                      "hub_order": {
                        "maxItems": 100,
                        "type": "array",
                        "items": {
                          "maxLength": 100,
                          "type": "string"
                        }
                      },
                      "locked_module_ids": {
                        "maxItems": 100,
                        "type": "array",
                        "items": {
                          "maxLength": 100,
                          "type": "string"
                        }
                      },
                      "pinned_module_ids": {
                        "maxItems": 100,
                        "type": "array",
                        "items": {
                          "maxLength": 100,
                          "type": "string"
                        }
                      },
                      "policy": {
                        "additionalProperties": false,
                        "type": "object",
                        "required": [
                          "allow_user_hide",
                          "allow_user_pin",
                          "allow_user_reorder",
                          "allow_user_templates"
                        ],
                        "properties": {
                          "allow_user_hide": {
                            "type": "boolean"
                          },
                          "allow_user_pin": {
                            "type": "boolean"
                          },
                          "allow_user_reorder": {
                            "type": "boolean"
                          },
                          "allow_user_templates": {
                            "type": "boolean"
                          }
                        }
                      },
                      "default_conversion_source": {
                        "maxLength": 20,
                        "type": "string"
                      }
                    }
                  },
                  "preset_name": {
                    "maxLength": 255,
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "config",
                    "id",
                    "is_active",
                    "preset_name",
                    "profile",
                    "resolver_version",
                    "team_id"
                  ],
                  "properties": {
                    "config": {
                      "type": "object",
                      "required": [
                        "enabled_module_ids",
                        "hub_order",
                        "locked_module_ids",
                        "pinned_module_ids",
                        "policy"
                      ],
                      "properties": {
                        "enabled_module_ids": {
                          "type": "array",
                          "items": {
                            "type": "string"
                          }
                        },
                        "hub_order": {
                          "type": "array",
                          "items": {
                            "type": "string"
                          }
                        },
                        "locked_module_ids": {
                          "type": "array",
                          "items": {
                            "type": "string"
                          }
                        },
                        "pinned_module_ids": {
                          "type": "array",
                          "items": {
                            "type": "string"
                          }
                        },
                        "policy": {
                          "type": "object",
                          "required": [
                            "allow_user_hide",
                            "allow_user_pin",
                            "allow_user_reorder",
                            "allow_user_templates"
                          ],
                          "properties": {
                            "allow_user_hide": {
                              "type": "boolean"
                            },
                            "allow_user_pin": {
                              "type": "boolean"
                            },
                            "allow_user_reorder": {
                              "type": "boolean"
                            },
                            "allow_user_templates": {
                              "type": "boolean"
                            }
                          }
                        },
                        "default_conversion_source": {
                          "type": "string"
                        }
                      }
                    },
                    "id": {
                      "type": "string"
                    },
                    "is_active": {
                      "type": "boolean"
                    },
                    "preset_name": {
                      "type": "string"
                    },
                    "profile": {
                      "type": "string"
                    },
                    "resolver_version": {
                      "type": "string"
                    },
                    "team_id": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/team-workspace/preset/reset": {
      "post": {
        "operationId": "postApiV1TeamWorkspacePresetReset",
        "summary": "Reset team workspace preset",
        "tags": [
          "workspace"
        ],
        "description": "Reset the workspace preset to default for the current profile",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "config",
                    "id",
                    "is_active",
                    "preset_name",
                    "profile",
                    "resolver_version",
                    "team_id"
                  ],
                  "properties": {
                    "config": {
                      "type": "object",
                      "required": [
                        "enabled_module_ids",
                        "hub_order",
                        "locked_module_ids",
                        "pinned_module_ids",
                        "policy"
                      ],
                      "properties": {
                        "enabled_module_ids": {
                          "type": "array",
                          "items": {
                            "type": "string"
                          }
                        },
                        "hub_order": {
                          "type": "array",
                          "items": {
                            "type": "string"
                          }
                        },
                        "locked_module_ids": {
                          "type": "array",
                          "items": {
                            "type": "string"
                          }
                        },
                        "pinned_module_ids": {
                          "type": "array",
                          "items": {
                            "type": "string"
                          }
                        },
                        "policy": {
                          "type": "object",
                          "required": [
                            "allow_user_hide",
                            "allow_user_pin",
                            "allow_user_reorder",
                            "allow_user_templates"
                          ],
                          "properties": {
                            "allow_user_hide": {
                              "type": "boolean"
                            },
                            "allow_user_pin": {
                              "type": "boolean"
                            },
                            "allow_user_reorder": {
                              "type": "boolean"
                            },
                            "allow_user_templates": {
                              "type": "boolean"
                            }
                          }
                        },
                        "default_conversion_source": {
                          "type": "string"
                        }
                      }
                    },
                    "id": {
                      "type": "string"
                    },
                    "is_active": {
                      "type": "boolean"
                    },
                    "preset_name": {
                      "type": "string"
                    },
                    "profile": {
                      "type": "string"
                    },
                    "resolver_version": {
                      "type": "string"
                    },
                    "team_id": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/team/members": {
      "get": {
        "operationId": "getApiV1TeamMembers",
        "summary": "List team members (owner/manager)",
        "tags": [
          "teams"
        ],
        "description": "Returns all members of the caller's current team. Accessible to owners and managers (and super_admin).",
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "from_date",
            "required": false
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "to_date",
            "required": false
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "currency",
            "required": false
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "timezone",
            "required": false
          },
          {
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "enum": [
                    "postback"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "all"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "meta"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "google"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "tiktok"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "taboola"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "snapchat"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "outbrain"
                  ]
                }
              ]
            },
            "in": "query",
            "name": "conversion_source",
            "required": false,
            "description": "Revenue/conversion data source. \"postback\" (default) uses postback conversions; \"all\" aggregates platform-native purchase data across every platform; a platform value (e.g. \"meta\", \"google\") scopes platform-native revenue to that platform."
          }
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "items",
                    "total"
                  ],
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "id",
                          "name",
                          "email",
                          "role",
                          "is_founder",
                          "is_active",
                          "last_login"
                        ],
                        "properties": {
                          "id": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "name": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "email": {
                            "type": "string"
                          },
                          "role": {
                            "type": "string"
                          },
                          "is_founder": {
                            "type": "boolean"
                          },
                          "is_active": {
                            "type": "boolean"
                          },
                          "last_login": {
                            "anyOf": [
                              {
                                "format": "date-time",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "stats": {
                            "type": "object",
                            "required": [
                              "total_spend",
                              "campaigns_active",
                              "roi",
                              "total_conversions",
                              "total_revenue",
                              "profit"
                            ],
                            "properties": {
                              "total_spend": {
                                "type": "number"
                              },
                              "campaigns_active": {
                                "type": "number"
                              },
                              "roi": {
                                "type": "number"
                              },
                              "total_conversions": {
                                "type": "number"
                              },
                              "total_revenue": {
                                "type": "number"
                              },
                              "profit": {
                                "type": "number"
                              }
                            }
                          }
                        }
                      }
                    },
                    "total": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "feature": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "feature": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/team/impersonate": {
      "post": {
        "operationId": "postApiV1TeamImpersonate",
        "summary": "Impersonate a team member (owner only)",
        "tags": [
          "teams"
        ],
        "description": "Generates a JWT for a mediabuyer in the owner team, allowing the owner to view their data.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "user_id"
                ],
                "properties": {
                  "user_id": {
                    "format": "uuid",
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "token",
                    "user"
                  ],
                  "properties": {
                    "token": {
                      "type": "string"
                    },
                    "user": {
                      "type": "object",
                      "required": [
                        "id",
                        "name",
                        "email",
                        "role",
                        "created_at",
                        "last_login",
                        "is_active",
                        "primary_team_id"
                      ],
                      "properties": {
                        "id": {
                          "format": "uuid",
                          "type": "string"
                        },
                        "name": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "email": {
                          "type": "string"
                        },
                        "role": {
                          "type": "string"
                        },
                        "created_at": {
                          "format": "date-time",
                          "type": "string"
                        },
                        "last_login": {
                          "anyOf": [
                            {
                              "format": "date-time",
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "is_active": {
                          "type": "boolean"
                        },
                        "primary_team_id": {
                          "anyOf": [
                            {
                              "format": "uuid",
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "feature": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "feature": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "feature": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/team/members/{id}/role": {
      "patch": {
        "operationId": "patchApiV1TeamMembersByIdRole",
        "summary": "Update team member role",
        "tags": [
          "teams"
        ],
        "description": "Changes the role of a team member. Only the team owner can update roles.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "role"
                ],
                "properties": {
                  "role": {
                    "anyOf": [
                      {
                        "type": "string",
                        "enum": [
                          "owner"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "mediabuyer"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "manager"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "viewer"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "finance"
                        ]
                      }
                    ]
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "id",
                    "email",
                    "role",
                    "is_active"
                  ],
                  "properties": {
                    "id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "email": {
                      "type": "string"
                    },
                    "role": {
                      "type": "string"
                    },
                    "is_active": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "feature": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "feature": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "feature": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "feature": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/team/members/{id}/status": {
      "patch": {
        "operationId": "patchApiV1TeamMembersByIdStatus",
        "summary": "Activate or deactivate a team member",
        "tags": [
          "teams"
        ],
        "description": "Enables or disables a team member account. Deactivating a member also force-logs them out.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "is_active"
                ],
                "properties": {
                  "is_active": {
                    "type": "boolean"
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "id",
                    "email",
                    "role",
                    "is_active"
                  ],
                  "properties": {
                    "id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "email": {
                      "type": "string"
                    },
                    "role": {
                      "type": "string"
                    },
                    "is_active": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "feature": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "feature": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "feature": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "Conflict - resource state prevents the operation",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "feature": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "feature": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/team/members/{id}": {
      "delete": {
        "operationId": "deleteApiV1TeamMembersById",
        "summary": "Remove a team member from the current team",
        "tags": [
          "teams"
        ],
        "description": "Kicks a member out of the current team without deleting or deactivating their user account or BetterAuth credentials.",
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "message"
                  ],
                  "properties": {
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "feature": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "feature": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "feature": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "Conflict - resource state prevents the operation",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "feature": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "feature": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/telegram/link": {
      "post": {
        "operationId": "postApiV1TelegramLink",
        "summary": "Generate Telegram link token",
        "tags": [
          "telegram"
        ],
        "description": "Generates a one-time token to link the user's Telegram account to their Wevion account.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "token",
                    "deep_link"
                  ],
                  "properties": {
                    "token": {
                      "type": "string"
                    },
                    "deep_link": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "Service unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/telegram/unlink": {
      "delete": {
        "operationId": "deleteApiV1TelegramUnlink",
        "summary": "Unlink Telegram account",
        "tags": [
          "telegram"
        ],
        "description": "Removes the link between the user's Telegram account and their Wevion account.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "204": {
            "description": "No content"
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "503": {
            "description": "Service unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/telegram/status": {
      "get": {
        "operationId": "getApiV1TelegramStatus",
        "summary": "Get Telegram link status",
        "tags": [
          "telegram"
        ],
        "description": "Returns whether the user's Telegram account is linked and the associated Telegram profile info.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "linked"
                  ],
                  "properties": {
                    "linked": {
                      "type": "boolean"
                    },
                    "username": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "first_name": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "linked_at": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "is_active": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/telegram/preferences": {
      "get": {
        "operationId": "getApiV1TelegramPreferences",
        "summary": "Get Telegram notification preferences",
        "tags": [
          "telegram"
        ],
        "description": "Returns the user's Telegram notification alert and digest preferences. Returns defaults if no preferences are saved.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "alert_account_status",
                    "alert_spend_cap",
                    "alert_campaign_approved",
                    "alert_campaign_disapproved",
                    "alert_delivery_error",
                    "alert_sync_completed",
                    "alert_sync_failed",
                    "alert_report_ready",
                    "alert_bulk_launch",
                    "alert_token_expiring",
                    "alert_payment_issue",
                    "alert_rule_executed",
                    "daily_digest_enabled",
                    "daily_digest_hour",
                    "weekly_digest_enabled",
                    "weekly_digest_day",
                    "weekly_digest_hour",
                    "digest_timezone"
                  ],
                  "properties": {
                    "alert_account_status": {
                      "type": "boolean"
                    },
                    "alert_spend_cap": {
                      "type": "boolean"
                    },
                    "alert_campaign_approved": {
                      "type": "boolean"
                    },
                    "alert_campaign_disapproved": {
                      "type": "boolean"
                    },
                    "alert_delivery_error": {
                      "type": "boolean"
                    },
                    "alert_sync_completed": {
                      "type": "boolean"
                    },
                    "alert_sync_failed": {
                      "type": "boolean"
                    },
                    "alert_report_ready": {
                      "type": "boolean"
                    },
                    "alert_bulk_launch": {
                      "type": "boolean"
                    },
                    "alert_token_expiring": {
                      "type": "boolean"
                    },
                    "alert_payment_issue": {
                      "type": "boolean"
                    },
                    "alert_rule_executed": {
                      "type": "boolean"
                    },
                    "daily_digest_enabled": {
                      "type": "boolean"
                    },
                    "daily_digest_hour": {
                      "type": "number"
                    },
                    "weekly_digest_enabled": {
                      "type": "boolean"
                    },
                    "weekly_digest_day": {
                      "type": "number"
                    },
                    "weekly_digest_hour": {
                      "type": "number"
                    },
                    "digest_timezone": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      },
      "put": {
        "operationId": "putApiV1TelegramPreferences",
        "summary": "Update Telegram notification preferences",
        "tags": [
          "telegram"
        ],
        "description": "Updates the user's Telegram notification alert and digest preferences. Supports partial updates.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "alert_account_status": {
                    "type": "boolean"
                  },
                  "alert_spend_cap": {
                    "type": "boolean"
                  },
                  "alert_campaign_approved": {
                    "type": "boolean"
                  },
                  "alert_campaign_disapproved": {
                    "type": "boolean"
                  },
                  "alert_delivery_error": {
                    "type": "boolean"
                  },
                  "alert_sync_completed": {
                    "type": "boolean"
                  },
                  "alert_sync_failed": {
                    "type": "boolean"
                  },
                  "alert_report_ready": {
                    "type": "boolean"
                  },
                  "alert_bulk_launch": {
                    "type": "boolean"
                  },
                  "alert_token_expiring": {
                    "type": "boolean"
                  },
                  "alert_payment_issue": {
                    "type": "boolean"
                  },
                  "alert_rule_executed": {
                    "type": "boolean"
                  },
                  "daily_digest_enabled": {
                    "type": "boolean"
                  },
                  "daily_digest_hour": {
                    "minimum": 0,
                    "maximum": 23,
                    "type": "number"
                  },
                  "weekly_digest_enabled": {
                    "type": "boolean"
                  },
                  "weekly_digest_day": {
                    "minimum": 0,
                    "maximum": 6,
                    "type": "number"
                  },
                  "weekly_digest_hour": {
                    "minimum": 0,
                    "maximum": 23,
                    "type": "number"
                  },
                  "digest_timezone": {
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "ok"
                  ],
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/telegram/test": {
      "post": {
        "operationId": "postApiV1TelegramTest",
        "summary": "Send test Telegram message",
        "tags": [
          "telegram"
        ],
        "description": "Sends a test notification message to the user's linked Telegram account to verify the integration.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "ok"
                  ],
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "503": {
            "description": "Service unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/tiktok/identities/check": {
      "get": {
        "operationId": "checkTikTokIdentity",
        "summary": "Check the TikTok TT_USER identity for an advertiser",
        "tags": [
          "tiktok"
        ],
        "description": "Returns whether the advertiser has at least one TT_USER identity (required to publish TikTok ads). When missing, the user must authorize an identity from the TikTok app.",
        "parameters": [
          {
            "schema": {
              "minLength": 1,
              "type": "string"
            },
            "in": "query",
            "name": "advertiser_id",
            "required": true,
            "description": "TikTok advertiser id."
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "hasIdentity"
                  ],
                  "properties": {
                    "hasIdentity": {
                      "description": "true when an authorized TT_USER identity exists.",
                      "type": "boolean"
                    },
                    "identityId": {
                      "type": "string"
                    },
                    "displayName": {
                      "type": "string"
                    },
                    "reason": {
                      "anyOf": [
                        {
                          "type": "string",
                          "enum": [
                            "no_token"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "no_tt_user"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "api_error"
                          ]
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Error response - short human-readable message.",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "description": "Error response - short human-readable message.",
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/tiktok/publish-check": {
      "get": {
        "operationId": "tiktokPublishCheck",
        "summary": "Verify all TikTok publish prerequisites for an objective",
        "tags": [
          "tiktok"
        ],
        "description": "Combined preflight: identity, pixel, catalog, app, and lead form based on the supplied objective. Returns the list of missing prerequisites so the client can prompt the user.",
        "parameters": [
          {
            "schema": {
              "minLength": 1,
              "type": "string"
            },
            "in": "query",
            "name": "advertiser_id",
            "required": true
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "objective",
            "required": false,
            "description": "Optional TikTok campaign objective (e.g. WEB_CONVERSIONS, PRODUCT_SALES, APP_PROMOTION, LEAD_GENERATION)."
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "ready",
                    "missing"
                  ],
                  "properties": {
                    "ready": {
                      "description": "true when no missing prerequisites for the requested objective.",
                      "type": "boolean"
                    },
                    "missing": {
                      "description": "Missing prerequisites for the supplied objective.",
                      "type": "array",
                      "items": {
                        "anyOf": [
                          {
                            "type": "string",
                            "enum": [
                              "identity"
                            ]
                          },
                          {
                            "type": "string",
                            "enum": [
                              "pixel"
                            ]
                          },
                          {
                            "type": "string",
                            "enum": [
                              "catalog"
                            ]
                          },
                          {
                            "type": "string",
                            "enum": [
                              "app"
                            ]
                          },
                          {
                            "type": "string",
                            "enum": [
                              "leadForm"
                            ]
                          }
                        ]
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/tiktok/identities": {
      "get": {
        "operationId": "listTikTokIdentities",
        "summary": "List TikTok identities (TT_USER + CUSTOMIZED_USER)",
        "tags": [
          "tiktok"
        ],
        "description": "Returns every authorized identity available for the advertiser, both TT_USER (linked TikTok accounts) and CUSTOMIZED_USER (custom display profiles).",
        "parameters": [
          {
            "schema": {
              "minLength": 1,
              "type": "string"
            },
            "in": "query",
            "name": "advertiser_id",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "identities"
                  ],
                  "properties": {
                    "identities": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "identity_id",
                          "identity_type",
                          "display_name"
                        ],
                        "properties": {
                          "identity_id": {
                            "type": "string"
                          },
                          "identity_type": {
                            "anyOf": [
                              {
                                "type": "string",
                                "enum": [
                                  "TT_USER"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "CUSTOMIZED_USER"
                                ]
                              }
                            ]
                          },
                          "display_name": {
                            "type": "string"
                          },
                          "image_uri": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Error response - short human-readable message.",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "description": "Error response - short human-readable message.",
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "createTikTokIdentity",
        "summary": "Create a CUSTOMIZED_USER TikTok identity",
        "tags": [
          "tiktok"
        ],
        "description": "Creates a new CUSTOMIZED_USER identity for the advertiser. TT_USER identities cannot be created via API - they require manual authorization from the TikTok app.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "advertiser_id",
                  "display_name"
                ],
                "properties": {
                  "advertiser_id": {
                    "minLength": 1,
                    "type": "string"
                  },
                  "display_name": {
                    "minLength": 1,
                    "maxLength": 40,
                    "type": "string"
                  },
                  "image_uri": {
                    "description": "TikTok image_uri obtained via image upload API.",
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "identity_id",
                    "identity_type",
                    "display_name"
                  ],
                  "properties": {
                    "identity_id": {
                      "type": "string"
                    },
                    "identity_type": {
                      "type": "string",
                      "enum": [
                        "CUSTOMIZED_USER"
                      ]
                    },
                    "display_name": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Error response - short human-readable message.",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "description": "Error response - short human-readable message.",
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Error response - short human-readable message.",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "description": "Error response - short human-readable message.",
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/tiktok/pixels/live": {
      "get": {
        "operationId": "listTikTokPixels",
        "summary": "List TikTok pixels for an advertiser",
        "tags": [
          "tiktok"
        ],
        "description": "Returns the pixels available for the advertiser. Required when launching campaigns with CONVERSIONS / WEB_CONVERSIONS objectives. `meta` exposes `code` and `mode`.",
        "parameters": [
          {
            "schema": {
              "minLength": 1,
              "type": "string"
            },
            "in": "query",
            "name": "advertiser_id",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "items"
                  ],
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "additionalProperties": false,
                        "type": "object",
                        "required": [
                          "id",
                          "name"
                        ],
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "name": {
                            "type": "string"
                          },
                          "meta": {
                            "description": "Free-form per-resource metadata (varies by endpoint, see description).",
                            "type": "object",
                            "additionalProperties": {
                              "$comment": "json-value",
                              "description": "Arbitrary JSON value with nested arrays and objects."
                            }
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/tiktok/apps": {
      "get": {
        "operationId": "listTikTokApps",
        "summary": "List TikTok mobile apps for an advertiser",
        "tags": [
          "tiktok"
        ],
        "description": "Returns the apps registered for the advertiser. Required when launching APP_PROMOTION / APP_INSTALL campaigns. `meta` exposes `package` (bundle id) and `platform` (ANDROID / IOS).",
        "parameters": [
          {
            "schema": {
              "minLength": 1,
              "type": "string"
            },
            "in": "query",
            "name": "advertiser_id",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "items"
                  ],
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "additionalProperties": false,
                        "type": "object",
                        "required": [
                          "id",
                          "name"
                        ],
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "name": {
                            "type": "string"
                          },
                          "meta": {
                            "description": "Free-form per-resource metadata (varies by endpoint, see description).",
                            "type": "object",
                            "additionalProperties": {
                              "$comment": "json-value",
                              "description": "Arbitrary JSON value with nested arrays and objects."
                            }
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/tiktok/catalogs": {
      "get": {
        "operationId": "listTikTokCatalogs",
        "summary": "List TikTok product catalogs for an advertiser",
        "tags": [
          "tiktok"
        ],
        "description": "Returns the product catalogs available for the advertiser (scoped via Business Center). Required when launching PRODUCT_SALES / SHOP_PURCHASES campaigns. Falls back to an empty list when no BC catalog is available.",
        "parameters": [
          {
            "schema": {
              "minLength": 1,
              "type": "string"
            },
            "in": "query",
            "name": "advertiser_id",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "items"
                  ],
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "additionalProperties": false,
                        "type": "object",
                        "required": [
                          "id",
                          "name"
                        ],
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "name": {
                            "type": "string"
                          },
                          "meta": {
                            "description": "Free-form per-resource metadata (varies by endpoint, see description).",
                            "type": "object",
                            "additionalProperties": {
                              "$comment": "json-value",
                              "description": "Arbitrary JSON value with nested arrays and objects."
                            }
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/tiktok/pixels/{pixelId}/events": {
      "get": {
        "operationId": "listTikTokPixelEvents",
        "summary": "List events tracked by a TikTok pixel (with standard fallback)",
        "tags": [
          "tiktok"
        ],
        "description": "Returns the optimization events available for a pixel. Combines events tracked by the pixel with the TikTok standard event catalog so the response is never empty. `meta.tracked` is true when the event is configured on the pixel; `meta.isValueEvent` is true for value-producing events compatible with VBO.",
        "parameters": [
          {
            "schema": {
              "minLength": 1,
              "type": "string"
            },
            "in": "query",
            "name": "advertiser_id",
            "required": true
          },
          {
            "schema": {
              "minLength": 1,
              "type": "string"
            },
            "in": "path",
            "name": "pixelId",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "items"
                  ],
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "additionalProperties": false,
                        "type": "object",
                        "required": [
                          "id",
                          "name"
                        ],
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "name": {
                            "type": "string"
                          },
                          "meta": {
                            "description": "Free-form per-resource metadata (varies by endpoint, see description).",
                            "type": "object",
                            "additionalProperties": {
                              "$comment": "json-value",
                              "description": "Arbitrary JSON value with nested arrays and objects."
                            }
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/tiktok/identities/{identityId}/posts": {
      "get": {
        "operationId": "listTikTokIdentityPosts",
        "summary": "List authorized organic posts for a TikTok identity (Spark Ads)",
        "tags": [
          "tiktok"
        ],
        "description": "Returns organic TikTok posts authorized for use in ads (\"Spark Ads\") for the supplied identity. Posts must be authorized in-app (TikTok app → Privacy → Ad authorization) - non-authorized posts are not returned. `meta.thumbnailUrl` and `meta.createTime` are set when available.",
        "parameters": [
          {
            "schema": {
              "minLength": 1,
              "type": "string"
            },
            "in": "query",
            "name": "advertiser_id",
            "required": true
          },
          {
            "schema": {
              "default": "TT_USER",
              "anyOf": [
                {
                  "type": "string",
                  "enum": [
                    "TT_USER"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "CUSTOMIZED_USER"
                  ]
                }
              ]
            },
            "in": "query",
            "name": "identity_type",
            "required": false
          },
          {
            "schema": {
              "minLength": 1,
              "type": "string"
            },
            "in": "path",
            "name": "identityId",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "items"
                  ],
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "additionalProperties": false,
                        "type": "object",
                        "required": [
                          "id",
                          "name"
                        ],
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "name": {
                            "type": "string"
                          },
                          "meta": {
                            "description": "Free-form per-resource metadata (varies by endpoint, see description).",
                            "type": "object",
                            "additionalProperties": {
                              "$comment": "json-value",
                              "description": "Arbitrary JSON value with nested arrays and objects."
                            }
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/tiktok/lead-forms": {
      "get": {
        "operationId": "listTikTokLeadForms",
        "summary": "List TikTok instant lead forms for an advertiser",
        "tags": [
          "tiktok"
        ],
        "description": "Returns the instant lead forms available for the advertiser. Required when launching LEAD_GENERATION campaigns.",
        "parameters": [
          {
            "schema": {
              "minLength": 1,
              "type": "string"
            },
            "in": "query",
            "name": "advertiser_id",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "items"
                  ],
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "additionalProperties": false,
                        "type": "object",
                        "required": [
                          "id",
                          "name"
                        ],
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "name": {
                            "type": "string"
                          },
                          "meta": {
                            "description": "Free-form per-resource metadata (varies by endpoint, see description).",
                            "type": "object",
                            "additionalProperties": {
                              "$comment": "json-value",
                              "description": "Arbitrary JSON value with nested arrays and objects."
                            }
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/trackers/{configId}/keitaro-users": {
      "get": {
        "operationId": "getApiV1TrackersByConfigIdKeitaroUsers",
        "summary": "List Keitaro users available for member mapping",
        "tags": [
          "trackers",
          "access"
        ],
        "description": "Returns the Keitaro users synced for the tracker config, including their access_data ACL payload used to map Wevion members to tracker permissions.",
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "configId",
            "required": true
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "configId",
                    "users"
                  ],
                  "properties": {
                    "configId": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "users": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "id",
                          "externalId",
                          "login",
                          "userType",
                          "accessData"
                        ],
                        "properties": {
                          "id": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "externalId": {
                            "type": "string"
                          },
                          "login": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "userType": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "accessData": {
                            "anyOf": [
                              {
                                "additionalProperties": {
                                  "$comment": "json-value",
                                  "description": "Arbitrary JSON value with nested arrays and objects."
                                },
                                "type": "object",
                                "properties": {
                                  "affiliate_networks_access_type": {
                                    "anyOf": [
                                      {
                                        "anyOf": [
                                          {
                                            "type": "string",
                                            "enum": [
                                              "full_access"
                                            ]
                                          },
                                          {
                                            "type": "string",
                                            "enum": [
                                              "read_only"
                                            ]
                                          },
                                          {
                                            "type": "string",
                                            "enum": [
                                              "to_groups_and_selected"
                                            ]
                                          },
                                          {
                                            "type": "string",
                                            "enum": [
                                              "created_by_user_groups_and_selected"
                                            ]
                                          },
                                          {
                                            "description": "Access type as reported by Keitaro, when outside the known set.",
                                            "type": "string"
                                          }
                                        ]
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "affiliate_networks_selected_entities": {
                                    "anyOf": [
                                      {
                                        "type": "array",
                                        "items": {
                                          "anyOf": [
                                            {
                                              "type": "number"
                                            },
                                            {
                                              "type": "string"
                                            }
                                          ]
                                        }
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "affiliate_networks_selected_groups": {
                                    "anyOf": [
                                      {
                                        "type": "array",
                                        "items": {
                                          "anyOf": [
                                            {
                                              "type": "number"
                                            },
                                            {
                                              "type": "string"
                                            }
                                          ]
                                        }
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "allowed_resources": {
                                    "anyOf": [
                                      {
                                        "type": "array",
                                        "items": {
                                          "anyOf": [
                                            {
                                              "type": "string"
                                            },
                                            {
                                              "type": "number"
                                            }
                                          ]
                                        }
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "campaigns_access_type": {
                                    "anyOf": [
                                      {
                                        "anyOf": [
                                          {
                                            "type": "string",
                                            "enum": [
                                              "full_access"
                                            ]
                                          },
                                          {
                                            "type": "string",
                                            "enum": [
                                              "read_only"
                                            ]
                                          },
                                          {
                                            "type": "string",
                                            "enum": [
                                              "to_groups_and_selected"
                                            ]
                                          },
                                          {
                                            "type": "string",
                                            "enum": [
                                              "created_by_user_groups_and_selected"
                                            ]
                                          },
                                          {
                                            "description": "Access type as reported by Keitaro, when outside the known set.",
                                            "type": "string"
                                          }
                                        ]
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "campaigns_selected_entities": {
                                    "anyOf": [
                                      {
                                        "type": "array",
                                        "items": {
                                          "anyOf": [
                                            {
                                              "type": "number"
                                            },
                                            {
                                              "type": "string"
                                            }
                                          ]
                                        }
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "campaigns_selected_groups": {
                                    "anyOf": [
                                      {
                                        "type": "array",
                                        "items": {
                                          "anyOf": [
                                            {
                                              "type": "number"
                                            },
                                            {
                                              "type": "string"
                                            }
                                          ]
                                        }
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "domains_access_type": {
                                    "anyOf": [
                                      {
                                        "anyOf": [
                                          {
                                            "type": "string",
                                            "enum": [
                                              "full_access"
                                            ]
                                          },
                                          {
                                            "type": "string",
                                            "enum": [
                                              "read_only"
                                            ]
                                          },
                                          {
                                            "type": "string",
                                            "enum": [
                                              "to_groups_and_selected"
                                            ]
                                          },
                                          {
                                            "type": "string",
                                            "enum": [
                                              "created_by_user_groups_and_selected"
                                            ]
                                          },
                                          {
                                            "description": "Access type as reported by Keitaro, when outside the known set.",
                                            "type": "string"
                                          }
                                        ]
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "domains_selected_entities": {
                                    "anyOf": [
                                      {
                                        "type": "array",
                                        "items": {
                                          "anyOf": [
                                            {
                                              "type": "number"
                                            },
                                            {
                                              "type": "string"
                                            }
                                          ]
                                        }
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "domains_selected_groups": {
                                    "anyOf": [
                                      {
                                        "type": "array",
                                        "items": {
                                          "anyOf": [
                                            {
                                              "type": "number"
                                            },
                                            {
                                              "type": "string"
                                            }
                                          ]
                                        }
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "landings_access_type": {
                                    "anyOf": [
                                      {
                                        "anyOf": [
                                          {
                                            "type": "string",
                                            "enum": [
                                              "full_access"
                                            ]
                                          },
                                          {
                                            "type": "string",
                                            "enum": [
                                              "read_only"
                                            ]
                                          },
                                          {
                                            "type": "string",
                                            "enum": [
                                              "to_groups_and_selected"
                                            ]
                                          },
                                          {
                                            "type": "string",
                                            "enum": [
                                              "created_by_user_groups_and_selected"
                                            ]
                                          },
                                          {
                                            "description": "Access type as reported by Keitaro, when outside the known set.",
                                            "type": "string"
                                          }
                                        ]
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "landings_selected_entities": {
                                    "anyOf": [
                                      {
                                        "type": "array",
                                        "items": {
                                          "anyOf": [
                                            {
                                              "type": "number"
                                            },
                                            {
                                              "type": "string"
                                            }
                                          ]
                                        }
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "landings_selected_groups": {
                                    "anyOf": [
                                      {
                                        "type": "array",
                                        "items": {
                                          "anyOf": [
                                            {
                                              "type": "number"
                                            },
                                            {
                                              "type": "string"
                                            }
                                          ]
                                        }
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "offers_access_type": {
                                    "anyOf": [
                                      {
                                        "anyOf": [
                                          {
                                            "type": "string",
                                            "enum": [
                                              "full_access"
                                            ]
                                          },
                                          {
                                            "type": "string",
                                            "enum": [
                                              "read_only"
                                            ]
                                          },
                                          {
                                            "type": "string",
                                            "enum": [
                                              "to_groups_and_selected"
                                            ]
                                          },
                                          {
                                            "type": "string",
                                            "enum": [
                                              "created_by_user_groups_and_selected"
                                            ]
                                          },
                                          {
                                            "description": "Access type as reported by Keitaro, when outside the known set.",
                                            "type": "string"
                                          }
                                        ]
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "offers_selected_entities": {
                                    "anyOf": [
                                      {
                                        "type": "array",
                                        "items": {
                                          "anyOf": [
                                            {
                                              "type": "number"
                                            },
                                            {
                                              "type": "string"
                                            }
                                          ]
                                        }
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "offers_selected_groups": {
                                    "anyOf": [
                                      {
                                        "type": "array",
                                        "items": {
                                          "anyOf": [
                                            {
                                              "type": "number"
                                            },
                                            {
                                              "type": "string"
                                            }
                                          ]
                                        }
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "resources": {
                                    "anyOf": [
                                      {
                                        "type": "array",
                                        "items": {
                                          "anyOf": [
                                            {
                                              "type": "string"
                                            },
                                            {
                                              "type": "number"
                                            }
                                          ]
                                        }
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "streams_access_type": {
                                    "anyOf": [
                                      {
                                        "anyOf": [
                                          {
                                            "type": "string",
                                            "enum": [
                                              "full_access"
                                            ]
                                          },
                                          {
                                            "type": "string",
                                            "enum": [
                                              "read_only"
                                            ]
                                          },
                                          {
                                            "type": "string",
                                            "enum": [
                                              "to_groups_and_selected"
                                            ]
                                          },
                                          {
                                            "type": "string",
                                            "enum": [
                                              "created_by_user_groups_and_selected"
                                            ]
                                          },
                                          {
                                            "description": "Access type as reported by Keitaro, when outside the known set.",
                                            "type": "string"
                                          }
                                        ]
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "traffic_sources_access_type": {
                                    "anyOf": [
                                      {
                                        "anyOf": [
                                          {
                                            "type": "string",
                                            "enum": [
                                              "full_access"
                                            ]
                                          },
                                          {
                                            "type": "string",
                                            "enum": [
                                              "read_only"
                                            ]
                                          },
                                          {
                                            "type": "string",
                                            "enum": [
                                              "to_groups_and_selected"
                                            ]
                                          },
                                          {
                                            "type": "string",
                                            "enum": [
                                              "created_by_user_groups_and_selected"
                                            ]
                                          },
                                          {
                                            "description": "Access type as reported by Keitaro, when outside the known set.",
                                            "type": "string"
                                          }
                                        ]
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "traffic_sources_selected_entities": {
                                    "anyOf": [
                                      {
                                        "type": "array",
                                        "items": {
                                          "anyOf": [
                                            {
                                              "type": "number"
                                            },
                                            {
                                              "type": "string"
                                            }
                                          ]
                                        }
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "traffic_sources_selected_groups": {
                                    "anyOf": [
                                      {
                                        "type": "array",
                                        "items": {
                                          "anyOf": [
                                            {
                                              "type": "number"
                                            },
                                            {
                                              "type": "string"
                                            }
                                          ]
                                        }
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  }
                                }
                              },
                              {
                                "type": "null"
                              }
                            ]
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/trackers/{configId}/access": {
      "get": {
        "operationId": "getApiV1TrackersByConfigIdAccess",
        "summary": "List team members and their Keitaro user mappings",
        "tags": [
          "trackers",
          "access"
        ],
        "description": "Returns team members for the tracker config team and the Keitaro user mappings that determine each member effective tracker access.",
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "configId",
            "required": true
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "configId",
                    "members"
                  ],
                  "properties": {
                    "configId": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "members": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "memberId",
                          "memberEmail",
                          "memberName",
                          "memberRole",
                          "mappings"
                        ],
                        "properties": {
                          "memberId": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "memberEmail": {
                            "type": "string"
                          },
                          "memberName": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "memberRole": {
                            "type": "string"
                          },
                          "mappings": {
                            "type": "array",
                            "items": {
                              "type": "object",
                              "required": [
                                "id",
                                "keitaroUserId",
                                "keitaroExternalId",
                                "keitaroLogin",
                                "keitaroUserType",
                                "orphaned"
                              ],
                              "properties": {
                                "id": {
                                  "format": "uuid",
                                  "type": "string"
                                },
                                "keitaroUserId": {
                                  "format": "uuid",
                                  "type": "string"
                                },
                                "keitaroExternalId": {
                                  "type": "string"
                                },
                                "keitaroLogin": {
                                  "anyOf": [
                                    {
                                      "type": "string"
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "keitaroUserType": {
                                  "anyOf": [
                                    {
                                      "type": "string"
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "orphaned": {
                                  "type": "boolean"
                                }
                              }
                            }
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/trackers/{configId}/access/{memberId}": {
      "put": {
        "operationId": "putApiV1TrackersByConfigIdAccessByMemberId",
        "summary": "Set the Keitaro user mappings for one team member",
        "tags": [
          "trackers",
          "access"
        ],
        "description": "Replaces the full mapping set for the given member on this tracker config. Pass an empty array to remove all mappings (member loses access to this tracker).",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "keitaroUserIds"
                ],
                "properties": {
                  "keitaroUserIds": {
                    "type": "array",
                    "items": {
                      "format": "uuid",
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "configId",
            "required": true
          },
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "memberId",
            "required": true
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "added",
                    "removed",
                    "kept"
                  ],
                  "properties": {
                    "added": {
                      "type": "number"
                    },
                    "removed": {
                      "type": "number"
                    },
                    "kept": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/trackers/{configId}/breakdowns/sub": {
      "get": {
        "operationId": "getApiV1TrackersByConfigIdBreakdownsSub",
        "summary": "Get sub-ID breakdown stats",
        "tags": [
          "tracker-breakdowns"
        ],
        "description": "Returns sub-ID breakdown stats for a tracker config.",
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "campaign_id",
            "required": false
          },
          {
            "schema": {
              "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
              "type": "string"
            },
            "in": "query",
            "name": "from_date",
            "required": true
          },
          {
            "schema": {
              "maximum": 10000,
              "minimum": 1,
              "type": "integer"
            },
            "in": "query",
            "name": "limit",
            "required": false
          },
          {
            "schema": {
              "minimum": 0,
              "type": "integer"
            },
            "in": "query",
            "name": "offset",
            "required": false
          },
          {
            "schema": {
              "maxLength": 200,
              "type": "string"
            },
            "in": "query",
            "name": "search",
            "required": false
          },
          {
            "schema": {
              "pattern": "^[A-Za-z0-9_-]+$",
              "type": "string"
            },
            "in": "query",
            "name": "sort_by",
            "required": false
          },
          {
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "enum": [
                    "asc"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "desc"
                  ]
                }
              ]
            },
            "in": "query",
            "name": "sort_order",
            "required": false
          },
          {
            "schema": {
              "pattern": "^[A-Za-z0-9_/+-]+$",
              "type": "string"
            },
            "in": "query",
            "name": "timezone",
            "required": false
          },
          {
            "schema": {
              "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
              "type": "string"
            },
            "in": "query",
            "name": "to_date",
            "required": true
          },
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "configId",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "items",
                    "hasMore",
                    "limit",
                    "offset",
                    "total"
                  ],
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "campaignExternalId",
                          "clicks",
                          "conversions",
                          "costCents",
                          "cr",
                          "date",
                          "id",
                          "profitCents",
                          "revenueCents",
                          "roi",
                          "isPartial",
                          "updatedThrough",
                          "subId",
                          "sub1",
                          "sub2",
                          "sub3",
                          "sub4",
                          "sub5",
                          "sub6",
                          "sub7",
                          "sub8",
                          "sub9",
                          "sub10",
                          "sub11",
                          "sub12",
                          "sub13",
                          "sub14",
                          "sub15",
                          "sub16",
                          "sub17",
                          "sub18",
                          "sub19",
                          "sub20",
                          "sub21",
                          "sub22",
                          "sub23",
                          "sub24",
                          "sub25",
                          "sub26",
                          "sub27",
                          "sub28",
                          "sub29",
                          "sub30",
                          "uniqueClicks"
                        ],
                        "properties": {
                          "campaignExternalId": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "clicks": {
                            "type": "number"
                          },
                          "conversions": {
                            "type": "number"
                          },
                          "costCents": {
                            "type": "string"
                          },
                          "cr": {
                            "anyOf": [
                              {
                                "type": "number"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "date": {
                            "format": "date",
                            "type": "string"
                          },
                          "id": {
                            "type": "string"
                          },
                          "profitCents": {
                            "type": "string"
                          },
                          "revenueCents": {
                            "type": "string"
                          },
                          "roi": {
                            "anyOf": [
                              {
                                "type": "number"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "isPartial": {
                            "type": "boolean"
                          },
                          "updatedThrough": {
                            "anyOf": [
                              {
                                "format": "date-time",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "subId": {
                            "type": "string"
                          },
                          "sub1": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "sub2": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "sub3": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "sub4": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "sub5": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "sub6": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "sub7": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "sub8": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "sub9": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "sub10": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "sub11": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "sub12": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "sub13": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "sub14": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "sub15": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "sub16": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "sub17": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "sub18": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "sub19": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "sub20": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "sub21": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "sub22": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "sub23": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "sub24": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "sub25": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "sub26": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "sub27": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "sub28": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "sub29": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "sub30": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "uniqueClicks": {
                            "anyOf": [
                              {
                                "type": "number"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          }
                        }
                      }
                    },
                    "hasMore": {
                      "type": "boolean"
                    },
                    "limit": {
                      "minimum": 1,
                      "type": "integer"
                    },
                    "offset": {
                      "minimum": 0,
                      "type": "integer"
                    },
                    "total": {
                      "minimum": 0,
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/trackers/{configId}/breakdowns/landing": {
      "get": {
        "operationId": "getApiV1TrackersByConfigIdBreakdownsLanding",
        "summary": "Get landing page breakdown stats",
        "tags": [
          "tracker-breakdowns"
        ],
        "description": "Returns landing page A/B test stats for a tracker config.",
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "campaign_id",
            "required": false
          },
          {
            "schema": {
              "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
              "type": "string"
            },
            "in": "query",
            "name": "from_date",
            "required": true
          },
          {
            "schema": {
              "maximum": 10000,
              "minimum": 1,
              "type": "integer"
            },
            "in": "query",
            "name": "limit",
            "required": false
          },
          {
            "schema": {
              "minimum": 0,
              "type": "integer"
            },
            "in": "query",
            "name": "offset",
            "required": false
          },
          {
            "schema": {
              "maxLength": 200,
              "type": "string"
            },
            "in": "query",
            "name": "search",
            "required": false
          },
          {
            "schema": {
              "pattern": "^[A-Za-z0-9_-]+$",
              "type": "string"
            },
            "in": "query",
            "name": "sort_by",
            "required": false
          },
          {
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "enum": [
                    "asc"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "desc"
                  ]
                }
              ]
            },
            "in": "query",
            "name": "sort_order",
            "required": false
          },
          {
            "schema": {
              "pattern": "^[A-Za-z0-9_/+-]+$",
              "type": "string"
            },
            "in": "query",
            "name": "timezone",
            "required": false
          },
          {
            "schema": {
              "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
              "type": "string"
            },
            "in": "query",
            "name": "to_date",
            "required": true
          },
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "configId",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "items",
                    "hasMore",
                    "limit",
                    "offset",
                    "total"
                  ],
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "campaignExternalId",
                          "clicks",
                          "conversions",
                          "costCents",
                          "cr",
                          "date",
                          "id",
                          "landingId",
                          "landingName",
                          "landingExternalId",
                          "leads",
                          "lpClicks",
                          "lpCtr",
                          "profitCents",
                          "revenueCents",
                          "roi",
                          "isPartial",
                          "updatedThrough",
                          "sales",
                          "uniqueClicks"
                        ],
                        "properties": {
                          "campaignExternalId": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "clicks": {
                            "type": "number"
                          },
                          "conversions": {
                            "type": "number"
                          },
                          "costCents": {
                            "type": "string"
                          },
                          "cr": {
                            "anyOf": [
                              {
                                "type": "number"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "date": {
                            "format": "date",
                            "type": "string"
                          },
                          "id": {
                            "type": "string"
                          },
                          "landingId": {
                            "type": "string"
                          },
                          "landingName": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "landingExternalId": {
                            "type": "string"
                          },
                          "leads": {
                            "anyOf": [
                              {
                                "type": "number"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "lpClicks": {
                            "anyOf": [
                              {
                                "type": "number"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "lpCtr": {
                            "anyOf": [
                              {
                                "type": "number"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "profitCents": {
                            "type": "string"
                          },
                          "revenueCents": {
                            "type": "string"
                          },
                          "roi": {
                            "anyOf": [
                              {
                                "type": "number"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "isPartial": {
                            "type": "boolean"
                          },
                          "updatedThrough": {
                            "anyOf": [
                              {
                                "format": "date-time",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "sales": {
                            "anyOf": [
                              {
                                "type": "number"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "uniqueClicks": {
                            "anyOf": [
                              {
                                "type": "number"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          }
                        }
                      }
                    },
                    "hasMore": {
                      "type": "boolean"
                    },
                    "limit": {
                      "minimum": 1,
                      "type": "integer"
                    },
                    "offset": {
                      "minimum": 0,
                      "type": "integer"
                    },
                    "total": {
                      "minimum": 0,
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/trackers/{configId}/breakdowns/offer": {
      "get": {
        "operationId": "getApiV1TrackersByConfigIdBreakdownsOffer",
        "summary": "Get offer breakdown stats",
        "tags": [
          "tracker-breakdowns"
        ],
        "description": "Returns offer A/B test stats for a tracker config.",
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "campaign_id",
            "required": false
          },
          {
            "schema": {
              "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
              "type": "string"
            },
            "in": "query",
            "name": "from_date",
            "required": true
          },
          {
            "schema": {
              "maximum": 10000,
              "minimum": 1,
              "type": "integer"
            },
            "in": "query",
            "name": "limit",
            "required": false
          },
          {
            "schema": {
              "minimum": 0,
              "type": "integer"
            },
            "in": "query",
            "name": "offset",
            "required": false
          },
          {
            "schema": {
              "maxLength": 200,
              "type": "string"
            },
            "in": "query",
            "name": "search",
            "required": false
          },
          {
            "schema": {
              "pattern": "^[A-Za-z0-9_-]+$",
              "type": "string"
            },
            "in": "query",
            "name": "sort_by",
            "required": false
          },
          {
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "enum": [
                    "asc"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "desc"
                  ]
                }
              ]
            },
            "in": "query",
            "name": "sort_order",
            "required": false
          },
          {
            "schema": {
              "pattern": "^[A-Za-z0-9_/+-]+$",
              "type": "string"
            },
            "in": "query",
            "name": "timezone",
            "required": false
          },
          {
            "schema": {
              "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
              "type": "string"
            },
            "in": "query",
            "name": "to_date",
            "required": true
          },
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "configId",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "items",
                    "hasMore",
                    "limit",
                    "offset",
                    "total"
                  ],
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "campaignExternalId",
                          "clicks",
                          "conversions",
                          "costCents",
                          "cr",
                          "date",
                          "id",
                          "leads",
                          "offerId",
                          "offerName",
                          "offerExternalId",
                          "payoutCents",
                          "profitCents",
                          "revenueCents",
                          "roi",
                          "isPartial",
                          "updatedThrough",
                          "sales",
                          "uniqueClicks"
                        ],
                        "properties": {
                          "campaignExternalId": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "clicks": {
                            "type": "number"
                          },
                          "conversions": {
                            "type": "number"
                          },
                          "costCents": {
                            "type": "string"
                          },
                          "cr": {
                            "anyOf": [
                              {
                                "type": "number"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "date": {
                            "format": "date",
                            "type": "string"
                          },
                          "id": {
                            "type": "string"
                          },
                          "leads": {
                            "anyOf": [
                              {
                                "type": "number"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "offerId": {
                            "type": "string"
                          },
                          "offerName": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "offerExternalId": {
                            "type": "string"
                          },
                          "payoutCents": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "profitCents": {
                            "type": "string"
                          },
                          "revenueCents": {
                            "type": "string"
                          },
                          "roi": {
                            "anyOf": [
                              {
                                "type": "number"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "isPartial": {
                            "type": "boolean"
                          },
                          "updatedThrough": {
                            "anyOf": [
                              {
                                "format": "date-time",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "sales": {
                            "anyOf": [
                              {
                                "type": "number"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "uniqueClicks": {
                            "anyOf": [
                              {
                                "type": "number"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          }
                        }
                      }
                    },
                    "hasMore": {
                      "type": "boolean"
                    },
                    "limit": {
                      "minimum": 1,
                      "type": "integer"
                    },
                    "offset": {
                      "minimum": 0,
                      "type": "integer"
                    },
                    "total": {
                      "minimum": 0,
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/trackers/{configId}/breakdowns/geo": {
      "get": {
        "operationId": "getApiV1TrackersByConfigIdBreakdownsGeo",
        "summary": "Get geo breakdown stats",
        "tags": [
          "tracker-breakdowns"
        ],
        "description": "Returns geo (country) breakdown stats for a tracker config.",
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "campaign_id",
            "required": false
          },
          {
            "schema": {
              "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
              "type": "string"
            },
            "in": "query",
            "name": "from_date",
            "required": true
          },
          {
            "schema": {
              "maximum": 10000,
              "minimum": 1,
              "type": "integer"
            },
            "in": "query",
            "name": "limit",
            "required": false
          },
          {
            "schema": {
              "minimum": 0,
              "type": "integer"
            },
            "in": "query",
            "name": "offset",
            "required": false
          },
          {
            "schema": {
              "maxLength": 200,
              "type": "string"
            },
            "in": "query",
            "name": "search",
            "required": false
          },
          {
            "schema": {
              "pattern": "^[A-Za-z0-9_-]+$",
              "type": "string"
            },
            "in": "query",
            "name": "sort_by",
            "required": false
          },
          {
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "enum": [
                    "asc"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "desc"
                  ]
                }
              ]
            },
            "in": "query",
            "name": "sort_order",
            "required": false
          },
          {
            "schema": {
              "pattern": "^[A-Za-z0-9_/+-]+$",
              "type": "string"
            },
            "in": "query",
            "name": "timezone",
            "required": false
          },
          {
            "schema": {
              "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
              "type": "string"
            },
            "in": "query",
            "name": "to_date",
            "required": true
          },
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "configId",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "items",
                    "hasMore",
                    "limit",
                    "offset",
                    "total"
                  ],
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "campaignExternalId",
                          "clicks",
                          "conversions",
                          "costCents",
                          "country",
                          "cr",
                          "date",
                          "id",
                          "profitCents",
                          "revenueCents",
                          "roi",
                          "isPartial",
                          "updatedThrough",
                          "region",
                          "city"
                        ],
                        "properties": {
                          "campaignExternalId": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "clicks": {
                            "type": "number"
                          },
                          "conversions": {
                            "type": "number"
                          },
                          "costCents": {
                            "type": "string"
                          },
                          "country": {
                            "type": "string"
                          },
                          "cr": {
                            "anyOf": [
                              {
                                "type": "number"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "date": {
                            "format": "date",
                            "type": "string"
                          },
                          "id": {
                            "type": "string"
                          },
                          "profitCents": {
                            "type": "string"
                          },
                          "revenueCents": {
                            "type": "string"
                          },
                          "roi": {
                            "anyOf": [
                              {
                                "type": "number"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "isPartial": {
                            "type": "boolean"
                          },
                          "updatedThrough": {
                            "anyOf": [
                              {
                                "format": "date-time",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "region": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "city": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          }
                        }
                      }
                    },
                    "hasMore": {
                      "type": "boolean"
                    },
                    "limit": {
                      "minimum": 1,
                      "type": "integer"
                    },
                    "offset": {
                      "minimum": 0,
                      "type": "integer"
                    },
                    "total": {
                      "minimum": 0,
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/trackers/{configId}/mappings/setup": {
      "get": {
        "operationId": "getApiV1TrackersByConfigIdMappingsSetup",
        "summary": "Get tracker field mapping setup",
        "tags": [
          "tracker-mappings"
        ],
        "description": "Returns tracker fields, configured rules and generated mapping count for this tracker.",
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "configId",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "coverage",
                    "fields",
                    "macroDiagnostics",
                    "mappingsCount",
                    "rules"
                  ],
                  "properties": {
                    "coverage": {
                      "type": "object",
                      "required": [
                        "byType",
                        "mapped",
                        "total",
                        "unmapped"
                      ],
                      "properties": {
                        "byType": {
                          "type": "object",
                          "required": [
                            "ad",
                            "adset",
                            "campaign"
                          ],
                          "properties": {
                            "ad": {
                              "type": "object",
                              "required": [
                                "mapped",
                                "total",
                                "unmapped"
                              ],
                              "properties": {
                                "mapped": {
                                  "type": "number"
                                },
                                "total": {
                                  "type": "number"
                                },
                                "unmapped": {
                                  "type": "number"
                                }
                              }
                            },
                            "adset": {
                              "type": "object",
                              "required": [
                                "mapped",
                                "total",
                                "unmapped"
                              ],
                              "properties": {
                                "mapped": {
                                  "type": "number"
                                },
                                "total": {
                                  "type": "number"
                                },
                                "unmapped": {
                                  "type": "number"
                                }
                              }
                            },
                            "campaign": {
                              "type": "object",
                              "required": [
                                "mapped",
                                "total",
                                "unmapped"
                              ],
                              "properties": {
                                "mapped": {
                                  "type": "number"
                                },
                                "total": {
                                  "type": "number"
                                },
                                "unmapped": {
                                  "type": "number"
                                }
                              }
                            }
                          }
                        },
                        "mapped": {
                          "type": "number"
                        },
                        "total": {
                          "type": "number"
                        },
                        "unmapped": {
                          "type": "number"
                        }
                      }
                    },
                    "fields": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "aliases",
                          "availability",
                          "campaignCount",
                          "isMappable",
                          "names",
                          "placeholders",
                          "sourceFields",
                          "sourceName",
                          "trafficSourceCount"
                        ],
                        "properties": {
                          "aliases": {
                            "type": "array",
                            "items": {
                              "type": "string"
                            }
                          },
                          "availability": {
                            "anyOf": [
                              {
                                "type": "string",
                                "enum": [
                                  "available"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "click_level"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "unsupported"
                                ]
                              }
                            ]
                          },
                          "campaignCount": {
                            "type": "number"
                          },
                          "isMappable": {
                            "type": "boolean"
                          },
                          "names": {
                            "type": "array",
                            "items": {
                              "type": "string"
                            }
                          },
                          "placeholders": {
                            "type": "array",
                            "items": {
                              "type": "string"
                            }
                          },
                          "sourceField": {
                            "anyOf": [
                              {
                                "type": "string",
                                "enum": [
                                  "sub1"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "sub2"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "sub3"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "sub4"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "sub5"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "sub6"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "sub7"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "sub8"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "sub9"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "sub10"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "sub11"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "sub12"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "sub13"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "sub14"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "sub15"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "sub16"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "sub17"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "sub18"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "sub19"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "sub20"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "sub21"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "sub22"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "sub23"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "sub24"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "sub25"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "sub26"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "sub27"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "sub28"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "sub29"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "sub30"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "ad_campaign_id"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "creative_id"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "external_id"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "keyword"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "source"
                                ]
                              }
                            ]
                          },
                          "sourceFields": {
                            "type": "array",
                            "items": {
                              "anyOf": [
                                {
                                  "type": "string",
                                  "enum": [
                                    "sub1"
                                  ]
                                },
                                {
                                  "type": "string",
                                  "enum": [
                                    "sub2"
                                  ]
                                },
                                {
                                  "type": "string",
                                  "enum": [
                                    "sub3"
                                  ]
                                },
                                {
                                  "type": "string",
                                  "enum": [
                                    "sub4"
                                  ]
                                },
                                {
                                  "type": "string",
                                  "enum": [
                                    "sub5"
                                  ]
                                },
                                {
                                  "type": "string",
                                  "enum": [
                                    "sub6"
                                  ]
                                },
                                {
                                  "type": "string",
                                  "enum": [
                                    "sub7"
                                  ]
                                },
                                {
                                  "type": "string",
                                  "enum": [
                                    "sub8"
                                  ]
                                },
                                {
                                  "type": "string",
                                  "enum": [
                                    "sub9"
                                  ]
                                },
                                {
                                  "type": "string",
                                  "enum": [
                                    "sub10"
                                  ]
                                },
                                {
                                  "type": "string",
                                  "enum": [
                                    "sub11"
                                  ]
                                },
                                {
                                  "type": "string",
                                  "enum": [
                                    "sub12"
                                  ]
                                },
                                {
                                  "type": "string",
                                  "enum": [
                                    "sub13"
                                  ]
                                },
                                {
                                  "type": "string",
                                  "enum": [
                                    "sub14"
                                  ]
                                },
                                {
                                  "type": "string",
                                  "enum": [
                                    "sub15"
                                  ]
                                },
                                {
                                  "type": "string",
                                  "enum": [
                                    "sub16"
                                  ]
                                },
                                {
                                  "type": "string",
                                  "enum": [
                                    "sub17"
                                  ]
                                },
                                {
                                  "type": "string",
                                  "enum": [
                                    "sub18"
                                  ]
                                },
                                {
                                  "type": "string",
                                  "enum": [
                                    "sub19"
                                  ]
                                },
                                {
                                  "type": "string",
                                  "enum": [
                                    "sub20"
                                  ]
                                },
                                {
                                  "type": "string",
                                  "enum": [
                                    "sub21"
                                  ]
                                },
                                {
                                  "type": "string",
                                  "enum": [
                                    "sub22"
                                  ]
                                },
                                {
                                  "type": "string",
                                  "enum": [
                                    "sub23"
                                  ]
                                },
                                {
                                  "type": "string",
                                  "enum": [
                                    "sub24"
                                  ]
                                },
                                {
                                  "type": "string",
                                  "enum": [
                                    "sub25"
                                  ]
                                },
                                {
                                  "type": "string",
                                  "enum": [
                                    "sub26"
                                  ]
                                },
                                {
                                  "type": "string",
                                  "enum": [
                                    "sub27"
                                  ]
                                },
                                {
                                  "type": "string",
                                  "enum": [
                                    "sub28"
                                  ]
                                },
                                {
                                  "type": "string",
                                  "enum": [
                                    "sub29"
                                  ]
                                },
                                {
                                  "type": "string",
                                  "enum": [
                                    "sub30"
                                  ]
                                },
                                {
                                  "type": "string",
                                  "enum": [
                                    "ad_campaign_id"
                                  ]
                                },
                                {
                                  "type": "string",
                                  "enum": [
                                    "creative_id"
                                  ]
                                },
                                {
                                  "type": "string",
                                  "enum": [
                                    "external_id"
                                  ]
                                },
                                {
                                  "type": "string",
                                  "enum": [
                                    "keyword"
                                  ]
                                },
                                {
                                  "type": "string",
                                  "enum": [
                                    "source"
                                  ]
                                }
                              ]
                            }
                          },
                          "sourceName": {
                            "type": "string"
                          },
                          "trafficSourceCount": {
                            "type": "number"
                          }
                        }
                      }
                    },
                    "macroDiagnostics": {
                      "type": "object",
                      "required": [
                        "fullMetaMacroClicks",
                        "fullMetaMacroConversions",
                        "fullMetaMacroRows",
                        "lastHour",
                        "lookbackDays",
                        "metaMacroClicks",
                        "metaMacroConversions",
                        "metaMacroRows",
                        "otherMacroClicks",
                        "otherMacroConversions",
                        "otherMacroRows",
                        "totalClicks",
                        "totalConversions",
                        "totalRows"
                      ],
                      "properties": {
                        "fullMetaMacroClicks": {
                          "type": "number"
                        },
                        "fullMetaMacroConversions": {
                          "type": "number"
                        },
                        "fullMetaMacroRows": {
                          "type": "number"
                        },
                        "lastHour": {
                          "anyOf": [
                            {
                              "format": "date-time",
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "lookbackDays": {
                          "type": "number"
                        },
                        "metaMacroClicks": {
                          "type": "number"
                        },
                        "metaMacroConversions": {
                          "type": "number"
                        },
                        "metaMacroRows": {
                          "type": "number"
                        },
                        "otherMacroClicks": {
                          "type": "number"
                        },
                        "otherMacroConversions": {
                          "type": "number"
                        },
                        "otherMacroRows": {
                          "type": "number"
                        },
                        "totalClicks": {
                          "type": "number"
                        },
                        "totalConversions": {
                          "type": "number"
                        },
                        "totalRows": {
                          "type": "number"
                        }
                      }
                    },
                    "mappingsCount": {
                      "type": "number"
                    },
                    "rules": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "configId",
                          "createdAt",
                          "enabled",
                          "id",
                          "manualOverride",
                          "mappingPriority",
                          "matchTarget",
                          "metaEntityType",
                          "sourceName"
                        ],
                        "properties": {
                          "configId": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "createdAt": {
                            "format": "date-time",
                            "type": "string"
                          },
                          "enabled": {
                            "type": "boolean"
                          },
                          "id": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "manualOverride": {
                            "type": "boolean"
                          },
                          "mappingPriority": {
                            "type": "number"
                          },
                          "matchTarget": {
                            "anyOf": [
                              {
                                "type": "string",
                                "enum": [
                                  "id"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "name"
                                ]
                              }
                            ]
                          },
                          "metaEntityType": {
                            "anyOf": [
                              {
                                "type": "string",
                                "enum": [
                                  "campaign"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "adset"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "ad"
                                ]
                              }
                            ]
                          },
                          "sourceAlias": {
                            "type": "string"
                          },
                          "sourceField": {
                            "anyOf": [
                              {
                                "type": "string",
                                "enum": [
                                  "sub1"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "sub2"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "sub3"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "sub4"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "sub5"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "sub6"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "sub7"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "sub8"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "sub9"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "sub10"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "sub11"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "sub12"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "sub13"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "sub14"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "sub15"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "sub16"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "sub17"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "sub18"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "sub19"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "sub20"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "sub21"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "sub22"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "sub23"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "sub24"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "sub25"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "sub26"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "sub27"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "sub28"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "sub29"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "sub30"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "ad_campaign_id"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "creative_id"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "external_id"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "keyword"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "source"
                                ]
                              }
                            ]
                          },
                          "sourceName": {
                            "type": "string"
                          },
                          "sourcePlaceholder": {
                            "type": "string"
                          },
                          "updatedAt": {
                            "format": "date-time",
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/trackers/{configId}/mappings/rules": {
      "put": {
        "operationId": "putApiV1TrackersByConfigIdMappingsRules",
        "summary": "Save tracker field mapping rules",
        "tags": [
          "tracker-mappings"
        ],
        "description": "Replaces configured tracker field rules and rebuilds generated Meta mappings.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "rules"
                ],
                "properties": {
                  "rules": {
                    "type": "array",
                    "items": {
                      "additionalProperties": false,
                      "type": "object",
                      "required": [
                        "match_target",
                        "meta_entity_type",
                        "source_name"
                      ],
                      "properties": {
                        "match_target": {
                          "anyOf": [
                            {
                              "type": "string",
                              "enum": [
                                "id"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "name"
                              ]
                            }
                          ]
                        },
                        "mapping_priority": {
                          "minimum": 0,
                          "type": "number"
                        },
                        "meta_entity_type": {
                          "anyOf": [
                            {
                              "type": "string",
                              "enum": [
                                "campaign"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "adset"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "ad"
                              ]
                            }
                          ]
                        },
                        "source_name": {
                          "minLength": 1,
                          "type": "string"
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "configId",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "detected",
                    "skipped"
                  ],
                  "properties": {
                    "detected": {
                      "type": "number"
                    },
                    "rulesDetected": {
                      "type": "number"
                    },
                    "rulesSaved": {
                      "type": "number"
                    },
                    "skipped": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/trackers/{configId}/mappings": {
      "get": {
        "operationId": "getApiV1TrackersByConfigIdMappings",
        "summary": "List tracker-to-Meta mappings",
        "tags": [
          "tracker-mappings"
        ],
        "description": "Returns all mappings for a tracker config with optional filters.",
        "parameters": [
          {
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "enum": [
                    "campaign"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "adset"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "ad"
                  ]
                }
              ]
            },
            "in": "query",
            "name": "meta_entity_type",
            "required": false
          },
          {
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "enum": [
                    "sub1"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "sub2"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "sub3"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "sub4"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "sub5"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "sub6"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "sub7"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "sub8"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "sub9"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "sub10"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "sub11"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "sub12"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "sub13"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "sub14"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "sub15"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "sub16"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "sub17"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "sub18"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "sub19"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "sub20"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "sub21"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "sub22"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "sub23"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "sub24"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "sub25"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "sub26"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "sub27"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "sub28"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "sub29"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "sub30"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "ad_campaign_id"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "creative_id"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "keyword"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "source"
                  ]
                }
              ]
            },
            "in": "query",
            "name": "sub_field",
            "required": false
          },
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "configId",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "required": [
                      "configId",
                      "createdAt",
                      "id",
                      "manualOverride",
                      "mappingPriority",
                      "matchMethod",
                      "metaEntityId",
                      "metaEntityType",
                      "subField",
                      "subValue"
                    ],
                    "properties": {
                      "campaignExternalId": {
                        "type": "string"
                      },
                      "confidence": {
                        "type": "number"
                      },
                      "configId": {
                        "format": "uuid",
                        "type": "string"
                      },
                      "createdAt": {
                        "format": "date-time",
                        "type": "string"
                      },
                      "id": {
                        "format": "uuid",
                        "type": "string"
                      },
                      "manualOverride": {
                        "type": "boolean"
                      },
                      "mappingPriority": {
                        "type": "number"
                      },
                      "matchMethod": {
                        "anyOf": [
                          {
                            "type": "string",
                            "enum": [
                              "field_id_exact"
                            ]
                          },
                          {
                            "type": "string",
                            "enum": [
                              "field_name_exact"
                            ]
                          },
                          {
                            "type": "string",
                            "enum": [
                              "id_exact"
                            ]
                          },
                          {
                            "type": "string",
                            "enum": [
                              "utm_campaign"
                            ]
                          },
                          {
                            "type": "string",
                            "enum": [
                              "utm_source_medium"
                            ]
                          },
                          {
                            "type": "string",
                            "enum": [
                              "name_exact"
                            ]
                          },
                          {
                            "type": "string",
                            "enum": [
                              "name_fuzzy"
                            ]
                          },
                          {
                            "type": "string",
                            "enum": [
                              "manual"
                            ]
                          }
                        ]
                      },
                      "metaEntityId": {
                        "type": "string"
                      },
                      "metaEntityName": {
                        "type": "string"
                      },
                      "metaEntityType": {
                        "anyOf": [
                          {
                            "type": "string",
                            "enum": [
                              "campaign"
                            ]
                          },
                          {
                            "type": "string",
                            "enum": [
                              "adset"
                            ]
                          },
                          {
                            "type": "string",
                            "enum": [
                              "ad"
                            ]
                          }
                        ]
                      },
                      "subField": {
                        "anyOf": [
                          {
                            "type": "string",
                            "enum": [
                              "sub1"
                            ]
                          },
                          {
                            "type": "string",
                            "enum": [
                              "sub2"
                            ]
                          },
                          {
                            "type": "string",
                            "enum": [
                              "sub3"
                            ]
                          },
                          {
                            "type": "string",
                            "enum": [
                              "sub4"
                            ]
                          },
                          {
                            "type": "string",
                            "enum": [
                              "sub5"
                            ]
                          },
                          {
                            "type": "string",
                            "enum": [
                              "sub6"
                            ]
                          },
                          {
                            "type": "string",
                            "enum": [
                              "sub7"
                            ]
                          },
                          {
                            "type": "string",
                            "enum": [
                              "sub8"
                            ]
                          },
                          {
                            "type": "string",
                            "enum": [
                              "sub9"
                            ]
                          },
                          {
                            "type": "string",
                            "enum": [
                              "sub10"
                            ]
                          },
                          {
                            "type": "string",
                            "enum": [
                              "sub11"
                            ]
                          },
                          {
                            "type": "string",
                            "enum": [
                              "sub12"
                            ]
                          },
                          {
                            "type": "string",
                            "enum": [
                              "sub13"
                            ]
                          },
                          {
                            "type": "string",
                            "enum": [
                              "sub14"
                            ]
                          },
                          {
                            "type": "string",
                            "enum": [
                              "sub15"
                            ]
                          },
                          {
                            "type": "string",
                            "enum": [
                              "sub16"
                            ]
                          },
                          {
                            "type": "string",
                            "enum": [
                              "sub17"
                            ]
                          },
                          {
                            "type": "string",
                            "enum": [
                              "sub18"
                            ]
                          },
                          {
                            "type": "string",
                            "enum": [
                              "sub19"
                            ]
                          },
                          {
                            "type": "string",
                            "enum": [
                              "sub20"
                            ]
                          },
                          {
                            "type": "string",
                            "enum": [
                              "sub21"
                            ]
                          },
                          {
                            "type": "string",
                            "enum": [
                              "sub22"
                            ]
                          },
                          {
                            "type": "string",
                            "enum": [
                              "sub23"
                            ]
                          },
                          {
                            "type": "string",
                            "enum": [
                              "sub24"
                            ]
                          },
                          {
                            "type": "string",
                            "enum": [
                              "sub25"
                            ]
                          },
                          {
                            "type": "string",
                            "enum": [
                              "sub26"
                            ]
                          },
                          {
                            "type": "string",
                            "enum": [
                              "sub27"
                            ]
                          },
                          {
                            "type": "string",
                            "enum": [
                              "sub28"
                            ]
                          },
                          {
                            "type": "string",
                            "enum": [
                              "sub29"
                            ]
                          },
                          {
                            "type": "string",
                            "enum": [
                              "sub30"
                            ]
                          },
                          {
                            "type": "string",
                            "enum": [
                              "ad_campaign_id"
                            ]
                          },
                          {
                            "type": "string",
                            "enum": [
                              "creative_id"
                            ]
                          },
                          {
                            "type": "string",
                            "enum": [
                              "keyword"
                            ]
                          },
                          {
                            "type": "string",
                            "enum": [
                              "source"
                            ]
                          }
                        ]
                      },
                      "subValue": {
                        "type": "string"
                      },
                      "updatedAt": {
                        "format": "date-time",
                        "type": "string"
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "postApiV1TrackersByConfigIdMappings",
        "summary": "Create manual mapping",
        "tags": [
          "tracker-mappings"
        ],
        "description": "Creates a manual mapping between a sub value and Meta entity.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "meta_entity_id",
                  "meta_entity_type",
                  "sub_field",
                  "sub_value"
                ],
                "properties": {
                  "meta_entity_id": {
                    "minLength": 1,
                    "type": "string"
                  },
                  "meta_entity_name": {
                    "type": "string"
                  },
                  "meta_entity_type": {
                    "anyOf": [
                      {
                        "type": "string",
                        "enum": [
                          "campaign"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "adset"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "ad"
                        ]
                      }
                    ]
                  },
                  "sub_field": {
                    "anyOf": [
                      {
                        "type": "string",
                        "enum": [
                          "sub1"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "sub2"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "sub3"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "sub4"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "sub5"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "sub6"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "sub7"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "sub8"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "sub9"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "sub10"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "sub11"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "sub12"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "sub13"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "sub14"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "sub15"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "sub16"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "sub17"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "sub18"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "sub19"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "sub20"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "sub21"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "sub22"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "sub23"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "sub24"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "sub25"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "sub26"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "sub27"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "sub28"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "sub29"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "sub30"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "ad_campaign_id"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "creative_id"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "keyword"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "source"
                        ]
                      }
                    ]
                  },
                  "sub_value": {
                    "minLength": 1,
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "configId",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "201": {
            "description": "Resource created",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "configId",
                    "createdAt",
                    "id",
                    "manualOverride",
                    "mappingPriority",
                    "matchMethod",
                    "metaEntityId",
                    "metaEntityType",
                    "subField",
                    "subValue"
                  ],
                  "properties": {
                    "campaignExternalId": {
                      "type": "string"
                    },
                    "confidence": {
                      "type": "number"
                    },
                    "configId": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "createdAt": {
                      "format": "date-time",
                      "type": "string"
                    },
                    "id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "manualOverride": {
                      "type": "boolean"
                    },
                    "mappingPriority": {
                      "type": "number"
                    },
                    "matchMethod": {
                      "anyOf": [
                        {
                          "type": "string",
                          "enum": [
                            "field_id_exact"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "field_name_exact"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "id_exact"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "utm_campaign"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "utm_source_medium"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "name_exact"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "name_fuzzy"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "manual"
                          ]
                        }
                      ]
                    },
                    "metaEntityId": {
                      "type": "string"
                    },
                    "metaEntityName": {
                      "type": "string"
                    },
                    "metaEntityType": {
                      "anyOf": [
                        {
                          "type": "string",
                          "enum": [
                            "campaign"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "adset"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "ad"
                          ]
                        }
                      ]
                    },
                    "subField": {
                      "anyOf": [
                        {
                          "type": "string",
                          "enum": [
                            "sub1"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "sub2"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "sub3"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "sub4"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "sub5"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "sub6"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "sub7"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "sub8"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "sub9"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "sub10"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "sub11"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "sub12"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "sub13"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "sub14"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "sub15"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "sub16"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "sub17"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "sub18"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "sub19"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "sub20"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "sub21"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "sub22"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "sub23"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "sub24"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "sub25"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "sub26"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "sub27"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "sub28"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "sub29"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "sub30"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "ad_campaign_id"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "creative_id"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "keyword"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "source"
                          ]
                        }
                      ]
                    },
                    "subValue": {
                      "type": "string"
                    },
                    "updatedAt": {
                      "format": "date-time",
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/trackers/{configId}/mappings/detect": {
      "post": {
        "operationId": "postApiV1TrackersByConfigIdMappingsDetect",
        "summary": "Auto-detect mappings",
        "tags": [
          "tracker-mappings"
        ],
        "description": "Runs auto-detection to map sub values to Meta entities.",
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "configId",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "detected",
                    "skipped"
                  ],
                  "properties": {
                    "detected": {
                      "type": "number"
                    },
                    "rulesDetected": {
                      "type": "number"
                    },
                    "rulesSaved": {
                      "type": "number"
                    },
                    "skipped": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/trackers/{configId}/mappings/{mappingId}": {
      "delete": {
        "operationId": "deleteApiV1TrackersByConfigIdMappingsByMappingId",
        "summary": "Delete mapping",
        "tags": [
          "tracker-mappings"
        ],
        "description": "Deletes a mapping by ID.",
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "configId",
            "required": true
          },
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "mappingId",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "deleted"
                  ],
                  "properties": {
                    "deleted": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/trackers/{configId}/mappings/settings": {
      "delete": {
        "operationId": "deleteApiV1TrackersByConfigIdMappingsSettings",
        "summary": "Clear tracker mapping settings",
        "tags": [
          "tracker-mappings"
        ],
        "description": "Deletes configured mapping rules and generated mappings for this tracker.",
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "configId",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "detected",
                    "skipped"
                  ],
                  "properties": {
                    "detected": {
                      "type": "number"
                    },
                    "rulesDetected": {
                      "type": "number"
                    },
                    "rulesSaved": {
                      "type": "number"
                    },
                    "skipped": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/trackers/{configId}/mappings/refresh": {
      "post": {
        "operationId": "postApiV1TrackersByConfigIdMappingsRefresh",
        "summary": "Regenerate tracker mappings",
        "tags": [
          "tracker-mappings"
        ],
        "description": "Regenerates concrete mappings from saved rules, or auto-detects if no rules exist.",
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "configId",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "detected",
                    "skipped"
                  ],
                  "properties": {
                    "detected": {
                      "type": "number"
                    },
                    "rulesDetected": {
                      "type": "number"
                    },
                    "rulesSaved": {
                      "type": "number"
                    },
                    "skipped": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/trackers/types": {
      "get": {
        "operationId": "getApiV1TrackersTypes",
        "summary": "List supported tracker types",
        "tags": [
          "trackers"
        ],
        "description": "Returns all supported tracker types with their metadata.",
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "header",
            "name": "x-team-id",
            "required": false,
            "description": "Destination workspace team id."
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "required": [
                      "type",
                      "name",
                      "description",
                      "icon",
                      "features"
                    ],
                    "properties": {
                      "type": {
                        "type": "string"
                      },
                      "name": {
                        "type": "string"
                      },
                      "description": {
                        "type": "string"
                      },
                      "icon": {
                        "type": "string"
                      },
                      "features": {
                        "type": "array",
                        "items": {
                          "type": "string"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/trackers/test": {
      "post": {
        "operationId": "postApiV1TrackersTest",
        "summary": "Test tracker connection",
        "tags": [
          "trackers"
        ],
        "description": "Tests connection to a tracker without saving configuration.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "tracker_type",
                  "base_url",
                  "api_key"
                ],
                "properties": {
                  "tracker_type": {
                    "anyOf": [
                      {
                        "type": "string",
                        "enum": [
                          "keitaro"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "voluum"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "redtrack"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "bemob"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "tgtracker"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "binom_v2"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "clickflare"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "trafficmanager"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "everflow"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "everflow_partner"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "exoclick"
                        ]
                      }
                    ]
                  },
                  "base_url": {
                    "format": "uri",
                    "type": "string"
                  },
                  "api_key": {
                    "minLength": 1,
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "header",
            "name": "x-team-id",
            "required": false,
            "description": "Destination workspace team id."
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "success"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "latencyMs": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "adminAccess": {
                      "type": "boolean"
                    },
                    "warning": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/trackers": {
      "get": {
        "operationId": "getApiV1Trackers",
        "summary": "List tracker configurations",
        "tags": [
          "trackers"
        ],
        "description": "Returns all tracker configurations for the current team.",
        "parameters": [
          {
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "enum": [
                    "keitaro"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "voluum"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "redtrack"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "bemob"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "tgtracker"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "binom_v2"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "clickflare"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "trafficmanager"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "everflow"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "everflow_partner"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "exoclick"
                  ]
                }
              ]
            },
            "in": "query",
            "name": "tracker_type",
            "required": false
          },
          {
            "schema": {
              "type": "boolean"
            },
            "in": "query",
            "name": "is_active",
            "required": false
          },
          {
            "schema": {
              "minimum": 1,
              "maximum": 100,
              "type": "integer"
            },
            "in": "query",
            "name": "limit",
            "required": false
          },
          {
            "schema": {
              "minimum": 0,
              "type": "integer"
            },
            "in": "query",
            "name": "offset",
            "required": false
          },
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "header",
            "name": "x-team-id",
            "required": false,
            "description": "Destination workspace team id."
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "items",
                    "total"
                  ],
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "id",
                          "trackerType",
                          "name",
                          "baseUrl",
                          "isActive",
                          "lastSyncAt",
                          "syncStatus",
                          "createdAt"
                        ],
                        "properties": {
                          "id": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "trackerType": {
                            "type": "string"
                          },
                          "name": {
                            "type": "string"
                          },
                          "baseUrl": {
                            "type": "string"
                          },
                          "isActive": {
                            "type": "boolean"
                          },
                          "lastSyncAt": {
                            "anyOf": [
                              {
                                "format": "date-time",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "syncStatus": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "syncError": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "createdAt": {
                            "format": "date-time",
                            "type": "string"
                          },
                          "updatedAt": {
                            "anyOf": [
                              {
                                "format": "date-time",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "syncProgress": {
                            "anyOf": [
                              {
                                "type": "null"
                              },
                              {
                                "type": "object",
                                "required": [
                                  "total",
                                  "completed",
                                  "failed"
                                ],
                                "properties": {
                                  "total": {
                                    "minimum": 0,
                                    "type": "integer"
                                  },
                                  "completed": {
                                    "minimum": 0,
                                    "type": "integer"
                                  },
                                  "failed": {
                                    "minimum": 0,
                                    "type": "integer"
                                  }
                                }
                              }
                            ]
                          }
                        }
                      }
                    },
                    "total": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "postApiV1Trackers",
        "summary": "Create tracker configuration",
        "tags": [
          "trackers"
        ],
        "description": "Creates a new tracker integration in the destination workspace. Requires an explicit team scope (x-team-id header or an active team scope): without it the request fails with 400 and code SCOPE_TEAM_REQUIRED — no silent fallback to the primary team.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "tracker_type",
                  "name",
                  "base_url",
                  "api_key"
                ],
                "properties": {
                  "tracker_type": {
                    "anyOf": [
                      {
                        "type": "string",
                        "enum": [
                          "keitaro"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "voluum"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "redtrack"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "bemob"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "tgtracker"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "binom_v2"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "clickflare"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "trafficmanager"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "everflow"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "everflow_partner"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "exoclick"
                        ]
                      }
                    ]
                  },
                  "name": {
                    "minLength": 1,
                    "maxLength": 200,
                    "type": "string"
                  },
                  "base_url": {
                    "format": "uri",
                    "type": "string"
                  },
                  "api_key": {
                    "minLength": 1,
                    "type": "string"
                  },
                  "extra_config": {
                    "description": "JSON object with nested arrays and objects.",
                    "type": "object",
                    "additionalProperties": {
                      "$comment": "json-value",
                      "description": "Arbitrary JSON value with nested arrays and objects."
                    }
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "header",
            "name": "x-team-id",
            "required": false,
            "description": "Destination workspace team id."
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "201": {
            "description": "Resource created",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "id",
                    "trackerType",
                    "name",
                    "baseUrl",
                    "isActive",
                    "lastSyncAt",
                    "syncStatus",
                    "createdAt"
                  ],
                  "properties": {
                    "id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "trackerType": {
                      "type": "string"
                    },
                    "name": {
                      "type": "string"
                    },
                    "baseUrl": {
                      "type": "string"
                    },
                    "isActive": {
                      "type": "boolean"
                    },
                    "lastSyncAt": {
                      "anyOf": [
                        {
                          "format": "date-time",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "syncStatus": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "syncError": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "createdAt": {
                      "format": "date-time",
                      "type": "string"
                    },
                    "updatedAt": {
                      "anyOf": [
                        {
                          "format": "date-time",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "syncProgress": {
                      "anyOf": [
                        {
                          "type": "null"
                        },
                        {
                          "type": "object",
                          "required": [
                            "total",
                            "completed",
                            "failed"
                          ],
                          "properties": {
                            "total": {
                              "minimum": 0,
                              "type": "integer"
                            },
                            "completed": {
                              "minimum": 0,
                              "type": "integer"
                            },
                            "failed": {
                              "minimum": 0,
                              "type": "integer"
                            }
                          }
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "Conflict - resource state prevents the operation",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/trackers/{id}": {
      "get": {
        "operationId": "getApiV1TrackersById",
        "summary": "Get tracker configuration",
        "tags": [
          "trackers"
        ],
        "description": "Returns details for a specific tracker configuration.",
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          },
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "header",
            "name": "x-team-id",
            "required": false,
            "description": "Destination workspace team id."
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "id",
                    "trackerType",
                    "name",
                    "baseUrl",
                    "isActive",
                    "lastSyncAt",
                    "syncStatus",
                    "createdAt"
                  ],
                  "properties": {
                    "id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "trackerType": {
                      "type": "string"
                    },
                    "name": {
                      "type": "string"
                    },
                    "baseUrl": {
                      "type": "string"
                    },
                    "isActive": {
                      "type": "boolean"
                    },
                    "lastSyncAt": {
                      "anyOf": [
                        {
                          "format": "date-time",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "syncStatus": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "syncError": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "createdAt": {
                      "format": "date-time",
                      "type": "string"
                    },
                    "updatedAt": {
                      "anyOf": [
                        {
                          "format": "date-time",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "syncProgress": {
                      "anyOf": [
                        {
                          "type": "null"
                        },
                        {
                          "type": "object",
                          "required": [
                            "total",
                            "completed",
                            "failed"
                          ],
                          "properties": {
                            "total": {
                              "minimum": 0,
                              "type": "integer"
                            },
                            "completed": {
                              "minimum": 0,
                              "type": "integer"
                            },
                            "failed": {
                              "minimum": 0,
                              "type": "integer"
                            }
                          }
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      },
      "patch": {
        "operationId": "patchApiV1TrackersById",
        "summary": "Update tracker configuration",
        "tags": [
          "trackers"
        ],
        "description": "Updates an existing tracker configuration.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "properties": {
                  "name": {
                    "minLength": 1,
                    "maxLength": 200,
                    "type": "string"
                  },
                  "base_url": {
                    "format": "uri",
                    "type": "string"
                  },
                  "api_key": {
                    "minLength": 1,
                    "type": "string"
                  },
                  "is_active": {
                    "type": "boolean"
                  },
                  "extra_config": {
                    "description": "JSON object with nested arrays and objects.",
                    "type": "object",
                    "additionalProperties": {
                      "$comment": "json-value",
                      "description": "Arbitrary JSON value with nested arrays and objects."
                    }
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          },
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "header",
            "name": "x-team-id",
            "required": false,
            "description": "Destination workspace team id."
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "id",
                    "trackerType",
                    "name",
                    "baseUrl",
                    "isActive",
                    "lastSyncAt",
                    "syncStatus",
                    "createdAt"
                  ],
                  "properties": {
                    "id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "trackerType": {
                      "type": "string"
                    },
                    "name": {
                      "type": "string"
                    },
                    "baseUrl": {
                      "type": "string"
                    },
                    "isActive": {
                      "type": "boolean"
                    },
                    "lastSyncAt": {
                      "anyOf": [
                        {
                          "format": "date-time",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "syncStatus": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "syncError": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "createdAt": {
                      "format": "date-time",
                      "type": "string"
                    },
                    "updatedAt": {
                      "anyOf": [
                        {
                          "format": "date-time",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "syncProgress": {
                      "anyOf": [
                        {
                          "type": "null"
                        },
                        {
                          "type": "object",
                          "required": [
                            "total",
                            "completed",
                            "failed"
                          ],
                          "properties": {
                            "total": {
                              "minimum": 0,
                              "type": "integer"
                            },
                            "completed": {
                              "minimum": 0,
                              "type": "integer"
                            },
                            "failed": {
                              "minimum": 0,
                              "type": "integer"
                            }
                          }
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      },
      "delete": {
        "operationId": "deleteApiV1TrackersById",
        "summary": "Delete tracker configuration",
        "tags": [
          "trackers"
        ],
        "description": "Deletes a tracker configuration and all associated data.",
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          },
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "header",
            "name": "x-team-id",
            "required": false,
            "description": "Destination workspace team id."
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "deleted",
                    "campaigns",
                    "offers",
                    "landingPages",
                    "trafficSources",
                    "affiliateNetworks",
                    "groups",
                    "hourlyRollups",
                    "syncLogs",
                    "syncProgress"
                  ],
                  "properties": {
                    "deleted": {
                      "type": "boolean"
                    },
                    "campaigns": {
                      "type": "number"
                    },
                    "offers": {
                      "type": "number"
                    },
                    "landingPages": {
                      "type": "number"
                    },
                    "trafficSources": {
                      "type": "number"
                    },
                    "affiliateNetworks": {
                      "type": "number"
                    },
                    "groups": {
                      "type": "number"
                    },
                    "hourlyRollups": {
                      "type": "number"
                    },
                    "syncLogs": {
                      "type": "number"
                    },
                    "syncProgress": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/trackers/{id}/sync": {
      "post": {
        "operationId": "postApiV1TrackersByIdSync",
        "summary": "Trigger tracker sync",
        "tags": [
          "trackers"
        ],
        "description": "Triggers a background sync for the tracker.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "properties": {
                  "sync_type": {
                    "anyOf": [
                      {
                        "type": "string",
                        "enum": [
                          "live"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "recent"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "history"
                        ]
                      }
                    ]
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          },
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "header",
            "name": "x-team-id",
            "required": false,
            "description": "Destination workspace team id."
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "202": {
            "description": "Accepted - processing asynchronously",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "message",
                    "configId",
                    "workerRunId",
                    "state"
                  ],
                  "properties": {
                    "message": {
                      "type": "string"
                    },
                    "configId": {
                      "type": "string"
                    },
                    "workerRunId": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "state": {
                      "type": "string"
                    },
                    "retryAt": {
                      "type": "string"
                    },
                    "reason": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/trackers/{id}/sync-logs": {
      "get": {
        "operationId": "getApiV1TrackersByIdSyncLogs",
        "summary": "Get sync history",
        "tags": [
          "trackers"
        ],
        "description": "Returns recent sync logs for a tracker.",
        "parameters": [
          {
            "schema": {
              "minimum": 1,
              "maximum": 50,
              "default": 10,
              "type": "integer"
            },
            "in": "query",
            "name": "limit",
            "required": false
          },
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          },
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "header",
            "name": "x-team-id",
            "required": false,
            "description": "Destination workspace team id."
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "required": [
                      "id",
                      "startedAt",
                      "finishedAt",
                      "stalledAt",
                      "status",
                      "syncType",
                      "entitiesSynced",
                      "statsSynced",
                      "errorMessage"
                    ],
                    "properties": {
                      "id": {
                        "type": "string"
                      },
                      "startedAt": {
                        "format": "date-time",
                        "type": "string"
                      },
                      "finishedAt": {
                        "anyOf": [
                          {
                            "format": "date-time",
                            "type": "string"
                          },
                          {
                            "type": "null"
                          }
                        ]
                      },
                      "stalledAt": {
                        "anyOf": [
                          {
                            "format": "date-time",
                            "type": "string"
                          },
                          {
                            "type": "null"
                          }
                        ]
                      },
                      "status": {
                        "type": "string"
                      },
                      "syncType": {
                        "anyOf": [
                          {
                            "type": "string"
                          },
                          {
                            "type": "null"
                          }
                        ]
                      },
                      "entitiesSynced": {
                        "type": "number"
                      },
                      "statsSynced": {
                        "type": "number"
                      },
                      "errorMessage": {
                        "anyOf": [
                          {
                            "type": "string"
                          },
                          {
                            "type": "null"
                          }
                        ]
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/trackers/{id}/sync-logs/{syncLogId}/progress": {
      "get": {
        "operationId": "getApiV1TrackersByIdSyncLogsBySyncLogIdProgress",
        "summary": "Get per-unit progress for a single sync log",
        "tags": [
          "trackers"
        ],
        "description": "Returns per-unit sync progress for one tracker sync log, including processed totals, status, retry metadata, heartbeat, and last error details.",
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          },
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "syncLogId",
            "required": true
          },
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "header",
            "name": "x-team-id",
            "required": false,
            "description": "Destination workspace team id."
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "required": [
                      "unitType",
                      "unitKey",
                      "status",
                      "processedCount",
                      "totalCount",
                      "lastError",
                      "lastErrorCode",
                      "attemptCount",
                      "heartbeatAt",
                      "nextRetryAt",
                      "startedAt",
                      "completedAt",
                      "leaseActive"
                    ],
                    "properties": {
                      "unitType": {
                        "type": "string"
                      },
                      "unitKey": {
                        "type": "string"
                      },
                      "status": {
                        "type": "string"
                      },
                      "processedCount": {
                        "type": "number"
                      },
                      "totalCount": {
                        "anyOf": [
                          {
                            "type": "number"
                          },
                          {
                            "type": "null"
                          }
                        ]
                      },
                      "lastError": {
                        "anyOf": [
                          {
                            "type": "string"
                          },
                          {
                            "type": "null"
                          }
                        ]
                      },
                      "lastErrorCode": {
                        "anyOf": [
                          {
                            "type": "string"
                          },
                          {
                            "type": "null"
                          }
                        ]
                      },
                      "attemptCount": {
                        "type": "number"
                      },
                      "heartbeatAt": {
                        "anyOf": [
                          {
                            "format": "date-time",
                            "type": "string"
                          },
                          {
                            "type": "null"
                          }
                        ]
                      },
                      "nextRetryAt": {
                        "anyOf": [
                          {
                            "format": "date-time",
                            "type": "string"
                          },
                          {
                            "type": "null"
                          }
                        ]
                      },
                      "startedAt": {
                        "anyOf": [
                          {
                            "format": "date-time",
                            "type": "string"
                          },
                          {
                            "type": "null"
                          }
                        ]
                      },
                      "completedAt": {
                        "anyOf": [
                          {
                            "format": "date-time",
                            "type": "string"
                          },
                          {
                            "type": "null"
                          }
                        ]
                      },
                      "leaseActive": {
                        "type": "boolean"
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/trackers/{id}/sync-logs/{syncLogId}/debug": {
      "get": {
        "operationId": "getApiV1TrackersByIdSyncLogsBySyncLogIdDebug",
        "summary": "Get aggregated debug snapshot for a sync log",
        "tags": [
          "trackers"
        ],
        "description": "Returns an aggregated debug snapshot for one tracker sync log, including unit-level status counts, error summaries, and recent sync diagnostics.",
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          },
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "syncLogId",
            "required": true
          },
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "header",
            "name": "x-team-id",
            "required": false,
            "description": "Destination workspace team id."
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "config",
                    "syncLog",
                    "summary",
                    "rootDispatch",
                    "units"
                  ],
                  "properties": {
                    "config": {
                      "type": "object",
                      "required": [
                        "id",
                        "name",
                        "sessionId",
                        "trackerType",
                        "syncStatus",
                        "syncError",
                        "lastSyncAt",
                        "activeSyncLogId"
                      ],
                      "properties": {
                        "id": {
                          "format": "uuid",
                          "type": "string"
                        },
                        "name": {
                          "type": "string"
                        },
                        "sessionId": {
                          "format": "uuid",
                          "type": "string"
                        },
                        "trackerType": {
                          "type": "string"
                        },
                        "syncStatus": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "syncError": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "lastSyncAt": {
                          "anyOf": [
                            {
                              "format": "date-time",
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "activeSyncLogId": {
                          "anyOf": [
                            {
                              "format": "uuid",
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        }
                      }
                    },
                    "syncLog": {
                      "type": "object",
                      "required": [
                        "id",
                        "status",
                        "syncType",
                        "startedAt",
                        "finishedAt",
                        "stalledAt",
                        "entitiesSynced",
                        "statsSynced",
                        "errorMessage",
                        "metadata"
                      ],
                      "properties": {
                        "id": {
                          "format": "uuid",
                          "type": "string"
                        },
                        "status": {
                          "type": "string"
                        },
                        "syncType": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "startedAt": {
                          "format": "date-time",
                          "type": "string"
                        },
                        "finishedAt": {
                          "anyOf": [
                            {
                              "format": "date-time",
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "stalledAt": {
                          "anyOf": [
                            {
                              "format": "date-time",
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "entitiesSynced": {
                          "type": "number"
                        },
                        "statsSynced": {
                          "type": "number"
                        },
                        "errorMessage": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "metadata": {
                          "$comment": "json-value",
                          "description": "Arbitrary JSON value with nested arrays and objects."
                        }
                      }
                    },
                    "summary": {
                      "type": "object",
                      "required": [
                        "totalUnits",
                        "statusCounts",
                        "unitTypeCounts",
                        "lastHeartbeatAt",
                        "leasedUnitCount",
                        "nextRetryAt",
                        "maxAttemptCount",
                        "ownedByConfig"
                      ],
                      "properties": {
                        "totalUnits": {
                          "minimum": 0,
                          "type": "integer"
                        },
                        "statusCounts": {
                          "type": "object",
                          "required": [
                            "pending",
                            "inProgress",
                            "retrying",
                            "completed",
                            "failed"
                          ],
                          "properties": {
                            "pending": {
                              "minimum": 0,
                              "type": "integer"
                            },
                            "inProgress": {
                              "minimum": 0,
                              "type": "integer"
                            },
                            "retrying": {
                              "minimum": 0,
                              "type": "integer"
                            },
                            "completed": {
                              "minimum": 0,
                              "type": "integer"
                            },
                            "failed": {
                              "minimum": 0,
                              "type": "integer"
                            }
                          }
                        },
                        "unitTypeCounts": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "required": [
                              "unitType",
                              "total",
                              "statusCounts"
                            ],
                            "properties": {
                              "unitType": {
                                "type": "string"
                              },
                              "total": {
                                "minimum": 0,
                                "type": "integer"
                              },
                              "statusCounts": {
                                "type": "object",
                                "required": [
                                  "pending",
                                  "inProgress",
                                  "retrying",
                                  "completed",
                                  "failed"
                                ],
                                "properties": {
                                  "pending": {
                                    "minimum": 0,
                                    "type": "integer"
                                  },
                                  "inProgress": {
                                    "minimum": 0,
                                    "type": "integer"
                                  },
                                  "retrying": {
                                    "minimum": 0,
                                    "type": "integer"
                                  },
                                  "completed": {
                                    "minimum": 0,
                                    "type": "integer"
                                  },
                                  "failed": {
                                    "minimum": 0,
                                    "type": "integer"
                                  }
                                }
                              }
                            }
                          }
                        },
                        "lastHeartbeatAt": {
                          "anyOf": [
                            {
                              "format": "date-time",
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "leasedUnitCount": {
                          "minimum": 0,
                          "type": "integer"
                        },
                        "nextRetryAt": {
                          "anyOf": [
                            {
                              "format": "date-time",
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "maxAttemptCount": {
                          "minimum": 0,
                          "type": "integer"
                        },
                        "ownedByConfig": {
                          "type": "boolean"
                        }
                      }
                    },
                    "rootDispatch": {
                      "anyOf": [
                        {
                          "type": "null"
                        },
                        {
                          "type": "object",
                          "required": [
                            "workerRunId",
                            "workerRunStatus",
                            "createdAt",
                            "updatedAt",
                            "totalEvents",
                            "latestDispatchState",
                            "latestReason",
                            "nextDispatchAt",
                            "events"
                          ],
                          "properties": {
                            "workerRunId": {
                              "format": "uuid",
                              "type": "string"
                            },
                            "workerRunStatus": {
                              "type": "string"
                            },
                            "createdAt": {
                              "format": "date-time",
                              "type": "string"
                            },
                            "updatedAt": {
                              "anyOf": [
                                {
                                  "format": "date-time",
                                  "type": "string"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "totalEvents": {
                              "minimum": 0,
                              "type": "integer"
                            },
                            "latestDispatchState": {
                              "anyOf": [
                                {
                                  "type": "string"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "latestReason": {
                              "anyOf": [
                                {
                                  "type": "string"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "nextDispatchAt": {
                              "anyOf": [
                                {
                                  "format": "date-time",
                                  "type": "string"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "events": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "required": [
                                  "dispatchAttempt",
                                  "dispatchState",
                                  "eventStatus",
                                  "nextDispatchAt",
                                  "reason",
                                  "requeueAttempt",
                                  "source",
                                  "syncLogId",
                                  "createdAt"
                                ],
                                "properties": {
                                  "dispatchAttempt": {
                                    "minimum": 0,
                                    "type": "integer"
                                  },
                                  "dispatchState": {
                                    "anyOf": [
                                      {
                                        "type": "string"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "eventStatus": {
                                    "type": "string"
                                  },
                                  "nextDispatchAt": {
                                    "anyOf": [
                                      {
                                        "format": "date-time",
                                        "type": "string"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "reason": {
                                    "anyOf": [
                                      {
                                        "type": "string"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "requeueAttempt": {
                                    "minimum": 0,
                                    "type": "integer"
                                  },
                                  "source": {
                                    "anyOf": [
                                      {
                                        "type": "string"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "syncLogId": {
                                    "anyOf": [
                                      {
                                        "format": "uuid",
                                        "type": "string"
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "createdAt": {
                                    "format": "date-time",
                                    "type": "string"
                                  }
                                }
                              }
                            }
                          }
                        }
                      ]
                    },
                    "units": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "unitType",
                          "unitKey",
                          "status",
                          "processedCount",
                          "totalCount",
                          "lastError",
                          "lastErrorCode",
                          "attemptCount",
                          "heartbeatAt",
                          "nextRetryAt",
                          "startedAt",
                          "completedAt",
                          "leaseActive"
                        ],
                        "properties": {
                          "unitType": {
                            "type": "string"
                          },
                          "unitKey": {
                            "type": "string"
                          },
                          "status": {
                            "type": "string"
                          },
                          "processedCount": {
                            "type": "number"
                          },
                          "totalCount": {
                            "anyOf": [
                              {
                                "type": "number"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "lastError": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "lastErrorCode": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "attemptCount": {
                            "type": "number"
                          },
                          "heartbeatAt": {
                            "anyOf": [
                              {
                                "format": "date-time",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "nextRetryAt": {
                            "anyOf": [
                              {
                                "format": "date-time",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "startedAt": {
                            "anyOf": [
                              {
                                "format": "date-time",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "completedAt": {
                            "anyOf": [
                              {
                                "format": "date-time",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "leaseActive": {
                            "type": "boolean"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/trackers/{id}/campaigns": {
      "get": {
        "operationId": "getApiV1TrackersByIdCampaigns",
        "summary": "List tracker campaigns",
        "tags": [
          "trackers"
        ],
        "description": "Returns synced campaigns for a tracker.",
        "parameters": [
          {
            "schema": {
              "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
              "type": "string"
            },
            "in": "query",
            "name": "from_date",
            "required": true
          },
          {
            "schema": {
              "type": "boolean"
            },
            "in": "query",
            "name": "include_metrics",
            "required": false
          },
          {
            "schema": {
              "minimum": 1,
              "maximum": 500,
              "type": "integer"
            },
            "in": "query",
            "name": "limit",
            "required": false
          },
          {
            "schema": {
              "minimum": 0,
              "type": "integer"
            },
            "in": "query",
            "name": "offset",
            "required": false
          },
          {
            "schema": {
              "maxLength": 200,
              "type": "string"
            },
            "in": "query",
            "name": "search",
            "required": false
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "sort_by",
            "required": false
          },
          {
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "enum": [
                    "asc"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "desc"
                  ]
                }
              ]
            },
            "in": "query",
            "name": "sort_order",
            "required": false
          },
          {
            "schema": {
              "pattern": "^[A-Za-z0-9_/+-]+$",
              "type": "string"
            },
            "in": "query",
            "name": "timezone",
            "required": false
          },
          {
            "schema": {
              "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
              "type": "string"
            },
            "in": "query",
            "name": "to_date",
            "required": true
          },
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          },
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "header",
            "name": "x-team-id",
            "required": false,
            "description": "Destination workspace team id."
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "items",
                    "hasMore",
                    "total",
                    "limit",
                    "offset"
                  ],
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "id",
                          "externalId",
                          "name",
                          "status",
                          "groupName",
                          "costModel",
                          "costValueCents",
                          "currency",
                          "clicks",
                          "conversions",
                          "revenueCents",
                          "costCents",
                          "profitCents",
                          "cr",
                          "roi",
                          "isPartial",
                          "updatedThrough",
                          "syncedAt"
                        ],
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "externalId": {
                            "type": "string"
                          },
                          "name": {
                            "type": "string"
                          },
                          "status": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "groupName": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "costModel": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "costValueCents": {
                            "anyOf": [
                              {
                                "type": "number"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "currency": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "clicks": {
                            "type": "number"
                          },
                          "conversions": {
                            "type": "number"
                          },
                          "revenueCents": {
                            "type": "string"
                          },
                          "costCents": {
                            "type": "string"
                          },
                          "profitCents": {
                            "type": "string"
                          },
                          "cr": {
                            "anyOf": [
                              {
                                "type": "number"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "roi": {
                            "anyOf": [
                              {
                                "type": "number"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "isPartial": {
                            "type": "boolean"
                          },
                          "updatedThrough": {
                            "anyOf": [
                              {
                                "format": "date-time",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "syncedAt": {
                            "format": "date-time",
                            "type": "string"
                          }
                        }
                      }
                    },
                    "hasMore": {
                      "type": "boolean"
                    },
                    "total": {
                      "minimum": 0,
                      "type": "integer"
                    },
                    "limit": {
                      "minimum": 1,
                      "type": "integer"
                    },
                    "offset": {
                      "minimum": 0,
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/trackers/{id}/offers": {
      "get": {
        "operationId": "getApiV1TrackersByIdOffers",
        "summary": "List tracker offers",
        "tags": [
          "trackers"
        ],
        "description": "Returns synced offers for a tracker.",
        "parameters": [
          {
            "schema": {
              "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
              "type": "string"
            },
            "in": "query",
            "name": "from_date",
            "required": true
          },
          {
            "schema": {
              "type": "boolean"
            },
            "in": "query",
            "name": "include_metrics",
            "required": false
          },
          {
            "schema": {
              "minimum": 1,
              "maximum": 500,
              "type": "integer"
            },
            "in": "query",
            "name": "limit",
            "required": false
          },
          {
            "schema": {
              "minimum": 0,
              "type": "integer"
            },
            "in": "query",
            "name": "offset",
            "required": false
          },
          {
            "schema": {
              "maxLength": 200,
              "type": "string"
            },
            "in": "query",
            "name": "search",
            "required": false
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "sort_by",
            "required": false
          },
          {
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "enum": [
                    "asc"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "desc"
                  ]
                }
              ]
            },
            "in": "query",
            "name": "sort_order",
            "required": false
          },
          {
            "schema": {
              "pattern": "^[A-Za-z0-9_/+-]+$",
              "type": "string"
            },
            "in": "query",
            "name": "timezone",
            "required": false
          },
          {
            "schema": {
              "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
              "type": "string"
            },
            "in": "query",
            "name": "to_date",
            "required": true
          },
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          },
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "header",
            "name": "x-team-id",
            "required": false,
            "description": "Destination workspace team id."
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "items",
                    "hasMore",
                    "total",
                    "limit",
                    "offset"
                  ],
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "id",
                          "externalId",
                          "name",
                          "status",
                          "url",
                          "payoutCents",
                          "currency",
                          "clicks",
                          "conversions",
                          "revenueCents",
                          "costCents",
                          "profitCents",
                          "cr",
                          "roi",
                          "isPartial",
                          "updatedThrough",
                          "syncedAt"
                        ],
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "externalId": {
                            "type": "string"
                          },
                          "name": {
                            "type": "string"
                          },
                          "status": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "url": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "payoutCents": {
                            "anyOf": [
                              {
                                "type": "number"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "currency": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "clicks": {
                            "type": "number"
                          },
                          "conversions": {
                            "type": "number"
                          },
                          "revenueCents": {
                            "type": "string"
                          },
                          "costCents": {
                            "type": "string"
                          },
                          "profitCents": {
                            "type": "string"
                          },
                          "cr": {
                            "anyOf": [
                              {
                                "type": "number"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "roi": {
                            "anyOf": [
                              {
                                "type": "number"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "isPartial": {
                            "type": "boolean"
                          },
                          "updatedThrough": {
                            "anyOf": [
                              {
                                "format": "date-time",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "syncedAt": {
                            "format": "date-time",
                            "type": "string"
                          }
                        }
                      }
                    },
                    "hasMore": {
                      "type": "boolean"
                    },
                    "total": {
                      "minimum": 0,
                      "type": "integer"
                    },
                    "limit": {
                      "minimum": 1,
                      "type": "integer"
                    },
                    "offset": {
                      "minimum": 0,
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/trackers/{id}/landing-pages": {
      "get": {
        "operationId": "getApiV1TrackersByIdLandingPages",
        "summary": "List tracker landing pages",
        "tags": [
          "trackers"
        ],
        "description": "Returns synced landing pages for a tracker.",
        "parameters": [
          {
            "schema": {
              "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
              "type": "string"
            },
            "in": "query",
            "name": "from_date",
            "required": true
          },
          {
            "schema": {
              "type": "boolean"
            },
            "in": "query",
            "name": "include_metrics",
            "required": false
          },
          {
            "schema": {
              "minimum": 1,
              "maximum": 500,
              "type": "integer"
            },
            "in": "query",
            "name": "limit",
            "required": false
          },
          {
            "schema": {
              "minimum": 0,
              "type": "integer"
            },
            "in": "query",
            "name": "offset",
            "required": false
          },
          {
            "schema": {
              "maxLength": 200,
              "type": "string"
            },
            "in": "query",
            "name": "search",
            "required": false
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "sort_by",
            "required": false
          },
          {
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "enum": [
                    "asc"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "desc"
                  ]
                }
              ]
            },
            "in": "query",
            "name": "sort_order",
            "required": false
          },
          {
            "schema": {
              "pattern": "^[A-Za-z0-9_/+-]+$",
              "type": "string"
            },
            "in": "query",
            "name": "timezone",
            "required": false
          },
          {
            "schema": {
              "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
              "type": "string"
            },
            "in": "query",
            "name": "to_date",
            "required": true
          },
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          },
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "header",
            "name": "x-team-id",
            "required": false,
            "description": "Destination workspace team id."
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "items",
                    "hasMore",
                    "total",
                    "limit",
                    "offset"
                  ],
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "id",
                          "externalId",
                          "name",
                          "status",
                          "url",
                          "clicks",
                          "conversions",
                          "revenueCents",
                          "costCents",
                          "profitCents",
                          "cr",
                          "roi",
                          "isPartial",
                          "updatedThrough",
                          "syncedAt"
                        ],
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "externalId": {
                            "type": "string"
                          },
                          "name": {
                            "type": "string"
                          },
                          "status": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "url": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "clicks": {
                            "type": "number"
                          },
                          "conversions": {
                            "type": "number"
                          },
                          "revenueCents": {
                            "type": "string"
                          },
                          "costCents": {
                            "type": "string"
                          },
                          "profitCents": {
                            "type": "string"
                          },
                          "cr": {
                            "anyOf": [
                              {
                                "type": "number"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "roi": {
                            "anyOf": [
                              {
                                "type": "number"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "isPartial": {
                            "type": "boolean"
                          },
                          "updatedThrough": {
                            "anyOf": [
                              {
                                "format": "date-time",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "syncedAt": {
                            "format": "date-time",
                            "type": "string"
                          }
                        }
                      }
                    },
                    "hasMore": {
                      "type": "boolean"
                    },
                    "total": {
                      "minimum": 0,
                      "type": "integer"
                    },
                    "limit": {
                      "minimum": 1,
                      "type": "integer"
                    },
                    "offset": {
                      "minimum": 0,
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/trackers/{id}/traffic-sources": {
      "get": {
        "operationId": "getApiV1TrackersByIdTrafficSources",
        "summary": "List tracker traffic sources",
        "tags": [
          "trackers"
        ],
        "description": "Returns synced traffic sources for a tracker.",
        "parameters": [
          {
            "schema": {
              "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
              "type": "string"
            },
            "in": "query",
            "name": "from_date",
            "required": true
          },
          {
            "schema": {
              "type": "boolean"
            },
            "in": "query",
            "name": "include_metrics",
            "required": false
          },
          {
            "schema": {
              "minimum": 1,
              "maximum": 500,
              "type": "integer"
            },
            "in": "query",
            "name": "limit",
            "required": false
          },
          {
            "schema": {
              "minimum": 0,
              "type": "integer"
            },
            "in": "query",
            "name": "offset",
            "required": false
          },
          {
            "schema": {
              "maxLength": 200,
              "type": "string"
            },
            "in": "query",
            "name": "search",
            "required": false
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "sort_by",
            "required": false
          },
          {
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "enum": [
                    "asc"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "desc"
                  ]
                }
              ]
            },
            "in": "query",
            "name": "sort_order",
            "required": false
          },
          {
            "schema": {
              "pattern": "^[A-Za-z0-9_/+-]+$",
              "type": "string"
            },
            "in": "query",
            "name": "timezone",
            "required": false
          },
          {
            "schema": {
              "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
              "type": "string"
            },
            "in": "query",
            "name": "to_date",
            "required": true
          },
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          },
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "header",
            "name": "x-team-id",
            "required": false,
            "description": "Destination workspace team id."
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "items",
                    "hasMore",
                    "total",
                    "limit",
                    "offset"
                  ],
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "id",
                          "externalId",
                          "name",
                          "status",
                          "template",
                          "postbackUrl",
                          "clicks",
                          "conversions",
                          "revenueCents",
                          "costCents",
                          "profitCents",
                          "cr",
                          "roi",
                          "isPartial",
                          "updatedThrough",
                          "syncedAt"
                        ],
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "externalId": {
                            "type": "string"
                          },
                          "name": {
                            "type": "string"
                          },
                          "status": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "template": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "postbackUrl": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "clicks": {
                            "type": "number"
                          },
                          "conversions": {
                            "type": "number"
                          },
                          "revenueCents": {
                            "type": "string"
                          },
                          "costCents": {
                            "type": "string"
                          },
                          "profitCents": {
                            "type": "string"
                          },
                          "cr": {
                            "anyOf": [
                              {
                                "type": "number"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "roi": {
                            "anyOf": [
                              {
                                "type": "number"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "isPartial": {
                            "type": "boolean"
                          },
                          "updatedThrough": {
                            "anyOf": [
                              {
                                "format": "date-time",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "syncedAt": {
                            "format": "date-time",
                            "type": "string"
                          }
                        }
                      }
                    },
                    "hasMore": {
                      "type": "boolean"
                    },
                    "total": {
                      "minimum": 0,
                      "type": "integer"
                    },
                    "limit": {
                      "minimum": 1,
                      "type": "integer"
                    },
                    "offset": {
                      "minimum": 0,
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/trackers/{id}/affiliate-networks": {
      "get": {
        "operationId": "getApiV1TrackersByIdAffiliateNetworks",
        "summary": "List tracker affiliate networks",
        "tags": [
          "trackers"
        ],
        "description": "Returns synced affiliate networks for a tracker.",
        "parameters": [
          {
            "schema": {
              "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
              "type": "string"
            },
            "in": "query",
            "name": "from_date",
            "required": true
          },
          {
            "schema": {
              "type": "boolean"
            },
            "in": "query",
            "name": "include_metrics",
            "required": false
          },
          {
            "schema": {
              "minimum": 1,
              "maximum": 500,
              "type": "integer"
            },
            "in": "query",
            "name": "limit",
            "required": false
          },
          {
            "schema": {
              "minimum": 0,
              "type": "integer"
            },
            "in": "query",
            "name": "offset",
            "required": false
          },
          {
            "schema": {
              "maxLength": 200,
              "type": "string"
            },
            "in": "query",
            "name": "search",
            "required": false
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "sort_by",
            "required": false
          },
          {
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "enum": [
                    "asc"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "desc"
                  ]
                }
              ]
            },
            "in": "query",
            "name": "sort_order",
            "required": false
          },
          {
            "schema": {
              "pattern": "^[A-Za-z0-9_/+-]+$",
              "type": "string"
            },
            "in": "query",
            "name": "timezone",
            "required": false
          },
          {
            "schema": {
              "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
              "type": "string"
            },
            "in": "query",
            "name": "to_date",
            "required": true
          },
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          },
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "header",
            "name": "x-team-id",
            "required": false,
            "description": "Destination workspace team id."
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "items",
                    "hasMore",
                    "total",
                    "limit",
                    "offset"
                  ],
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "id",
                          "externalId",
                          "name",
                          "postbackUrl",
                          "clicks",
                          "conversions",
                          "revenueCents",
                          "costCents",
                          "profitCents",
                          "cr",
                          "roi",
                          "isPartial",
                          "updatedThrough",
                          "syncedAt"
                        ],
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "externalId": {
                            "type": "string"
                          },
                          "name": {
                            "type": "string"
                          },
                          "postbackUrl": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "clicks": {
                            "type": "number"
                          },
                          "conversions": {
                            "type": "number"
                          },
                          "revenueCents": {
                            "type": "string"
                          },
                          "costCents": {
                            "type": "string"
                          },
                          "profitCents": {
                            "type": "string"
                          },
                          "cr": {
                            "anyOf": [
                              {
                                "type": "number"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "roi": {
                            "anyOf": [
                              {
                                "type": "number"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "isPartial": {
                            "type": "boolean"
                          },
                          "updatedThrough": {
                            "anyOf": [
                              {
                                "format": "date-time",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "syncedAt": {
                            "format": "date-time",
                            "type": "string"
                          }
                        }
                      }
                    },
                    "hasMore": {
                      "type": "boolean"
                    },
                    "total": {
                      "minimum": 0,
                      "type": "integer"
                    },
                    "limit": {
                      "minimum": 1,
                      "type": "integer"
                    },
                    "offset": {
                      "minimum": 0,
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/trackers/{id}/stats": {
      "get": {
        "operationId": "getApiV1TrackersByIdStats",
        "summary": "Get tracker daily stats",
        "tags": [
          "trackers"
        ],
        "description": "Returns daily statistics for a tracker.",
        "parameters": [
          {
            "schema": {
              "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
              "type": "string"
            },
            "in": "query",
            "name": "from_date",
            "required": true
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "campaign_id",
            "required": false
          },
          {
            "schema": {
              "pattern": "^[A-Za-z0-9_/+-]+$",
              "type": "string"
            },
            "in": "query",
            "name": "timezone",
            "required": false
          },
          {
            "schema": {
              "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
              "type": "string"
            },
            "in": "query",
            "name": "to_date",
            "required": true
          },
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          },
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "header",
            "name": "x-team-id",
            "required": false,
            "description": "Destination workspace team id."
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "required": [
                      "date",
                      "campaignExternalId",
                      "clicks",
                      "conversions",
                      "revenueCents",
                      "costCents",
                      "profitCents",
                      "roi",
                      "cr",
                      "isPartial",
                      "updatedThrough"
                    ],
                    "properties": {
                      "date": {
                        "format": "date",
                        "type": "string"
                      },
                      "campaignExternalId": {
                        "anyOf": [
                          {
                            "type": "string"
                          },
                          {
                            "type": "null"
                          }
                        ]
                      },
                      "clicks": {
                        "type": "number"
                      },
                      "conversions": {
                        "type": "number"
                      },
                      "revenueCents": {
                        "type": "string"
                      },
                      "costCents": {
                        "type": "string"
                      },
                      "profitCents": {
                        "type": "string"
                      },
                      "roi": {
                        "anyOf": [
                          {
                            "type": "number"
                          },
                          {
                            "type": "null"
                          }
                        ]
                      },
                      "cr": {
                        "anyOf": [
                          {
                            "type": "number"
                          },
                          {
                            "type": "null"
                          }
                        ]
                      },
                      "isPartial": {
                        "type": "boolean"
                      },
                      "updatedThrough": {
                        "anyOf": [
                          {
                            "format": "date-time",
                            "type": "string"
                          },
                          {
                            "type": "null"
                          }
                        ]
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/trackers/{id}/goals": {
      "get": {
        "operationId": "getApiV1TrackersByIdGoals",
        "summary": "List conversion goals",
        "tags": [
          "trackers"
        ],
        "description": "Conversion goals defined on the connected account. Only for trackers where the user must choose which goal counts as a conversion (ExoClick); 400 otherwise.",
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          },
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "header",
            "name": "x-team-id",
            "required": false,
            "description": "Destination workspace team id."
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "goals"
                  ],
                  "properties": {
                    "goals": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "id",
                          "name",
                          "payoutType"
                        ],
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "name": {
                            "type": "string"
                          },
                          "payout": {
                            "type": "string"
                          },
                          "payoutType": {
                            "anyOf": [
                              {
                                "type": "string",
                                "enum": [
                                  "dynamic"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "fixed"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "none"
                                ]
                              }
                            ]
                          }
                        }
                      }
                    },
                    "selectedGoalId": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/trackers/{id}/postback": {
      "get": {
        "operationId": "getApiV1TrackersByIdPostback",
        "summary": "Get postback template",
        "tags": [
          "trackers"
        ],
        "description": "Returns the postback URL template for a tracker.",
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          },
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "header",
            "name": "x-team-id",
            "required": false,
            "description": "Destination workspace team id."
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "url",
                    "placeholders"
                  ],
                  "properties": {
                    "url": {
                      "type": "string"
                    },
                    "placeholders": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "token",
                          "description",
                          "required"
                        ],
                        "properties": {
                          "token": {
                            "type": "string"
                          },
                          "description": {
                            "type": "string"
                          },
                          "required": {
                            "type": "boolean"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/usage/breakdown": {
      "get": {
        "operationId": "getUsageBreakdown",
        "summary": "Get platform usage breakdown by workspace and user",
        "tags": [
          "usage"
        ],
        "description": "Aggregates platform usage events and AI credit consumption over a time window, split per workspace (team) and per user. Owner/admin only; scoped to the active organization/team.",
        "parameters": [
          {
            "schema": {
              "format": "date-time",
              "type": "string"
            },
            "in": "query",
            "name": "from",
            "required": false,
            "description": "Window start (ISO). Defaults to 30 days ago."
          },
          {
            "schema": {
              "format": "date-time",
              "type": "string"
            },
            "in": "query",
            "name": "to",
            "required": false,
            "description": "Window end (ISO). Defaults to now."
          }
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "from",
                    "to",
                    "totals",
                    "by_workspace",
                    "by_user"
                  ],
                  "properties": {
                    "from": {
                      "format": "date-time",
                      "type": "string"
                    },
                    "to": {
                      "format": "date-time",
                      "type": "string"
                    },
                    "totals": {
                      "type": "object",
                      "required": [
                        "events_total",
                        "campaigns_launched",
                        "logins",
                        "ai_credits_used",
                        "active_users",
                        "workspace_count"
                      ],
                      "properties": {
                        "events_total": {
                          "type": "integer"
                        },
                        "campaigns_launched": {
                          "type": "integer"
                        },
                        "logins": {
                          "type": "integer"
                        },
                        "ai_credits_used": {
                          "type": "integer"
                        },
                        "active_users": {
                          "type": "integer"
                        },
                        "workspace_count": {
                          "type": "integer"
                        }
                      }
                    },
                    "by_workspace": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "team_id",
                          "name",
                          "events_total",
                          "campaigns_launched",
                          "logins",
                          "active_users"
                        ],
                        "properties": {
                          "team_id": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "name": {
                            "type": "string"
                          },
                          "events_total": {
                            "type": "integer"
                          },
                          "campaigns_launched": {
                            "type": "integer"
                          },
                          "logins": {
                            "type": "integer"
                          },
                          "active_users": {
                            "type": "integer"
                          }
                        }
                      }
                    },
                    "by_user": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "user_id",
                          "name",
                          "email",
                          "events_total",
                          "campaigns_launched",
                          "logins",
                          "ai_credits_used"
                        ],
                        "properties": {
                          "user_id": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "name": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "email": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "events_total": {
                            "type": "integer"
                          },
                          "campaigns_launched": {
                            "type": "integer"
                          },
                          "logins": {
                            "type": "integer"
                          },
                          "ai_credits_used": {
                            "description": "AI credits consumed in the window (absolute value).",
                            "type": "integer"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/user/preferences/{key}": {
      "get": {
        "operationId": "getUserUiPreference",
        "summary": "Get a user UI preference by key",
        "tags": [
          "user-preferences"
        ],
        "description": "Returns the stored preference for the current user. Allowed keys: home_layout, sidebar_menu, dashboard_columns, conversion_source, conversion_source_prompt_seen. Returns null pref_value when no value is stored — callers should treat this as \"use the default\".",
        "parameters": [
          {
            "schema": {
              "minLength": 1,
              "maxLength": 64,
              "type": "string"
            },
            "in": "path",
            "name": "key",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "user_id",
                    "pref_key",
                    "pref_value",
                    "updated_at"
                  ],
                  "properties": {
                    "user_id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "pref_key": {
                      "type": "string"
                    },
                    "pref_value": {
                      "anyOf": [
                        {
                          "$comment": "json-value",
                          "description": "Arbitrary JSON value with nested arrays and objects."
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "updated_at": {
                      "anyOf": [
                        {
                          "format": "date-time",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      },
      "put": {
        "operationId": "setUserUiPreference",
        "summary": "Create or update a user UI preference",
        "tags": [
          "user-preferences"
        ],
        "description": "Upserts the preference value for the current user. Body is JSON-serializable, max 16 KB. Allowed keys: home_layout, sidebar_menu, dashboard_columns, conversion_source, conversion_source_prompt_seen.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "value"
                ],
                "properties": {
                  "value": {
                    "$comment": "json-value",
                    "description": "Arbitrary JSON value with nested arrays and objects."
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "schema": {
              "minLength": 1,
              "maxLength": 64,
              "type": "string"
            },
            "in": "path",
            "name": "key",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "user_id",
                    "pref_key",
                    "pref_value",
                    "updated_at"
                  ],
                  "properties": {
                    "user_id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "pref_key": {
                      "type": "string"
                    },
                    "pref_value": {
                      "anyOf": [
                        {
                          "$comment": "json-value",
                          "description": "Arbitrary JSON value with nested arrays and objects."
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "updated_at": {
                      "anyOf": [
                        {
                          "format": "date-time",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "413": {
            "description": "Payload too large",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      },
      "delete": {
        "operationId": "deleteUserUiPreference",
        "summary": "Reset a user UI preference to its default",
        "tags": [
          "user-preferences"
        ],
        "description": "Deletes the stored preference. Subsequent GET returns 404 (caller falls back to default).",
        "parameters": [
          {
            "schema": {
              "minLength": 1,
              "maxLength": 64,
              "type": "string"
            },
            "in": "path",
            "name": "key",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "204": {
            "description": "No content"
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/utm/templates": {
      "get": {
        "operationId": "getApiV1UtmTemplates",
        "summary": "Lista template UTM del team",
        "tags": [
          "utm"
        ],
        "description": "Returns UTM templates visible to the current team scope so users can reuse standard source, medium, campaign, and custom parameters.",
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "required": [
                      "id",
                      "user_id",
                      "name",
                      "utm_source",
                      "utm_medium",
                      "utm_campaign",
                      "utm_term",
                      "utm_content",
                      "utm_id",
                      "custom_params",
                      "base_url",
                      "created_at",
                      "updated_at",
                      "deleted_at"
                    ],
                    "properties": {
                      "id": {
                        "format": "uuid",
                        "type": "string"
                      },
                      "user_id": {
                        "format": "uuid",
                        "type": "string"
                      },
                      "name": {
                        "type": "string"
                      },
                      "utm_source": {
                        "anyOf": [
                          {
                            "type": "string"
                          },
                          {
                            "type": "null"
                          }
                        ]
                      },
                      "utm_medium": {
                        "anyOf": [
                          {
                            "type": "string"
                          },
                          {
                            "type": "null"
                          }
                        ]
                      },
                      "utm_campaign": {
                        "anyOf": [
                          {
                            "type": "string"
                          },
                          {
                            "type": "null"
                          }
                        ]
                      },
                      "utm_term": {
                        "anyOf": [
                          {
                            "type": "string"
                          },
                          {
                            "type": "null"
                          }
                        ]
                      },
                      "utm_content": {
                        "anyOf": [
                          {
                            "type": "string"
                          },
                          {
                            "type": "null"
                          }
                        ]
                      },
                      "utm_id": {
                        "anyOf": [
                          {
                            "type": "string"
                          },
                          {
                            "type": "null"
                          }
                        ]
                      },
                      "custom_params": {
                        "anyOf": [
                          {
                            "type": "object",
                            "additionalProperties": {
                              "maxLength": 500,
                              "type": "string"
                            }
                          },
                          {
                            "type": "null"
                          }
                        ]
                      },
                      "base_url": {
                        "anyOf": [
                          {
                            "type": "string"
                          },
                          {
                            "type": "null"
                          }
                        ]
                      },
                      "created_at": {
                        "format": "date-time",
                        "type": "string"
                      },
                      "updated_at": {
                        "anyOf": [
                          {
                            "format": "date-time",
                            "type": "string"
                          },
                          {
                            "type": "null"
                          }
                        ]
                      },
                      "deleted_at": {
                        "anyOf": [
                          {
                            "format": "date-time",
                            "type": "string"
                          },
                          {
                            "type": "null"
                          }
                        ]
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "postApiV1UtmTemplates",
        "summary": "Crea template UTM (scope team)",
        "tags": [
          "utm"
        ],
        "description": "Creates a reusable UTM template for the current team with optional base URL, standard UTM fields, and custom parameters.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "name"
                ],
                "properties": {
                  "name": {
                    "minLength": 1,
                    "maxLength": 100,
                    "type": "string"
                  },
                  "utm_source": {
                    "anyOf": [
                      {
                        "maxLength": 100,
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "utm_medium": {
                    "anyOf": [
                      {
                        "maxLength": 100,
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "utm_campaign": {
                    "anyOf": [
                      {
                        "maxLength": 200,
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "utm_term": {
                    "anyOf": [
                      {
                        "maxLength": 200,
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "utm_content": {
                    "anyOf": [
                      {
                        "maxLength": 200,
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "utm_id": {
                    "anyOf": [
                      {
                        "maxLength": 200,
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "custom_params": {
                    "anyOf": [
                      {
                        "type": "object",
                        "additionalProperties": {
                          "maxLength": 500,
                          "type": "string"
                        }
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "base_url": {
                    "anyOf": [
                      {
                        "format": "uri",
                        "maxLength": 2000,
                        "type": "string"
                      },
                      {
                        "type": "string",
                        "enum": [
                          ""
                        ]
                      },
                      {
                        "type": "null"
                      }
                    ]
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "201": {
            "description": "Resource created",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "id",
                    "user_id",
                    "name",
                    "utm_source",
                    "utm_medium",
                    "utm_campaign",
                    "utm_term",
                    "utm_content",
                    "utm_id",
                    "custom_params",
                    "base_url",
                    "created_at",
                    "updated_at",
                    "deleted_at"
                  ],
                  "properties": {
                    "id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "user_id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "name": {
                      "type": "string"
                    },
                    "utm_source": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "utm_medium": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "utm_campaign": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "utm_term": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "utm_content": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "utm_id": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "custom_params": {
                      "anyOf": [
                        {
                          "type": "object",
                          "additionalProperties": {
                            "maxLength": 500,
                            "type": "string"
                          }
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "base_url": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "created_at": {
                      "format": "date-time",
                      "type": "string"
                    },
                    "updated_at": {
                      "anyOf": [
                        {
                          "format": "date-time",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "deleted_at": {
                      "anyOf": [
                        {
                          "format": "date-time",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/utm/templates/{id}": {
      "put": {
        "operationId": "putApiV1UtmTemplatesById",
        "summary": "Aggiorna template UTM",
        "tags": [
          "utm"
        ],
        "description": "Updates a reusable UTM template if it belongs to one of the team sessions accessible to the caller.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "name"
                ],
                "properties": {
                  "name": {
                    "minLength": 1,
                    "maxLength": 100,
                    "type": "string"
                  },
                  "utm_source": {
                    "anyOf": [
                      {
                        "maxLength": 100,
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "utm_medium": {
                    "anyOf": [
                      {
                        "maxLength": 100,
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "utm_campaign": {
                    "anyOf": [
                      {
                        "maxLength": 200,
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "utm_term": {
                    "anyOf": [
                      {
                        "maxLength": 200,
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "utm_content": {
                    "anyOf": [
                      {
                        "maxLength": 200,
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "utm_id": {
                    "anyOf": [
                      {
                        "maxLength": 200,
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "custom_params": {
                    "anyOf": [
                      {
                        "type": "object",
                        "additionalProperties": {
                          "maxLength": 500,
                          "type": "string"
                        }
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "base_url": {
                    "anyOf": [
                      {
                        "format": "uri",
                        "maxLength": 2000,
                        "type": "string"
                      },
                      {
                        "type": "string",
                        "enum": [
                          ""
                        ]
                      },
                      {
                        "type": "null"
                      }
                    ]
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "updated"
                  ],
                  "properties": {
                    "updated": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      },
      "delete": {
        "operationId": "deleteApiV1UtmTemplatesById",
        "summary": "Elimina template UTM (soft delete)",
        "tags": [
          "utm"
        ],
        "description": "Soft-deletes a reusable UTM template owned by one of the team sessions accessible to the caller.",
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "deleted"
                  ],
                  "properties": {
                    "deleted": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/utm/links": {
      "get": {
        "operationId": "getApiV1UtmLinks",
        "summary": "Lista storico link UTM del team (paginata)",
        "tags": [
          "utm"
        ],
        "description": "Returns paginated UTM link history for accessible team sessions, with optional text search over saved links.",
        "parameters": [
          {
            "schema": {
              "maxLength": 200,
              "type": "string"
            },
            "in": "query",
            "name": "search",
            "required": false
          },
          {
            "schema": {
              "minimum": 1,
              "maximum": 100,
              "default": 50,
              "type": "integer"
            },
            "in": "query",
            "name": "limit",
            "required": false
          },
          {
            "schema": {
              "minimum": 0,
              "default": 0,
              "type": "integer"
            },
            "in": "query",
            "name": "offset",
            "required": false
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "items",
                    "total"
                  ],
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "id",
                          "user_id",
                          "full_url",
                          "utm_source",
                          "utm_medium",
                          "utm_campaign",
                          "utm_term",
                          "utm_content",
                          "utm_id",
                          "custom_params",
                          "meta_campaign_id",
                          "template_id",
                          "created_at"
                        ],
                        "properties": {
                          "id": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "user_id": {
                            "anyOf": [
                              {
                                "format": "uuid",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "full_url": {
                            "type": "string"
                          },
                          "utm_source": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "utm_medium": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "utm_campaign": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "utm_term": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "utm_content": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "utm_id": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "custom_params": {
                            "anyOf": [
                              {
                                "type": "object",
                                "additionalProperties": {
                                  "maxLength": 500,
                                  "type": "string"
                                }
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "meta_campaign_id": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "template_id": {
                            "anyOf": [
                              {
                                "format": "uuid",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "created_at": {
                            "format": "date-time",
                            "type": "string"
                          }
                        }
                      }
                    },
                    "total": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "postApiV1UtmLinks",
        "summary": "Salva link UTM nello storico (scope team)",
        "tags": [
          "utm"
        ],
        "description": "Stores a generated UTM URL in the current team history with optional template and Meta campaign references.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "full_url"
                ],
                "properties": {
                  "full_url": {
                    "format": "uri",
                    "minLength": 1,
                    "maxLength": 5000,
                    "type": "string"
                  },
                  "utm_source": {
                    "anyOf": [
                      {
                        "maxLength": 100,
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "utm_medium": {
                    "anyOf": [
                      {
                        "maxLength": 100,
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "utm_campaign": {
                    "anyOf": [
                      {
                        "maxLength": 200,
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "utm_term": {
                    "anyOf": [
                      {
                        "maxLength": 200,
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "utm_content": {
                    "anyOf": [
                      {
                        "maxLength": 200,
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "utm_id": {
                    "anyOf": [
                      {
                        "maxLength": 200,
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "custom_params": {
                    "anyOf": [
                      {
                        "type": "object",
                        "additionalProperties": {
                          "maxLength": 500,
                          "type": "string"
                        }
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "meta_campaign_id": {
                    "anyOf": [
                      {
                        "maxLength": 50,
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "template_id": {
                    "anyOf": [
                      {
                        "format": "uuid",
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "201": {
            "description": "Resource created",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "id",
                    "user_id",
                    "full_url",
                    "utm_source",
                    "utm_medium",
                    "utm_campaign",
                    "utm_term",
                    "utm_content",
                    "utm_id",
                    "custom_params",
                    "meta_campaign_id",
                    "template_id",
                    "created_at"
                  ],
                  "properties": {
                    "id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "user_id": {
                      "anyOf": [
                        {
                          "format": "uuid",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "full_url": {
                      "type": "string"
                    },
                    "utm_source": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "utm_medium": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "utm_campaign": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "utm_term": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "utm_content": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "utm_id": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "custom_params": {
                      "anyOf": [
                        {
                          "type": "object",
                          "additionalProperties": {
                            "maxLength": 500,
                            "type": "string"
                          }
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "meta_campaign_id": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "template_id": {
                      "anyOf": [
                        {
                          "format": "uuid",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "created_at": {
                      "format": "date-time",
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/utm/links/{id}": {
      "put": {
        "operationId": "putApiV1UtmLinksById",
        "summary": "Aggiorna link UTM nello storico",
        "tags": [
          "utm"
        ],
        "description": "Updates a saved UTM link history record that belongs to one of the team sessions accessible to the caller.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "full_url"
                ],
                "properties": {
                  "full_url": {
                    "format": "uri",
                    "minLength": 1,
                    "maxLength": 5000,
                    "type": "string"
                  },
                  "utm_source": {
                    "anyOf": [
                      {
                        "maxLength": 100,
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "utm_medium": {
                    "anyOf": [
                      {
                        "maxLength": 100,
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "utm_campaign": {
                    "anyOf": [
                      {
                        "maxLength": 200,
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "utm_term": {
                    "anyOf": [
                      {
                        "maxLength": 200,
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "utm_content": {
                    "anyOf": [
                      {
                        "maxLength": 200,
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "utm_id": {
                    "anyOf": [
                      {
                        "maxLength": 200,
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "custom_params": {
                    "anyOf": [
                      {
                        "type": "object",
                        "additionalProperties": {
                          "maxLength": 500,
                          "type": "string"
                        }
                      },
                      {
                        "type": "null"
                      }
                    ]
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "updated"
                  ],
                  "properties": {
                    "updated": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      },
      "delete": {
        "operationId": "deleteApiV1UtmLinksById",
        "summary": "Elimina link UTM dallo storico",
        "tags": [
          "utm"
        ],
        "description": "Deletes a saved UTM link history record owned by one of the team sessions accessible to the caller.",
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "deleted"
                  ],
                  "properties": {
                    "deleted": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/utm/campaigns": {
      "get": {
        "operationId": "getApiV1UtmCampaigns",
        "summary": "Lista campagne Meta disponibili per auto-fill UTM",
        "tags": [
          "utm"
        ],
        "description": "Returns recently seen Meta campaigns for accessible team sessions so the UTM builder can auto-fill campaign values.",
        "parameters": [
          {
            "schema": {
              "maxLength": 200,
              "type": "string"
            },
            "in": "query",
            "name": "search",
            "required": false
          },
          {
            "schema": {
              "minimum": 1,
              "maximum": 200,
              "default": 100,
              "type": "integer"
            },
            "in": "query",
            "name": "limit",
            "required": false
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "required": [
                      "campaign_id",
                      "campaign_name"
                    ],
                    "properties": {
                      "campaign_id": {
                        "type": "string"
                      },
                      "campaign_name": {
                        "type": "string"
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/teams/{teamId}/guardrails": {
      "get": {
        "operationId": "getTeamGuardrails",
        "summary": "Get resolved WAVO guardrails for a team",
        "tags": [
          "wavo"
        ],
        "description": "Returns the resolved WAVO guardrail configuration for a team, including global defaults, team overrides, recommended values and the source of each overrideable key.",
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "teamId",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "resolved",
                    "global",
                    "team_overrides",
                    "recommended",
                    "_source"
                  ],
                  "properties": {
                    "resolved": {
                      "type": "object",
                      "additionalProperties": {
                        "$comment": "json-value",
                        "description": "Arbitrary JSON value with nested arrays and objects."
                      }
                    },
                    "global": {
                      "type": "object",
                      "additionalProperties": {
                        "$comment": "json-value",
                        "description": "Arbitrary JSON value with nested arrays and objects."
                      }
                    },
                    "team_overrides": {
                      "type": "object",
                      "additionalProperties": {
                        "$comment": "json-value",
                        "description": "Arbitrary JSON value with nested arrays and objects."
                      }
                    },
                    "recommended": {
                      "type": "object",
                      "additionalProperties": {
                        "$comment": "json-value",
                        "description": "Arbitrary JSON value with nested arrays and objects."
                      }
                    },
                    "_source": {
                      "type": "object",
                      "additionalProperties": {
                        "anyOf": [
                          {
                            "type": "string",
                            "enum": [
                              "team"
                            ]
                          },
                          {
                            "type": "string",
                            "enum": [
                              "default"
                            ]
                          }
                        ]
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      },
      "patch": {
        "operationId": "updateTeamGuardrails",
        "summary": "Update WAVO guardrails for a team (owner)",
        "tags": [
          "wavo"
        ],
        "description": "Upserts the allowed per-team WAVO guardrail overrides, validates each value fail-closed and returns the resolved overrideable guardrails after the change.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "properties": {
                  "autonomy_budget_delta_pct_max": {
                    "type": "number"
                  },
                  "autonomy_delta_increase_only": {
                    "type": "boolean"
                  },
                  "autonomy_per_action_cap_eur": {
                    "anyOf": [
                      {
                        "type": "null"
                      },
                      {
                        "type": "integer"
                      }
                    ]
                  },
                  "autonomy_daily_spend_cap_eur": {
                    "anyOf": [
                      {
                        "type": "null"
                      },
                      {
                        "type": "integer"
                      }
                    ]
                  },
                  "autonomy_max_actions_per_day": {
                    "anyOf": [
                      {
                        "type": "null"
                      },
                      {
                        "type": "integer"
                      }
                    ]
                  },
                  "approval_enforcement_enabled": {
                    "type": "boolean"
                  },
                  "approval_min_role": {
                    "maxLength": 20,
                    "type": "string"
                  },
                  "approval_high_impact_min_role": {
                    "maxLength": 20,
                    "type": "string"
                  },
                  "approval_request_ttl_minutes": {
                    "type": "integer"
                  },
                  "approval_always_for_actions": {
                    "type": "array",
                    "items": {
                      "maxLength": 40,
                      "type": "string"
                    }
                  },
                  "scope_allowed_platforms": {
                    "type": "array",
                    "items": {
                      "maxLength": 40,
                      "type": "string"
                    }
                  },
                  "scope_allowed_ad_accounts": {
                    "type": "array",
                    "items": {
                      "maxLength": 100,
                      "type": "string"
                    }
                  },
                  "scope_protected_entity_ids": {
                    "type": "array",
                    "items": {
                      "additionalProperties": false,
                      "type": "object",
                      "required": [
                        "entity_type",
                        "entity_id"
                      ],
                      "properties": {
                        "entity_type": {
                          "maxLength": 20,
                          "type": "string"
                        },
                        "entity_id": {
                          "maxLength": 100,
                          "type": "string"
                        },
                        "platform": {
                          "maxLength": 40,
                          "type": "string"
                        }
                      }
                    }
                  },
                  "scope_time_windows": {
                    "type": "array",
                    "items": {
                      "additionalProperties": false,
                      "type": "object",
                      "required": [
                        "start",
                        "end"
                      ],
                      "properties": {
                        "days": {
                          "type": "array",
                          "items": {
                            "minimum": 1,
                            "maximum": 7,
                            "type": "integer"
                          }
                        },
                        "start": {
                          "maxLength": 5,
                          "type": "string"
                        },
                        "end": {
                          "maxLength": 5,
                          "type": "string"
                        },
                        "tz": {
                          "maxLength": 60,
                          "type": "string"
                        }
                      }
                    }
                  },
                  "action_pause_enabled": {
                    "type": "boolean"
                  },
                  "action_activate_enabled": {
                    "maxLength": 10,
                    "type": "string"
                  },
                  "action_update_budget_enabled": {
                    "type": "boolean"
                  },
                  "action_launch_enabled": {
                    "maxLength": 10,
                    "type": "string"
                  },
                  "action_creative_enabled": {
                    "type": "boolean"
                  },
                  "action_automation_rule_enabled": {
                    "maxLength": 10,
                    "type": "string"
                  },
                  "launch_paused_by_default": {
                    "type": "boolean"
                  },
                  "autonomy_kill_switch": {
                    "type": "boolean"
                  },
                  "autonomy_paused_until": {
                    "anyOf": [
                      {
                        "type": "null"
                      },
                      {
                        "maxLength": 40,
                        "type": "string"
                      }
                    ]
                  },
                  "kill_switch_scope": {
                    "maxLength": 20,
                    "type": "string"
                  },
                  "undo_enabled": {
                    "type": "boolean"
                  },
                  "undo_window_minutes": {
                    "type": "integer"
                  },
                  "action_log_visible": {
                    "type": "boolean"
                  },
                  "notify_on_action": {
                    "type": "boolean"
                  },
                  "notify_min_risk": {
                    "maxLength": 10,
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "teamId",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "updated",
                    "resolved"
                  ],
                  "properties": {
                    "updated": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "resolved": {
                      "type": "object",
                      "additionalProperties": {
                        "$comment": "json-value",
                        "description": "Arbitrary JSON value with nested arrays and objects."
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "422": {
            "description": "Unprocessable entity - semantic validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      },
      "delete": {
        "operationId": "resetTeamGuardrails",
        "summary": "Reset WAVO guardrails for a team to the global defaults (owner)",
        "tags": [
          "wavo"
        ],
        "description": "Deletes the per-team overrides in wavo_team_guardrail so the team re-inherits the global WAVO config. Optional body { keys } limits the reset to specific override keys.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "anyOf": [
                  {
                    "type": "null"
                  },
                  {
                    "additionalProperties": false,
                    "type": "object",
                    "properties": {
                      "keys": {
                        "type": "array",
                        "items": {
                          "maxLength": 40,
                          "type": "string"
                        }
                      }
                    }
                  }
                ]
              }
            }
          }
        },
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "teamId",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "reset",
                    "resolved"
                  ],
                  "properties": {
                    "reset": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "resolved": {
                      "type": "object",
                      "additionalProperties": {
                        "$comment": "json-value",
                        "description": "Arbitrary JSON value with nested arrays and objects."
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "422": {
            "description": "Unprocessable entity - semantic validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/ai-action-log/{id}/rollback": {
      "post": {
        "operationId": "rollbackAiAction",
        "summary": "Undo the last reversible WAVO action (toggle/budget) within the undo window",
        "tags": [
          "wavo"
        ],
        "description": "Applies the reverse operation for a successful reversible AI action when the caller still has team access and the configured undo window has not expired. Refused with 423 while WAVO autonomy is stopped (kill-switch down or paused): the undo is a platform write of the same size as the action it reverses.",
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "ok",
                    "applied",
                    "prev_state",
                    "tool_name"
                  ],
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    },
                    "applied": {
                      "type": "boolean"
                    },
                    "prev_state": {
                      "$comment": "json-value",
                      "description": "Arbitrary JSON value with nested arrays and objects."
                    },
                    "tool_name": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "Conflict - resource state prevents the operation",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "423": {
            "description": "Response 423",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error",
                    "code"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "502": {
            "description": "Bad gateway - upstream provider failed",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/web-push/subscribe": {
      "post": {
        "operationId": "registerWebPushSubscription",
        "summary": "Register a Web Push subscription",
        "tags": [
          "web-push"
        ],
        "description": "Stores the browser-provided PushSubscription for the authenticated session so the backend can deliver Web Push notifications. Idempotent on (user, endpoint).",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "endpoint",
                  "keys"
                ],
                "properties": {
                  "endpoint": {
                    "description": "Push service endpoint URL returned by the browser PushSubscription.",
                    "type": "string"
                  },
                  "keys": {
                    "additionalProperties": false,
                    "type": "object",
                    "required": [
                      "p256dh",
                      "auth"
                    ],
                    "properties": {
                      "p256dh": {
                        "description": "Base64URL-encoded P-256 ECDH public key.",
                        "type": "string"
                      },
                      "auth": {
                        "description": "Base64URL-encoded auth secret generated by the user agent.",
                        "type": "string"
                      }
                    }
                  },
                  "user_agent": {
                    "description": "User-Agent string captured at subscription time.",
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "201": {
            "description": "Resource created",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "ok"
                  ],
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      },
      "delete": {
        "operationId": "removeWebPushSubscription",
        "summary": "Remove a Web Push subscription",
        "tags": [
          "web-push"
        ],
        "description": "Deletes the stored subscription for the given endpoint. Idempotent: returns 200 even if the subscription was already removed.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "endpoint"
                ],
                "properties": {
                  "endpoint": {
                    "description": "Push service endpoint URL to unregister.",
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "ok"
                  ],
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/woocommerce/compliance": {
      "post": {
        "operationId": "postApiV1WoocommerceCompliance",
        "summary": "Receive WooCommerce compliance request",
        "tags": [
          "woocommerce"
        ],
        "description": "Accepts WooCommerce GDPR compliance actions, soft-deletes local integration data for delete_data, and queues cascade cleanup where applicable.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "action"
                ],
                "properties": {
                  "store_domain": {
                    "minLength": 1,
                    "type": "string"
                  },
                  "action": {
                    "anyOf": [
                      {
                        "type": "string",
                        "enum": [
                          "delete_data"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "export_data"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "redact_customer"
                        ]
                      }
                    ]
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "status"
                  ],
                  "properties": {
                    "status": {
                      "type": "string",
                      "enum": [
                        "accepted"
                      ]
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/woocommerce/webhooks": {
      "post": {
        "operationId": "postApiV1WoocommerceWebhooks",
        "summary": "Receive WooCommerce webhook",
        "tags": [
          "woocommerce"
        ],
        "description": "Verifies WooCommerce webhook signatures, resolves the store, deduplicates deliveries, and queues processing.",
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "status"
                  ],
                  "properties": {
                    "status": {
                      "anyOf": [
                        {
                          "type": "string",
                          "enum": [
                            "accepted"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "duplicate"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "feature_disabled"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "ignored"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "requeued"
                          ]
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "Conflict - resource state prevents the operation",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "Service unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ]
      }
    },
    "/api/v1/woocommerce/install": {
      "post": {
        "operationId": "postApiV1WoocommerceInstall",
        "summary": "Start WooCommerce install",
        "tags": [
          "woocommerce"
        ],
        "description": "Creates a WooCommerce authorization URL for the active team and requested site URL.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "site_url"
                ],
                "properties": {
                  "site_url": {
                    "minLength": 1,
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "install_url"
                  ],
                  "properties": {
                    "install_url": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/woocommerce/callback": {
      "post": {
        "operationId": "postApiV1WoocommerceCallback",
        "summary": "Complete WooCommerce callback",
        "tags": [
          "woocommerce"
        ],
        "description": "Receives the WooCommerce authorization callback payload and stores the resulting API credentials.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": true,
                "type": "object",
                "required": [
                  "consumer_key",
                  "consumer_secret",
                  "user_id"
                ],
                "properties": {
                  "consumer_key": {
                    "type": "string"
                  },
                  "consumer_secret": {
                    "type": "string"
                  },
                  "key_permissions": {
                    "type": "string"
                  },
                  "user_id": {
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "success"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/woocommerce/connect": {
      "post": {
        "operationId": "postApiV1WoocommerceConnect",
        "summary": "Connect WooCommerce manually",
        "tags": [
          "woocommerce"
        ],
        "description": "Stores manually supplied WooCommerce API credentials and returns the resulting connection configuration.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "consumer_key",
                  "consumer_secret",
                  "site_url"
                ],
                "properties": {
                  "cogs_meta_keys": {
                    "maxItems": 20,
                    "type": "array",
                    "items": {
                      "minLength": 1,
                      "type": "string"
                    }
                  },
                  "consumer_key": {
                    "minLength": 1,
                    "type": "string"
                  },
                  "consumer_secret": {
                    "minLength": 1,
                    "type": "string"
                  },
                  "polling_interval_minutes": {
                    "minimum": 5,
                    "maximum": 1440,
                    "type": "integer"
                  },
                  "site_url": {
                    "minLength": 1,
                    "type": "string"
                  },
                  "utm_meta_mapping": {
                    "type": "object",
                    "additionalProperties": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "catalog_source_id",
                    "connected_at",
                    "feature_available",
                    "id",
                    "install_status",
                    "key_permissions",
                    "last_order_synced_at",
                    "last_product_synced_at",
                    "polling_interval_minutes",
                    "site_url",
                    "store_domain",
                    "store_name",
                    "token_status",
                    "wc_version",
                    "wp_version"
                  ],
                  "properties": {
                    "catalog_source_id": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "connected_at": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "feature_available": {
                      "type": "boolean"
                    },
                    "id": {
                      "type": "string"
                    },
                    "install_status": {
                      "type": "string"
                    },
                    "key_permissions": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "last_order_synced_at": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "last_product_synced_at": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "polling_interval_minutes": {
                      "type": "number"
                    },
                    "site_url": {
                      "type": "string"
                    },
                    "store_domain": {
                      "type": "string"
                    },
                    "store_name": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "token_status": {
                      "type": "string"
                    },
                    "wc_version": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "wp_version": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/woocommerce/config": {
      "get": {
        "operationId": "getApiV1WoocommerceConfig",
        "summary": "Get WooCommerce configuration",
        "tags": [
          "woocommerce"
        ],
        "description": "Returns WooCommerce connection status, sync timestamps, polling interval, and version metadata for the active team.",
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "anyOf": [
                    {
                      "type": "object",
                      "required": [
                        "catalog_source_id",
                        "connected_at",
                        "feature_available",
                        "id",
                        "install_status",
                        "key_permissions",
                        "last_order_synced_at",
                        "last_product_synced_at",
                        "polling_interval_minutes",
                        "site_url",
                        "store_domain",
                        "store_name",
                        "token_status",
                        "wc_version",
                        "wp_version"
                      ],
                      "properties": {
                        "catalog_source_id": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "connected_at": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "feature_available": {
                          "type": "boolean"
                        },
                        "id": {
                          "type": "string"
                        },
                        "install_status": {
                          "type": "string"
                        },
                        "key_permissions": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "last_order_synced_at": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "last_product_synced_at": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "polling_interval_minutes": {
                          "type": "number"
                        },
                        "site_url": {
                          "type": "string"
                        },
                        "store_domain": {
                          "type": "string"
                        },
                        "store_name": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "token_status": {
                          "type": "string"
                        },
                        "wc_version": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "wp_version": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        }
                      }
                    },
                    {
                      "type": "null"
                    }
                  ]
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/woocommerce/sync": {
      "post": {
        "operationId": "postApiV1WoocommerceSync",
        "summary": "Queue WooCommerce sync",
        "tags": [
          "woocommerce"
        ],
        "description": "Queues a WooCommerce product or order sync job for the connected store.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "properties": {
                  "after": {
                    "format": "date-time",
                    "type": "string"
                  },
                  "sync_type": {
                    "anyOf": [
                      {
                        "type": "string",
                        "enum": [
                          "initial"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "orders"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "products"
                        ]
                      }
                    ]
                  }
                }
              }
            }
          }
        },
        "responses": {
          "202": {
            "description": "Accepted - processing asynchronously",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "status"
                  ],
                  "properties": {
                    "status": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/woocommerce/disconnect": {
      "post": {
        "operationId": "postApiV1WoocommerceDisconnect",
        "summary": "Disconnect WooCommerce store",
        "tags": [
          "woocommerce"
        ],
        "description": "Disconnects the WooCommerce store for the active team, optionally deleting imported product data.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "properties": {
                  "delete_imported_products": {
                    "type": "boolean"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "success"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/worker-runs/{id}/status": {
      "get": {
        "operationId": "getWorkerRunStatus",
        "summary": "Get worker run status",
        "tags": [
          "jobs"
        ],
        "description": "Returns the current status and progress counters of a worker run.",
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "status",
                    "total_tasks",
                    "completed_tasks",
                    "failed_tasks"
                  ],
                  "properties": {
                    "status": {
                      "description": "Lifecycle state of a worker_run.",
                      "anyOf": [
                        {
                          "type": "string",
                          "enum": [
                            "RUNNING"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "COMPLETED"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "FAILED"
                          ]
                        }
                      ]
                    },
                    "total_tasks": {
                      "type": "integer"
                    },
                    "completed_tasks": {
                      "type": "integer"
                    },
                    "failed_tasks": {
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/workspace/resolve": {
      "get": {
        "operationId": "getApiV1WorkspaceResolve",
        "summary": "Resolve workspace preferences",
        "tags": [
          "workspace"
        ],
        "description": "Return the workspace preferences payload (team preset, user overrides, scope, permissions, runtime flags) for the authenticated user. The frontend composes this with its local registry to build the resolved workspace.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "onboarding_call",
                    "permissions_context",
                    "runtime_flags",
                    "scope_context",
                    "team_preset",
                    "team_profile",
                    "telemetry_context",
                    "user_overrides"
                  ],
                  "properties": {
                    "onboarding_call": {
                      "type": "object",
                      "required": [
                        "enabled",
                        "booking_url",
                        "window_days",
                        "snooze_days",
                        "targeting"
                      ],
                      "properties": {
                        "enabled": {
                          "type": "boolean"
                        },
                        "booking_url": {
                          "type": "string"
                        },
                        "window_days": {
                          "type": "integer"
                        },
                        "snooze_days": {
                          "type": "integer"
                        },
                        "targeting": {
                          "anyOf": [
                            {
                              "type": "string",
                              "enum": [
                                "new_users"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "all"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "no_integration"
                              ]
                            }
                          ]
                        }
                      }
                    },
                    "permissions_context": {
                      "type": "object",
                      "required": [
                        "role"
                      ],
                      "properties": {
                        "role": {
                          "anyOf": [
                            {
                              "type": "string",
                              "enum": [
                                "super_admin"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "admin"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "owner"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "manager"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "mediabuyer"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "finance"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "viewer"
                              ]
                            }
                          ]
                        }
                      }
                    },
                    "runtime_flags": {
                      "type": "object",
                      "additionalProperties": {
                        "type": "boolean"
                      }
                    },
                    "scope_context": {
                      "type": "object",
                      "required": [
                        "availability",
                        "id",
                        "label",
                        "type"
                      ],
                      "properties": {
                        "availability": {
                          "anyOf": [
                            {
                              "type": "string",
                              "enum": [
                                "resolved"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "defaulted"
                              ]
                            }
                          ]
                        },
                        "id": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "label": {
                          "type": "string"
                        },
                        "type": {
                          "type": "string",
                          "enum": [
                            "team"
                          ]
                        }
                      }
                    },
                    "team_preset": {
                      "type": "object",
                      "required": [
                        "enabled_module_ids",
                        "hub_order",
                        "locked_module_ids",
                        "pinned_module_ids",
                        "policy"
                      ],
                      "properties": {
                        "enabled_module_ids": {
                          "type": "array",
                          "items": {
                            "type": "string"
                          }
                        },
                        "hub_order": {
                          "type": "array",
                          "items": {
                            "type": "string"
                          }
                        },
                        "locked_module_ids": {
                          "type": "array",
                          "items": {
                            "type": "string"
                          }
                        },
                        "pinned_module_ids": {
                          "type": "array",
                          "items": {
                            "type": "string"
                          }
                        },
                        "policy": {
                          "type": "object",
                          "required": [
                            "allow_user_hide",
                            "allow_user_pin",
                            "allow_user_reorder",
                            "allow_user_templates"
                          ],
                          "properties": {
                            "allow_user_hide": {
                              "type": "boolean"
                            },
                            "allow_user_pin": {
                              "type": "boolean"
                            },
                            "allow_user_reorder": {
                              "type": "boolean"
                            },
                            "allow_user_templates": {
                              "type": "boolean"
                            }
                          }
                        },
                        "default_conversion_source": {
                          "type": "string"
                        }
                      }
                    },
                    "team_profile": {
                      "anyOf": [
                        {
                          "type": "string",
                          "enum": [
                            "affiliate"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "brand"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "agency"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "enterprise"
                          ]
                        }
                      ]
                    },
                    "telemetry_context": {
                      "type": "object",
                      "required": [
                        "preset_id",
                        "resolver_version"
                      ],
                      "properties": {
                        "preset_id": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "resolver_version": {
                          "type": "string"
                        }
                      }
                    },
                    "user_overrides": {
                      "anyOf": [
                        {
                          "type": "object",
                          "required": [
                            "hidden_module_ids",
                            "pinned_module_ids",
                            "reordered_module_ids"
                          ],
                          "properties": {
                            "hidden_module_ids": {
                              "type": "array",
                              "items": {
                                "type": "string"
                              }
                            },
                            "pinned_module_ids": {
                              "type": "array",
                              "items": {
                                "type": "string"
                              }
                            },
                            "reordered_hub_ids": {
                              "type": "array",
                              "items": {
                                "type": "string"
                              }
                            },
                            "reordered_module_ids": {
                              "type": "array",
                              "items": {
                                "type": "string"
                              }
                            },
                            "selected_template_id": {
                              "anyOf": [
                                {
                                  "type": "string"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            }
                          }
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ],
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/bulk-launch": {
      "post": {
        "operationId": "directBulkLaunch",
        "summary": "Launch a campaign directly from the frontend",
        "tags": [
          "bulk-launch"
        ],
        "description": "Accepts a full campaign payload built by the frontend campaign creator and dispatches the launch as an asynchronous job processed by the bulk-launch SQS workers, stamped with the ACTIVE workspace team (`x-team-id` / team scope required — 400 `SCOPE_TEAM_REQUIRED` otherwise). Every referenced resource (ad account, fan page, pixel) must belong to the active workspace or the dispatch is rejected with 403 `RESOURCE_NOT_IN_ACTIVE_WORKSPACE`. Returns the worker_run_id that must be used to poll for progress via /api/v1/bulk-launch/status/:workerRunId.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "ad_type",
                  "account_id",
                  "fan_page_id",
                  "pixel_id",
                  "campaign_name",
                  "budget_optimization",
                  "daily_budget",
                  "adset_names",
                  "bid_amounts",
                  "target_country",
                  "dsa_beneficiary",
                  "dsa_payor",
                  "min_age",
                  "max_age",
                  "gender",
                  "start_date",
                  "start_time",
                  "devices",
                  "operating_systems",
                  "optimization_goal",
                  "billing_event",
                  "custom_event_type",
                  "ad_names",
                  "main_video_urls",
                  "main_image_urls",
                  "main_url",
                  "url_parameters",
                  "main_message",
                  "main_title",
                  "main_description",
                  "call_to_action",
                  "target_language"
                ],
                "properties": {
                  "ad_type": {
                    "description": "Ad type: Standard, Multilanguage, Catalog, App Install",
                    "type": "string"
                  },
                  "account_id": {
                    "description": "Meta Ad Account ID",
                    "type": "string"
                  },
                  "fan_page_id": {
                    "description": "Meta Fan Page ID",
                    "type": "string"
                  },
                  "pixel_id": {
                    "description": "Meta Pixel ID",
                    "type": "string"
                  },
                  "campaign_name": {
                    "description": "Campaign name",
                    "type": "string"
                  },
                  "budget_optimization": {
                    "description": "Budget optimization type (CBO, BID CAP, COST CAP, MIN ROAS, ABO)",
                    "type": "string"
                  },
                  "daily_budget": {
                    "minimum": 1,
                    "description": "Daily budget in cents (must be > 0 for CBO and ABO)",
                    "type": "number"
                  },
                  "adset_names": {
                    "description": "Ad Set names",
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  },
                  "bid_amounts": {
                    "description": "Bid amounts per ad set",
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  },
                  "target_cities": {
                    "description": "Target cities with radius for geo targeting",
                    "type": "array",
                    "items": {
                      "additionalProperties": false,
                      "type": "object",
                      "required": [
                        "key",
                        "radius",
                        "distance_unit"
                      ],
                      "properties": {
                        "key": {
                          "type": "string"
                        },
                        "radius": {
                          "minimum": 10,
                          "maximum": 80,
                          "type": "number"
                        },
                        "distance_unit": {
                          "type": "string"
                        }
                      }
                    }
                  },
                  "target_country": {
                    "description": "Target country code (e.g. IT)",
                    "type": "string"
                  },
                  "target_countries": {
                    "description": "Target country codes for multi-country targeting",
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  },
                  "target_regions": {
                    "description": "Target regions for geo targeting",
                    "type": "array",
                    "items": {
                      "additionalProperties": false,
                      "type": "object",
                      "required": [
                        "key"
                      ],
                      "properties": {
                        "key": {
                          "type": "string"
                        }
                      }
                    }
                  },
                  "dsa_beneficiary": {
                    "description": "DSA beneficiary",
                    "type": "string"
                  },
                  "dsa_payor": {
                    "description": "DSA payor",
                    "type": "string"
                  },
                  "min_age": {
                    "minimum": 13,
                    "maximum": 65,
                    "description": "Minimum age targeting",
                    "type": "number"
                  },
                  "max_age": {
                    "minimum": 13,
                    "maximum": 65,
                    "description": "Maximum age targeting",
                    "type": "number"
                  },
                  "gender": {
                    "description": "Gender targeting: All, Male, Female",
                    "type": "string"
                  },
                  "start_date": {
                    "description": "Campaign start date",
                    "type": "string"
                  },
                  "start_time": {
                    "description": "Campaign start time",
                    "type": "string"
                  },
                  "devices": {
                    "description": "Device targeting: all, mobile, desktop",
                    "type": "string"
                  },
                  "operating_systems": {
                    "description": "OS targeting: all, android, ios",
                    "type": "string"
                  },
                  "optimization_goal": {
                    "description": "Ad Set optimization goal",
                    "anyOf": [
                      {
                        "type": "string",
                        "enum": [
                          "REACH"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "IMPRESSIONS"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "AD_RECALL_LIFT"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "LINK_CLICKS"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "LANDING_PAGE_VIEWS"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "POST_ENGAGEMENT"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "PAGE_LIKES"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "EVENT_RESPONSES"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "LEAD_GENERATION"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "APP_INSTALLS"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "OFFSITE_CONVERSIONS"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "CONVERSIONS"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "VALUE"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "QUALITY_LEAD"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "QUALITY_CALL"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "THRUPLAY"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "REMINDERS_SET"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "CONVERSATIONS"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "VISIT_INSTAGRAM_PROFILE"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "PROFILE_VISIT"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "TWO_SECOND_CONTINUOUS_VIDEO_VIEWS"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "MESSAGING_PURCHASE_CONVERSION"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "MESSAGING_APPOINTMENT_CONVERSION"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "APP_INSTALLS_AND_OFFSITE_CONVERSIONS"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "DERIVED_EVENTS"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "SUBSCRIBERS"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "IN_APP_VALUE"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "ENGAGED_USERS"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "MEANINGFUL_CALL_ATTEMPT"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "ENGAGED_PAGE_VIEWS"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "PROFILE_AND_PAGE_ENGAGEMENT"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "ADVERTISER_SILOED_VALUE"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "MESSAGING_DEEP_CONVERSATION_AND_FOLLOW"
                        ]
                      }
                    ]
                  },
                  "billing_event": {
                    "description": "Billing event",
                    "anyOf": [
                      {
                        "type": "string",
                        "enum": [
                          "IMPRESSIONS"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "LINK_CLICKS"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "THRUPLAY"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "APP_INSTALLS"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "CLICKS"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "PAGE_LIKES"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "POST_ENGAGEMENT"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "PURCHASE"
                        ]
                      }
                    ]
                  },
                  "custom_event_type": {
                    "description": "Custom event type",
                    "type": "string"
                  },
                  "ad_names": {
                    "description": "Ad names",
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  },
                  "main_video_urls": {
                    "description": "Main video URLs",
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  },
                  "main_image_urls": {
                    "description": "Main image URLs",
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  },
                  "main_url": {
                    "description": "Landing page URL",
                    "pattern": "^$|^https?:\\/\\/.+\\..+",
                    "type": "string"
                  },
                  "url_parameters": {
                    "description": "URL parameters",
                    "type": "string"
                  },
                  "main_message": {
                    "description": "Ad primary text",
                    "type": "string"
                  },
                  "main_title": {
                    "description": "Ad headline",
                    "type": "string"
                  },
                  "main_description": {
                    "description": "Ad description",
                    "type": "string"
                  },
                  "main_messages": {
                    "description": "Meta dynamic creative primary text variations",
                    "maxItems": 5,
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  },
                  "main_titles": {
                    "description": "Meta dynamic creative headline variations",
                    "maxItems": 5,
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  },
                  "main_descriptions": {
                    "description": "Meta dynamic creative description variations",
                    "maxItems": 5,
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  },
                  "call_to_action": {
                    "enum": [
                      "",
                      "LEARN_MORE",
                      "SHOP_NOW",
                      "SIGN_UP",
                      "BOOK_NOW",
                      "DOWNLOAD",
                      "CONTACT_US",
                      "SUBSCRIBE",
                      "APPLY_NOW",
                      "GET_OFFER",
                      "SEND_MESSAGE",
                      "WATCH_MORE",
                      "GET_QUOTE",
                      "INSTALL_APP",
                      "NO_BUTTON",
                      "SHOP_WITH_AI",
                      "TRY_ON_WITH_AI",
                      "CHAT_NOW",
                      "MAKE_AN_APPOINTMENT",
                      "ORDER_NOW",
                      "VISIT_PROFILE",
                      "INSTALL_MOBILE_APP",
                      "USE_APP",
                      "LISTEN_NOW",
                      "SEE_MENU"
                    ],
                    "description": "Call to action type. One of: LEARN_MORE, SHOP_NOW, SIGN_UP, BOOK_NOW, DOWNLOAD, CONTACT_US, SUBSCRIBE, APPLY_NOW, GET_OFFER, SEND_MESSAGE, WATCH_MORE, GET_QUOTE, INSTALL_APP, NO_BUTTON, SHOP_WITH_AI, TRY_ON_WITH_AI, CHAT_NOW, MAKE_AN_APPOINTMENT, ORDER_NOW, VISIT_PROFILE, INSTALL_MOBILE_APP, USE_APP, LISTEN_NOW, SEE_MENU. Empty string means \"worker default\".",
                    "type": "string"
                  },
                  "target_language": {
                    "description": "Target language for multilanguage ads",
                    "type": "string"
                  },
                  "unmatched_audience_video": {
                    "description": "Multilanguage: which creative audiences with no matching configured language see (is_default rule). Defaults to \"safe\".",
                    "anyOf": [
                      {
                        "type": "string",
                        "enum": [
                          "safe"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "targeted"
                        ]
                      }
                    ]
                  },
                  "extra_video_urls": {
                    "description": "Extra video URLs for multilanguage",
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  },
                  "extra_image_urls": {
                    "description": "Extra image URLs for multilanguage",
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  },
                  "extra_link": {
                    "description": "Extra link for multilanguage",
                    "type": "string"
                  },
                  "extra_message": {
                    "description": "Extra message for multilanguage",
                    "type": "string"
                  },
                  "extra_title": {
                    "description": "Extra title for multilanguage",
                    "type": "string"
                  },
                  "extra_description": {
                    "description": "Extra description for multilanguage",
                    "type": "string"
                  },
                  "extra_languages": {
                    "description": "Extra languages for multilanguage ads (new format)",
                    "type": "array",
                    "items": {
                      "additionalProperties": false,
                      "type": "object",
                      "required": [
                        "target_language",
                        "video_url",
                        "image_url",
                        "link",
                        "message",
                        "title",
                        "description"
                      ],
                      "properties": {
                        "target_language": {
                          "type": "string"
                        },
                        "video_url": {
                          "type": "string"
                        },
                        "image_url": {
                          "type": "string"
                        },
                        "link": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "title": {
                          "type": "string"
                        },
                        "description": {
                          "type": "string"
                        }
                      }
                    }
                  },
                  "campaign_objective": {
                    "description": "Campaign objective: OUTCOME_SALES, OUTCOME_LEADS, OUTCOME_TRAFFIC, etc.",
                    "anyOf": [
                      {
                        "type": "string",
                        "enum": [
                          "OUTCOME_AWARENESS"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "OUTCOME_TRAFFIC"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "OUTCOME_ENGAGEMENT"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "OUTCOME_LEADS"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "OUTCOME_APP_PROMOTION"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "OUTCOME_SALES"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "GOOGLE_SEARCH"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "GOOGLE_DISPLAY"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "GOOGLE_VIDEO"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "GOOGLE_SHOPPING"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "GOOGLE_PERFORMANCE_MAX"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "GOOGLE_DEMAND_GEN"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "GOOGLE_APP"
                        ]
                      }
                    ]
                  },
                  "budget_level": {
                    "description": "Budget level: CBO or ABO",
                    "type": "string"
                  },
                  "bid_strategy": {
                    "description": "Bid strategy: LOWEST_COST, BID_CAP, COST_CAP, MIN_ROAS",
                    "type": "string"
                  },
                  "roas_floor": {
                    "description": "ROAS minimum floor (for MIN_ROAS strategy)",
                    "type": "string"
                  },
                  "accelerated_delivery": {
                    "description": "Meta accelerated delivery (pacing_type [\"no_pacing\"] on ad sets). Applied only under ABO where the effective bid strategy is BID_CAP; ignored otherwise.",
                    "type": "boolean"
                  },
                  "end_date": {
                    "description": "Campaign end date",
                    "type": "string"
                  },
                  "publisher_platforms": {
                    "description": "Manual publisher platforms: facebook, instagram, audience_network, messenger, threads.",
                    "type": "array",
                    "items": {
                      "enum": [
                        "facebook",
                        "instagram",
                        "audience_network",
                        "messenger",
                        "threads"
                      ],
                      "type": "string"
                    }
                  },
                  "facebook_positions": {
                    "description": "Facebook positions: feed, right_hand_column, marketplace, story, search, instream_video, facebook_reels, facebook_reels_overlay, profile_feed, notification. Rejected (retired by Meta): instant_article, video_feeds.",
                    "type": "array",
                    "items": {
                      "enum": [
                        "feed",
                        "right_hand_column",
                        "marketplace",
                        "story",
                        "search",
                        "instream_video",
                        "facebook_reels",
                        "facebook_reels_overlay",
                        "profile_feed",
                        "notification"
                      ],
                      "type": "string"
                    }
                  },
                  "instagram_positions": {
                    "description": "Instagram positions: stream, story, explore, explore_home, reels, profile_feed, ig_search, profile_reels. Rejected (retired by Meta): shop. Removed by Meta on 2026-10-27, still accepted today: explore, explore_home.",
                    "type": "array",
                    "items": {
                      "enum": [
                        "stream",
                        "story",
                        "explore",
                        "explore_home",
                        "reels",
                        "profile_feed",
                        "ig_search",
                        "profile_reels"
                      ],
                      "type": "string"
                    }
                  },
                  "audience_network_positions": {
                    "description": "Audience Network positions: classic, rewarded_video.",
                    "type": "array",
                    "items": {
                      "enum": [
                        "classic",
                        "rewarded_video"
                      ],
                      "type": "string"
                    }
                  },
                  "messenger_positions": {
                    "description": "Messenger positions: story. Rejected (retired by Meta): messenger_home, sponsored_messages. Removed by Meta on 2026-10-27, still accepted today: story.",
                    "type": "array",
                    "items": {
                      "enum": [
                        "story"
                      ],
                      "type": "string"
                    }
                  },
                  "threads_positions": {
                    "description": "Threads positions: threads_stream.",
                    "type": "array",
                    "items": {
                      "enum": [
                        "threads_stream"
                      ],
                      "type": "string"
                    }
                  },
                  "catalog_id": {
                    "description": "Catalog ID for catalog ads",
                    "type": "string"
                  },
                  "product_set_id": {
                    "description": "Product Set ID for catalog ads",
                    "type": "string"
                  },
                  "app_id": {
                    "description": "App ID for app install ads",
                    "type": "string"
                  },
                  "app_store_url": {
                    "description": "App store URL for app install ads",
                    "type": "string"
                  },
                  "deep_link_url": {
                    "description": "Deep link URL for app install ads",
                    "type": "string"
                  },
                  "initial_status": {
                    "description": "Initial status for campaign, ad sets, and ads. Defaults to ACTIVE.",
                    "anyOf": [
                      {
                        "type": "string",
                        "enum": [
                          "ACTIVE"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "PAUSED"
                        ]
                      }
                    ]
                  },
                  "use_existing_post": {
                    "description": "Use existing post as ad creative",
                    "type": "boolean"
                  },
                  "object_story_id": {
                    "description": "Object story ID (post ID) for existing post ads",
                    "type": "string"
                  },
                  "included_audiences": {
                    "description": "Custom audience IDs to include",
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  },
                  "excluded_audiences": {
                    "description": "Custom audience IDs to exclude",
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "header",
            "name": "x-team-id",
            "required": false,
            "description": "Explicit team (workspace) scope: a team.id the caller belongs to."
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "header",
            "name": "x-active-scope",
            "required": false,
            "description": "Active scope selector in `<scopeType>:<uuid>` form, e.g. `organization:<organization_id>` or `team:<team_id>`. Omit the header for the all-workspaces view."
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "message"
                  ],
                  "properties": {
                    "message": {
                      "type": "string"
                    },
                    "worker_run_id": {
                      "format": "uuid",
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "description": "Machine-readable code, e.g. SCOPE_TEAM_REQUIRED",
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "402": {
            "description": "Response 402",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message",
                    "code",
                    "requested",
                    "max"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "requested": {
                      "type": "number"
                    },
                    "max": {
                      "anyOf": [
                        {
                          "type": "number"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "description": "Machine-readable code, e.g. RESOURCE_NOT_IN_ACTIVE_WORKSPACE",
                      "type": "string"
                    },
                    "resource_type": {
                      "description": "Offending resource: ad_account, fan_page, pixel, meta_token",
                      "type": "string"
                    },
                    "resource_id": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "423": {
            "description": "Response 423",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number",
                      "enum": [
                        423
                      ]
                    },
                    "error": {
                      "type": "string",
                      "enum": [
                        "Locked"
                      ]
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/bulk-launch/status/{workerRunId}": {
      "get": {
        "operationId": "getBulkLaunchStatus",
        "summary": "Get worker run status for a launched campaign",
        "tags": [
          "bulk-launch"
        ],
        "description": "Returns the current status, task counts, and event log for a specific worker run. Reconciles the row: heals to COMPLETED when all steps have actually finished, and marks FAILED only when a RUNNING run has shown no progress for 15 minutes.",
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "workerRunId",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "status",
                    "total_tasks",
                    "completed_tasks",
                    "failed_tasks",
                    "events",
                    "created"
                  ],
                  "properties": {
                    "status": {
                      "type": "string"
                    },
                    "total_tasks": {
                      "type": "number"
                    },
                    "completed_tasks": {
                      "type": "number"
                    },
                    "failed_tasks": {
                      "type": "number"
                    },
                    "events": {
                      "type": "array",
                      "items": {
                        "additionalProperties": false,
                        "type": "object",
                        "required": [
                          "status",
                          "error_message",
                          "created_at"
                        ],
                        "properties": {
                          "status": {
                            "type": "string"
                          },
                          "error_message": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "created_at": {
                            "format": "date-time",
                            "type": "string"
                          }
                        }
                      }
                    },
                    "created": {
                      "additionalProperties": false,
                      "type": "object",
                      "required": [
                        "campaign_id",
                        "adset_ids",
                        "ad_ids"
                      ],
                      "properties": {
                        "campaign_id": {
                          "description": "Meta campaign id returned at creation, null when no campaign was created",
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "adset_ids": {
                          "description": "Meta ad set ids created by this run",
                          "type": "array",
                          "items": {
                            "type": "string"
                          }
                        },
                        "ad_ids": {
                          "description": "Meta ad ids created by this run",
                          "type": "array",
                          "items": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "message"
                  ],
                  "properties": {
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/bulk-launch/status/batch": {
      "post": {
        "operationId": "getBulkLaunchStatusBatch",
        "summary": "Get worker run statuses for multiple launched campaigns in a single query",
        "tags": [
          "bulk-launch"
        ],
        "description": "Returns status, task counts, and event logs for multiple worker runs in a single request. Reconciles each row: heals to COMPLETED when all steps have actually finished, and marks FAILED only when a RUNNING run has shown no progress for 15 minutes. The response is a map keyed by worker_run_id.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "worker_run_ids"
                ],
                "properties": {
                  "worker_run_ids": {
                    "maxItems": 200,
                    "type": "array",
                    "items": {
                      "format": "uuid",
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "results"
                  ],
                  "properties": {
                    "results": {
                      "type": "object",
                      "additionalProperties": {
                        "additionalProperties": false,
                        "type": "object",
                        "required": [
                          "status",
                          "total_tasks",
                          "completed_tasks",
                          "failed_tasks",
                          "events",
                          "created"
                        ],
                        "properties": {
                          "status": {
                            "type": "string"
                          },
                          "total_tasks": {
                            "type": "number"
                          },
                          "completed_tasks": {
                            "type": "number"
                          },
                          "failed_tasks": {
                            "type": "number"
                          },
                          "events": {
                            "type": "array",
                            "items": {
                              "additionalProperties": false,
                              "type": "object",
                              "required": [
                                "status",
                                "error_message",
                                "created_at"
                              ],
                              "properties": {
                                "status": {
                                  "type": "string"
                                },
                                "error_message": {
                                  "anyOf": [
                                    {
                                      "type": "string"
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "created_at": {
                                  "format": "date-time",
                                  "type": "string"
                                }
                              }
                            }
                          },
                          "created": {
                            "additionalProperties": false,
                            "type": "object",
                            "required": [
                              "campaign_id",
                              "adset_ids",
                              "ad_ids"
                            ],
                            "properties": {
                              "campaign_id": {
                                "description": "Meta campaign id returned at creation, null when no campaign was created",
                                "anyOf": [
                                  {
                                    "type": "string"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "adset_ids": {
                                "description": "Meta ad set ids created by this run",
                                "type": "array",
                                "items": {
                                  "type": "string"
                                }
                              },
                              "ad_ids": {
                                "description": "Meta ad ids created by this run",
                                "type": "array",
                                "items": {
                                  "type": "string"
                                }
                              }
                            }
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/bulk-launch/nested": {
      "post": {
        "operationId": "nestedBulkLaunch",
        "summary": "Launch a campaign with nested adsets and ads structure",
        "tags": [
          "bulk-launch"
        ],
        "description": "Accepts a nested campaign payload where each ad set contains its own specific ads. Creates 1 campaign -> N ad sets -> M ads per ad set (no cartesian product) and dispatches the work to the bulk-launch SQS workers, stamped with the ACTIVE workspace team (`x-team-id` / team scope required — 400 `SCOPE_TEAM_REQUIRED` otherwise). The referenced ad account (and, for Meta, fan page / pixel / token) must belong to the active workspace or the dispatch is rejected with 403 `RESOURCE_NOT_IN_ACTIVE_WORKSPACE`. Returns the worker_run_id used to poll progress.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "campaign_name",
                  "daily_budget",
                  "ad_type",
                  "account_id",
                  "ad_sets"
                ],
                "properties": {
                  "platform": {
                    "description": "Ad platform - defaults to meta for legacy callers",
                    "anyOf": [
                      {
                        "type": "string",
                        "enum": [
                          "meta"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "google"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "tiktok"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "taboola"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "snapchat"
                        ]
                      }
                    ]
                  },
                  "campaign_name": {
                    "description": "Campaign name",
                    "type": "string"
                  },
                  "campaign_objective": {
                    "description": "Campaign objective. Accepts canonical objectives and platform-native values for non-Meta bulk launch.",
                    "anyOf": [
                      {
                        "description": "Canonical campaign objective.",
                        "anyOf": [
                          {
                            "type": "string",
                            "enum": [
                              "OUTCOME_AWARENESS"
                            ]
                          },
                          {
                            "type": "string",
                            "enum": [
                              "OUTCOME_TRAFFIC"
                            ]
                          },
                          {
                            "type": "string",
                            "enum": [
                              "OUTCOME_ENGAGEMENT"
                            ]
                          },
                          {
                            "type": "string",
                            "enum": [
                              "OUTCOME_LEADS"
                            ]
                          },
                          {
                            "type": "string",
                            "enum": [
                              "OUTCOME_APP_PROMOTION"
                            ]
                          },
                          {
                            "type": "string",
                            "enum": [
                              "OUTCOME_SALES"
                            ]
                          },
                          {
                            "type": "string",
                            "enum": [
                              "GOOGLE_SEARCH"
                            ]
                          },
                          {
                            "type": "string",
                            "enum": [
                              "GOOGLE_DISPLAY"
                            ]
                          },
                          {
                            "type": "string",
                            "enum": [
                              "GOOGLE_VIDEO"
                            ]
                          },
                          {
                            "type": "string",
                            "enum": [
                              "GOOGLE_SHOPPING"
                            ]
                          },
                          {
                            "type": "string",
                            "enum": [
                              "GOOGLE_PERFORMANCE_MAX"
                            ]
                          },
                          {
                            "type": "string",
                            "enum": [
                              "GOOGLE_DEMAND_GEN"
                            ]
                          },
                          {
                            "type": "string",
                            "enum": [
                              "GOOGLE_APP"
                            ]
                          }
                        ]
                      },
                      {
                        "description": "Platform-native objective/channel value for non-Meta bulk launch.",
                        "type": "string"
                      }
                    ]
                  },
                  "budget_optimization": {
                    "description": "Budget optimization type: CBO, ABO, BID_CAP, etc.",
                    "type": "string"
                  },
                  "daily_budget": {
                    "description": "Daily budget in cents (for CBO) or default for ABO ad sets",
                    "type": "number"
                  },
                  "budget_level": {
                    "description": "Budget level: CBO or ABO",
                    "type": "string"
                  },
                  "bid_strategy": {
                    "description": "Bid strategy: LOWEST_COST, BID_CAP, COST_CAP, MIN_ROAS",
                    "type": "string"
                  },
                  "accelerated_delivery": {
                    "description": "Meta accelerated delivery (pacing_type [\"no_pacing\"] on ad sets). Applied only under ABO where the effective bid strategy is BID_CAP; ignored otherwise.",
                    "type": "boolean"
                  },
                  "ad_type": {
                    "description": "Ad type: Standard, Multilanguage, Catalog, App Install",
                    "type": "string"
                  },
                  "account_id": {
                    "description": "Ad Account ID (Meta act_xxx, Taboola account_id, Google customer_id, TikTok advertiser_id)",
                    "type": "string"
                  },
                  "fan_page_id": {
                    "description": "Meta Fan Page ID - required when platform=meta",
                    "type": "string"
                  },
                  "pixel_id": {
                    "description": "Meta Pixel ID - required when platform=meta",
                    "type": "string"
                  },
                  "meta_token_id": {
                    "format": "uuid",
                    "description": "Selected Meta token ID for exclusive token mode",
                    "type": "string"
                  },
                  "taboola_branding_text": {
                    "description": "Taboola: branding text shown alongside ads (defaults to campaign_name)",
                    "type": "string"
                  },
                  "taboola_cpc": {
                    "description": "Taboola: CPC bid in account currency (0.01–1.5)",
                    "type": "number"
                  },
                  "taboola_daily_cap": {
                    "description": "Taboola: daily cap in account currency (min 15, default = daily_budget/100)",
                    "type": "number"
                  },
                  "taboola_spending_limit": {
                    "description": "Taboola: total spending limit (default = daily_cap × 30)",
                    "type": "number"
                  },
                  "taboola_spending_limit_type": {
                    "description": "Taboola: spending limit window - MONTHLY or ENTIRE (lifetime)",
                    "anyOf": [
                      {
                        "type": "string",
                        "enum": [
                          "MONTHLY"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "ENTIRE"
                        ]
                      }
                    ]
                  },
                  "taboola_bid_strategy": {
                    "description": "Taboola: bid strategy - FIXED (default) or TARGET_CPA (requires connected pixel)",
                    "anyOf": [
                      {
                        "type": "string",
                        "enum": [
                          "FIXED"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "TARGET_CPA"
                        ]
                      }
                    ]
                  },
                  "taboola_pricing_model": {
                    "description": "Taboola: pricing model - CPC, CPM, vCPM (account-dependent)",
                    "type": "string"
                  },
                  "taboola_cpa_goal": {
                    "description": "Taboola: target CPA in account currency (required when bid_strategy=TARGET_CPA)",
                    "type": "number"
                  },
                  "end_date": {
                    "description": "Campaign end date",
                    "type": "string"
                  },
                  "special_ad_categories": {
                    "description": "Special ad categories: NONE, HOUSING, EMPLOYMENT, CREDIT, ISSUES_ELECTIONS_POLITICS, ONLINE_GAMBLING_AND_GAMING",
                    "type": "array",
                    "items": {
                      "anyOf": [
                        {
                          "type": "string",
                          "enum": [
                            "NONE"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "HOUSING"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "EMPLOYMENT"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "CREDIT"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "ISSUES_ELECTIONS_POLITICS"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "ONLINE_GAMBLING_AND_GAMING"
                          ]
                        }
                      ]
                    }
                  },
                  "advantage_plus_campaign": {
                    "description": "Enable Advantage+ Shopping Campaign (is_advantage_plus_campaign). Requires CBO and eligible objectives (SALES, APP_PROMOTION, LEADS).",
                    "type": "boolean"
                  },
                  "advantage_audience": {
                    "description": "Enable Advantage+ Audience (targeting_automation.advantage_audience)",
                    "type": "boolean"
                  },
                  "advantage_age": {
                    "description": "Enable Advantage+ Age expansion",
                    "type": "boolean"
                  },
                  "advantage_gender": {
                    "description": "Enable Advantage+ Gender expansion",
                    "type": "boolean"
                  },
                  "advantage_detailed_targeting": {
                    "description": "Enable Advantage+ Detailed Targeting expansion (v25)",
                    "type": "boolean"
                  },
                  "advantage_lookalike": {
                    "description": "Enable Advantage+ Lookalike expansion (v25)",
                    "type": "boolean"
                  },
                  "multi_advertiser": {
                    "description": "Enable Multi-Advertiser ads (contextual_multi_ads)",
                    "type": "boolean"
                  },
                  "advantage_creative": {
                    "description": "Enable Advantage+ Creative enhancements (degrees_of_freedom_spec)",
                    "type": "boolean"
                  },
                  "dynamic_creative": {
                    "description": "Enable Dynamic Creative optimization (is_dynamic_creative)",
                    "type": "boolean"
                  },
                  "initial_status": {
                    "description": "Initial status for campaign, ad sets, and ads. Defaults to ACTIVE.",
                    "anyOf": [
                      {
                        "type": "string",
                        "enum": [
                          "ACTIVE"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "PAUSED"
                        ]
                      }
                    ]
                  },
                  "ad_sets": {
                    "description": "Ad Sets within this campaign",
                    "minItems": 1,
                    "type": "array",
                    "items": {
                      "additionalProperties": false,
                      "type": "object",
                      "required": [
                        "name",
                        "optimization_goal",
                        "billing_event",
                        "start_date",
                        "country",
                        "min_age",
                        "max_age",
                        "gender",
                        "ads"
                      ],
                      "properties": {
                        "name": {
                          "description": "Ad Set name",
                          "type": "string"
                        },
                        "bid_amount": {
                          "description": "Bid amount for this ad set",
                          "type": "string"
                        },
                        "bid_strategy": {
                          "description": "Per-adset bid strategy for ABO (LOWEST_COST, BID_CAP, COST_CAP, MIN_ROAS)",
                          "type": "string"
                        },
                        "optimization_goal": {
                          "description": "Ad Set optimization goal",
                          "anyOf": [
                            {
                              "type": "string",
                              "enum": [
                                "REACH"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "IMPRESSIONS"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "AD_RECALL_LIFT"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "LINK_CLICKS"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "LANDING_PAGE_VIEWS"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "POST_ENGAGEMENT"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "PAGE_LIKES"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "EVENT_RESPONSES"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "LEAD_GENERATION"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "APP_INSTALLS"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "OFFSITE_CONVERSIONS"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "CONVERSIONS"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "VALUE"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "QUALITY_LEAD"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "QUALITY_CALL"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "THRUPLAY"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "REMINDERS_SET"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "CONVERSATIONS"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "VISIT_INSTAGRAM_PROFILE"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "PROFILE_VISIT"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "TWO_SECOND_CONTINUOUS_VIDEO_VIEWS"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "MESSAGING_PURCHASE_CONVERSION"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "MESSAGING_APPOINTMENT_CONVERSION"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "APP_INSTALLS_AND_OFFSITE_CONVERSIONS"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "DERIVED_EVENTS"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "SUBSCRIBERS"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "IN_APP_VALUE"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "ENGAGED_USERS"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "MEANINGFUL_CALL_ATTEMPT"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "ENGAGED_PAGE_VIEWS"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "PROFILE_AND_PAGE_ENGAGEMENT"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "ADVERTISER_SILOED_VALUE"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "MESSAGING_DEEP_CONVERSATION_AND_FOLLOW"
                              ]
                            }
                          ]
                        },
                        "billing_event": {
                          "description": "Billing event (e.g. IMPRESSIONS)",
                          "anyOf": [
                            {
                              "type": "string",
                              "enum": [
                                "IMPRESSIONS"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "LINK_CLICKS"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "THRUPLAY"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "APP_INSTALLS"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "CLICKS"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "PAGE_LIKES"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "POST_ENGAGEMENT"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "PURCHASE"
                              ]
                            }
                          ]
                        },
                        "destination_type": {
                          "description": "Ad Set destination type (auto-derived if not provided)",
                          "anyOf": [
                            {
                              "type": "string",
                              "enum": [
                                "WEBSITE"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "APP"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "MESSENGER"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "PHONE_CALL"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "ON_AD"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "SHOP_AUTOMATIC"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "ON_POST"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "ON_PAGE"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "ON_VIDEO"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "ON_EVENT"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "APPLINKS_AUTOMATIC"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "MESSAGING"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "WHATSAPP"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "INSTAGRAM_DIRECT"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "FACEBOOK"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "MESSAGING_MESSENGER_WHATSAPP"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "MESSAGING_INSTAGRAM_DIRECT_MESSENGER"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "MESSAGING_INSTAGRAM_DIRECT_MESSENGER_WHATSAPP"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "MESSAGING_INSTAGRAM_DIRECT_WHATSAPP"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "INSTAGRAM_PROFILE"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "FACEBOOK_PAGE"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "INSTAGRAM_PROFILE_AND_FACEBOOK_PAGE"
                              ]
                            }
                          ]
                        },
                        "custom_event_type": {
                          "description": "Custom event type (e.g. PURCHASE)",
                          "type": "string"
                        },
                        "start_date": {
                          "description": "Ad Set start date",
                          "type": "string"
                        },
                        "start_time": {
                          "description": "Ad Set start time",
                          "type": "string"
                        },
                        "end_date": {
                          "description": "Ad Set end date",
                          "type": "string"
                        },
                        "end_time": {
                          "description": "Ad Set end time (HH:MM)",
                          "type": "string"
                        },
                        "daily_budget": {
                          "description": "Daily budget for ABO (in cents)",
                          "type": "string"
                        },
                        "spend_percent": {
                          "minimum": 1,
                          "maximum": 100,
                          "description": "Meta CBO only: fixed percentage (1-100) of the campaign budget to allocate to this ad set. Translated to daily_min_spend_target + daily_spend_cap (min == cap) on Meta.",
                          "type": "number"
                        },
                        "country": {
                          "description": "Target country code (e.g. IT)",
                          "type": "string"
                        },
                        "min_age": {
                          "description": "Minimum age targeting",
                          "type": "string"
                        },
                        "max_age": {
                          "description": "Maximum age targeting",
                          "type": "string"
                        },
                        "gender": {
                          "description": "Gender targeting: All, Male, Female",
                          "type": "string"
                        },
                        "devices": {
                          "description": "Device targeting: all, mobile, desktop",
                          "type": "string"
                        },
                        "os": {
                          "description": "OS targeting: all, android, ios",
                          "type": "string"
                        },
                        "publisher_platforms": {
                          "description": "Manual publisher platforms: facebook, instagram, audience_network, messenger, threads.",
                          "type": "array",
                          "items": {
                            "enum": [
                              "facebook",
                              "instagram",
                              "audience_network",
                              "messenger",
                              "threads"
                            ],
                            "type": "string"
                          }
                        },
                        "facebook_positions": {
                          "description": "Facebook positions: feed, right_hand_column, marketplace, story, search, instream_video, facebook_reels, facebook_reels_overlay, profile_feed, notification. Rejected (retired by Meta): instant_article, video_feeds.",
                          "type": "array",
                          "items": {
                            "enum": [
                              "feed",
                              "right_hand_column",
                              "marketplace",
                              "story",
                              "search",
                              "instream_video",
                              "facebook_reels",
                              "facebook_reels_overlay",
                              "profile_feed",
                              "notification"
                            ],
                            "type": "string"
                          }
                        },
                        "instagram_positions": {
                          "description": "Instagram positions: stream, story, explore, explore_home, reels, profile_feed, ig_search, profile_reels. Rejected (retired by Meta): shop. Removed by Meta on 2026-10-27, still accepted today: explore, explore_home.",
                          "type": "array",
                          "items": {
                            "enum": [
                              "stream",
                              "story",
                              "explore",
                              "explore_home",
                              "reels",
                              "profile_feed",
                              "ig_search",
                              "profile_reels"
                            ],
                            "type": "string"
                          }
                        },
                        "audience_network_positions": {
                          "description": "Audience Network positions: classic, rewarded_video.",
                          "type": "array",
                          "items": {
                            "enum": [
                              "classic",
                              "rewarded_video"
                            ],
                            "type": "string"
                          }
                        },
                        "messenger_positions": {
                          "description": "Messenger positions: story. Rejected (retired by Meta): messenger_home, sponsored_messages. Removed by Meta on 2026-10-27, still accepted today: story.",
                          "type": "array",
                          "items": {
                            "enum": [
                              "story"
                            ],
                            "type": "string"
                          }
                        },
                        "threads_positions": {
                          "description": "Threads positions: threads_stream.",
                          "type": "array",
                          "items": {
                            "enum": [
                              "threads_stream"
                            ],
                            "type": "string"
                          }
                        },
                        "dsa_beneficiary": {
                          "description": "DSA beneficiary",
                          "type": "string"
                        },
                        "dsa_payor": {
                          "description": "DSA payor",
                          "type": "string"
                        },
                        "roas_average_floor": {
                          "description": "ROAS minimum floor for MIN_ROAS strategy",
                          "type": "string"
                        },
                        "attribution_window": {
                          "description": "Attribution window: 7d_click_1d_view, 7d_click, 1d_click_1d_view, 1d_click",
                          "type": "string"
                        },
                        "target_cities": {
                          "description": "Target cities with radius for geo targeting",
                          "type": "array",
                          "items": {
                            "additionalProperties": false,
                            "type": "object",
                            "required": [
                              "key",
                              "radius",
                              "distance_unit"
                            ],
                            "properties": {
                              "key": {
                                "type": "string"
                              },
                              "radius": {
                                "minimum": 10,
                                "maximum": 80,
                                "type": "number"
                              },
                              "distance_unit": {
                                "type": "string"
                              }
                            }
                          }
                        },
                        "target_countries": {
                          "description": "Target country codes for multi-country targeting",
                          "type": "array",
                          "items": {
                            "type": "string"
                          }
                        },
                        "target_regions": {
                          "description": "Target regions for geo targeting",
                          "type": "array",
                          "items": {
                            "additionalProperties": false,
                            "type": "object",
                            "required": [
                              "key"
                            ],
                            "properties": {
                              "key": {
                                "type": "string"
                              }
                            }
                          }
                        },
                        "locales": {
                          "description": "Meta locale IDs for ad-set language targeting (targeting.locales). Restricts delivery to people whose Facebook language matches; omit or leave empty for no restriction. Discoverable via GET /api/v1/locale-search.",
                          "type": "array",
                          "items": {
                            "type": "integer"
                          }
                        },
                        "included_audiences": {
                          "description": "Custom audience IDs to include",
                          "type": "array",
                          "items": {
                            "type": "string"
                          }
                        },
                        "excluded_audiences": {
                          "description": "Custom audience IDs to exclude",
                          "type": "array",
                          "items": {
                            "type": "string"
                          }
                        },
                        "ads": {
                          "description": "Ads within this ad set",
                          "minItems": 1,
                          "type": "array",
                          "items": {
                            "additionalProperties": false,
                            "type": "object",
                            "required": [
                              "name",
                              "cta",
                              "landing_url",
                              "message",
                              "title"
                            ],
                            "properties": {
                              "name": {
                                "description": "Ad name",
                                "type": "string"
                              },
                              "cta": {
                                "description": "Call to action type. Meta values come from the canonical CallToAction enum (e.g. LEARN_MORE); other platforms send their own native CTA. Empty string means \"worker default\".",
                                "type": "string"
                              },
                              "video_url": {
                                "description": "Video URL for video ads",
                                "type": "string"
                              },
                              "image_url": {
                                "description": "Image URL for image ads",
                                "type": "string"
                              },
                              "landing_url": {
                                "description": "Landing page URL",
                                "pattern": "^$|^https?:\\/\\/.+\\..+",
                                "type": "string"
                              },
                              "url_params": {
                                "description": "URL tracking parameters",
                                "type": "string"
                              },
                              "message": {
                                "description": "Ad primary text",
                                "type": "string"
                              },
                              "title": {
                                "description": "Ad headline",
                                "type": "string"
                              },
                              "description": {
                                "description": "Ad description",
                                "type": "string"
                              },
                              "messages": {
                                "description": "Meta dynamic creative primary text variations",
                                "maxItems": 5,
                                "type": "array",
                                "items": {
                                  "type": "string"
                                }
                              },
                              "titles": {
                                "description": "Meta dynamic creative headline variations",
                                "maxItems": 5,
                                "type": "array",
                                "items": {
                                  "type": "string"
                                }
                              },
                              "descriptions": {
                                "description": "Meta dynamic creative description variations",
                                "maxItems": 5,
                                "type": "array",
                                "items": {
                                  "type": "string"
                                }
                              },
                              "catalog_id": {
                                "description": "Catalog ID for catalog ads",
                                "type": "string"
                              },
                              "product_set_id": {
                                "description": "Product Set ID for catalog ads",
                                "type": "string"
                              },
                              "app_id": {
                                "description": "App ID for app install ads",
                                "type": "string"
                              },
                              "app_store_url": {
                                "description": "App store URL for app install ads",
                                "type": "string"
                              },
                              "deep_link_url": {
                                "description": "Deep link URL for app install ads",
                                "type": "string"
                              },
                              "target_language": {
                                "description": "Target language for multilanguage ads",
                                "type": "string"
                              },
                              "secondary_languages": {
                                "description": "Secondary language codes for DLO",
                                "type": "array",
                                "items": {
                                  "type": "string"
                                }
                              },
                              "extra_video_url": {
                                "description": "Extra video URL for multilanguage",
                                "type": "string"
                              },
                              "extra_image_url": {
                                "description": "Extra image URL for multilanguage",
                                "type": "string"
                              },
                              "extra_link": {
                                "description": "Extra link for multilanguage",
                                "type": "string"
                              },
                              "extra_message": {
                                "description": "Extra message for multilanguage",
                                "type": "string"
                              },
                              "extra_title": {
                                "description": "Extra title for multilanguage",
                                "type": "string"
                              },
                              "extra_description": {
                                "description": "Extra description for multilanguage",
                                "type": "string"
                              },
                              "unmatched_audience_video": {
                                "description": "Multilanguage: which creative audiences with no matching configured language see (is_default rule). Defaults to \"safe\".",
                                "anyOf": [
                                  {
                                    "type": "string",
                                    "enum": [
                                      "safe"
                                    ]
                                  },
                                  {
                                    "type": "string",
                                    "enum": [
                                      "targeted"
                                    ]
                                  }
                                ]
                              },
                              "use_existing_post": {
                                "description": "Use existing post as ad creative",
                                "type": "boolean"
                              },
                              "object_story_id": {
                                "description": "Object story ID (post ID) for existing post ads",
                                "type": "string"
                              },
                              "use_flexible": {
                                "description": "Use Flexible format (mixed image + video)",
                                "type": "boolean"
                              },
                              "flexible_image_urls": {
                                "description": "Image URLs for Flexible format (combined with flexible_video_urls, total 2-10)",
                                "maxItems": 10,
                                "type": "array",
                                "items": {
                                  "type": "string"
                                }
                              },
                              "flexible_video_urls": {
                                "description": "Video URLs for Flexible format (combined with flexible_image_urls, total 2-10)",
                                "maxItems": 10,
                                "type": "array",
                                "items": {
                                  "type": "string"
                                }
                              },
                              "use_placement_customization": {
                                "description": "Use Meta placement asset customization (separate Stories/Reels asset)",
                                "type": "boolean"
                              },
                              "placement_story_url": {
                                "description": "Vertical 9:16 asset URL for Stories/Reels. Same media type as image_url/video_url (the Feed asset).",
                                "type": "string"
                              },
                              "platformFields": {
                                "description": "Platform-specific launch fields keyed as section.fieldId, for example campaign.goal or creative.rsa_headline_1",
                                "type": "object",
                                "additionalProperties": {
                                  "type": "string"
                                }
                              },
                              "platform_fields": {
                                "description": "Platform-specific launch fields keyed as section.fieldId, for example campaign.goal or creative.rsa_headline_1",
                                "type": "object",
                                "additionalProperties": {
                                  "type": "string"
                                }
                              }
                            }
                          }
                        },
                        "platformFields": {
                          "description": "Platform-specific launch fields keyed as section.fieldId, for example campaign.goal or creative.rsa_headline_1",
                          "type": "object",
                          "additionalProperties": {
                            "type": "string"
                          }
                        },
                        "platform_fields": {
                          "description": "Platform-specific launch fields keyed as section.fieldId, for example campaign.goal or creative.rsa_headline_1",
                          "type": "object",
                          "additionalProperties": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  },
                  "platformFields": {
                    "description": "Platform-specific launch fields keyed as section.fieldId, for example campaign.goal or creative.rsa_headline_1",
                    "type": "object",
                    "additionalProperties": {
                      "type": "string"
                    }
                  },
                  "platform_fields": {
                    "description": "Platform-specific launch fields keyed as section.fieldId, for example campaign.goal or creative.rsa_headline_1",
                    "type": "object",
                    "additionalProperties": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "header",
            "name": "x-team-id",
            "required": false,
            "description": "Explicit team (workspace) scope: a team.id the caller belongs to."
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "header",
            "name": "x-active-scope",
            "required": false,
            "description": "Active scope selector in `<scopeType>:<uuid>` form, e.g. `organization:<organization_id>` or `team:<team_id>`. Omit the header for the all-workspaces view."
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "message"
                  ],
                  "properties": {
                    "message": {
                      "type": "string"
                    },
                    "worker_run_id": {
                      "format": "uuid",
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "description": "Machine-readable code, e.g. SCOPE_TEAM_REQUIRED",
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "402": {
            "description": "Response 402",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message",
                    "code",
                    "requested",
                    "max"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "requested": {
                      "type": "number"
                    },
                    "max": {
                      "anyOf": [
                        {
                          "type": "number"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "description": "Machine-readable code, e.g. RESOURCE_NOT_IN_ACTIVE_WORKSPACE",
                      "type": "string"
                    },
                    "resource_type": {
                      "description": "Offending resource: ad_account, fan_page, pixel, meta_token",
                      "type": "string"
                    },
                    "resource_id": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "423": {
            "description": "Response 423",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number",
                      "enum": [
                        423
                      ]
                    },
                    "error": {
                      "type": "string",
                      "enum": [
                        "Locked"
                      ]
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/campaigns/actions": {
      "put": {
        "operationId": "putCampaignsActions",
        "summary": "Process campaign budget edits and toggle actions",
        "tags": [
          "campaigns"
        ],
        "description": "Receives a list of campaign actions (edit budget or toggle) and processes them asynchronously via SQS workers.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "sheet_id",
                  "rows"
                ],
                "properties": {
                  "sheet_id": {
                    "description": "Session or batch identifier.",
                    "type": "string"
                  },
                  "rows": {
                    "description": "Array of campaign actions to process.",
                    "minItems": 1,
                    "type": "array",
                    "items": {
                      "additionalProperties": false,
                      "type": "object",
                      "required": [
                        "sheet_row_number",
                        "campaign_id",
                        "account_id",
                        "bm_id"
                      ],
                      "properties": {
                        "sheet_row_number": {
                          "description": "Row number for tracking purposes.",
                          "type": "number"
                        },
                        "campaign_id": {
                          "description": "Meta Campaign ID to edit or toggle.",
                          "type": "string"
                        },
                        "account_id": {
                          "description": "Meta Ad Account ID associated with the campaign.",
                          "type": "string"
                        },
                        "bm_id": {
                          "description": "Business Manager ID.",
                          "type": "string"
                        },
                        "new_budget": {
                          "description": "New daily budget in cents (minimum currency units). Passed directly to Meta API.",
                          "type": "number"
                        },
                        "toggle_action": {
                          "description": "Whether to toggle the campaign (status=PAUSED).",
                          "anyOf": [
                            {
                              "type": "string",
                              "enum": [
                                "ACTIVE"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "PAUSED"
                              ]
                            }
                          ]
                        },
                        "delete_action": {
                          "description": "Delete (archive) the campaign on Meta.",
                          "type": "boolean"
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "message"
                  ],
                  "properties": {
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "207": {
            "description": "Multi-status - partial success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message",
                    "errors"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "errors": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "campaign_id",
                          "action",
                          "error"
                        ],
                        "properties": {
                          "campaign_id": {
                            "type": "string"
                          },
                          "action": {
                            "type": "string"
                          },
                          "error": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "422": {
            "description": "Unprocessable entity - semantic validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/google/insights/backfill": {
      "post": {
        "operationId": "googleSyncInsights",
        "summary": "Backfill historical Google Ads insights",
        "tags": [
          "google"
        ],
        "description": "Triggers an insights backfill for the last N days (default 30, max 365). Splits the date range into 30-day chunks distributed via SQS workers. Mirrors `/api/v1/insights/backfill` (Meta). 5-minute per-session debounce.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "properties": {
                  "days": {
                    "minimum": 1,
                    "maximum": 365,
                    "default": 30,
                    "description": "Lookback window in days (default 30, max 365). Split into 30-day chunks dispatched via SQS.",
                    "type": "number"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Insights backfill dispatch result. Mirrors `/api/v1/insights/backfill`.",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "description": "Insights backfill dispatch result. Mirrors `/api/v1/insights/backfill`.",
                  "type": "object",
                  "required": [
                    "status"
                  ],
                  "properties": {
                    "status": {
                      "type": "string"
                    },
                    "worker_run_id": {
                      "type": "string"
                    },
                    "days": {
                      "type": "number"
                    },
                    "chunks": {
                      "type": "number"
                    },
                    "from_date": {
                      "type": "string"
                    },
                    "to_date": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/google/campaigns/bulk-delete": {
      "post": {
        "operationId": "googleBulkDeleteCampaigns",
        "summary": "Bulk-delete every Google campaign for an account",
        "tags": [
          "google"
        ],
        "description": "Asynchronously removes every campaign on the supplied Google Ads account via the DELETE_CAMPAIGNS_BY_GOOGLE_ACCOUNT worker. Returns 202 with the worker_run_id; track progress via `/api/v1/sync/status`.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "account_id"
                ],
                "properties": {
                  "account_id": {
                    "minLength": 1,
                    "description": "Google Ads customer id (digits only, no dashes).",
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "202": {
            "description": "Accepted - processing asynchronously",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "success",
                    "queued",
                    "worker_run_id"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "queued": {
                      "type": "boolean"
                    },
                    "worker_run_id": {
                      "format": "uuid",
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/google/campaigns/{campaignId}": {
      "delete": {
        "operationId": "googleDeleteCampaign",
        "summary": "Delete a single Google campaign",
        "tags": [
          "google"
        ],
        "description": "Synchronously removes a single Google Ads campaign. Returns within ~1s under normal API load.",
        "parameters": [
          {
            "schema": {
              "minLength": 1,
              "type": "string"
            },
            "in": "query",
            "name": "account_id",
            "required": true,
            "description": "Google Ads customer id (digits only, no dashes)."
          },
          {
            "schema": {
              "minLength": 1,
              "type": "string"
            },
            "in": "path",
            "name": "campaignId",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Synchronous success ack - additional fields may be present.",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "description": "Synchronous success ack - additional fields may be present.",
                  "type": "object",
                  "required": [
                    "success"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/google/adgroups/{adgroupId}": {
      "delete": {
        "operationId": "googleDeleteAdGroup",
        "summary": "Delete a single Google ad group",
        "tags": [
          "google"
        ],
        "description": "Synchronously removes a single Google Ads ad group (Wevion adset level).",
        "parameters": [
          {
            "schema": {
              "minLength": 1,
              "type": "string"
            },
            "in": "query",
            "name": "account_id",
            "required": true,
            "description": "Google Ads customer id (digits only, no dashes)."
          },
          {
            "schema": {
              "minLength": 1,
              "type": "string"
            },
            "in": "path",
            "name": "adgroupId",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Synchronous success ack - additional fields may be present.",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "description": "Synchronous success ack - additional fields may be present.",
                  "type": "object",
                  "required": [
                    "success"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/google/ads/{adId}": {
      "delete": {
        "operationId": "googleDeleteAd",
        "summary": "Delete a single Google ad",
        "tags": [
          "google"
        ],
        "description": "Synchronously removes a single Google ad. The parent `adgroup_id` is required because Google addresses ads as `customers/{cid}/adGroupAds/{adgroup_id}~{ad_id}`.",
        "parameters": [
          {
            "schema": {
              "minLength": 1,
              "type": "string"
            },
            "in": "query",
            "name": "account_id",
            "required": true,
            "description": "Google Ads customer id."
          },
          {
            "schema": {
              "minLength": 1,
              "type": "string"
            },
            "in": "query",
            "name": "adgroup_id",
            "required": true,
            "description": "Parent ad-group id (Google API requires it for ad mutations)."
          },
          {
            "schema": {
              "minLength": 1,
              "type": "string"
            },
            "in": "path",
            "name": "adId",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Synchronous success ack - additional fields may be present.",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "description": "Synchronous success ack - additional fields may be present.",
                  "type": "object",
                  "required": [
                    "success"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/google/campaigns/{campaignId}/duplicate": {
      "post": {
        "operationId": "googleDuplicateCampaign",
        "summary": "Duplicate a Google campaign",
        "tags": [
          "google"
        ],
        "description": "Recreates a Google Ads campaign with its ad groups + ads. Google has no native copy endpoint - the provider walks the campaign tree and creates clones via mutate calls.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "account_id"
                ],
                "properties": {
                  "account_id": {
                    "minLength": 1,
                    "description": "Google Ads customer id (digits only, no dashes).",
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "schema": {
              "minLength": 1,
              "type": "string"
            },
            "in": "path",
            "name": "campaignId",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Synchronous success ack - additional fields may be present.",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "description": "Synchronous success ack - additional fields may be present.",
                  "type": "object",
                  "required": [
                    "success"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/google/adgroups/{adgroupId}/duplicate": {
      "post": {
        "operationId": "googleDuplicateAdGroup",
        "summary": "Duplicate a Google ad group",
        "tags": [
          "google"
        ],
        "description": "Recreates a Google Ads ad group with its ads. Wevion adset level.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "account_id"
                ],
                "properties": {
                  "account_id": {
                    "minLength": 1,
                    "description": "Google Ads customer id (digits only, no dashes).",
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "schema": {
              "minLength": 1,
              "type": "string"
            },
            "in": "path",
            "name": "adgroupId",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Synchronous success ack - additional fields may be present.",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "description": "Synchronous success ack - additional fields may be present.",
                  "type": "object",
                  "required": [
                    "success"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/google/ads/{adId}/duplicate": {
      "post": {
        "operationId": "googleDuplicateAd",
        "summary": "Duplicate a Google ad",
        "tags": [
          "google"
        ],
        "description": "Recreates a Google ad under its parent ad group.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "account_id",
                  "adgroup_id"
                ],
                "properties": {
                  "account_id": {
                    "minLength": 1,
                    "type": "string"
                  },
                  "adgroup_id": {
                    "minLength": 1,
                    "description": "Parent ad-group id (Google API requires it for ad mutations).",
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "schema": {
              "minLength": 1,
              "type": "string"
            },
            "in": "path",
            "name": "adId",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Synchronous success ack - additional fields may be present.",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "description": "Synchronous success ack - additional fields may be present.",
                  "type": "object",
                  "required": [
                    "success"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/google/campaigns/{campaignId}/toggle": {
      "post": {
        "operationId": "googleToggleCampaign",
        "summary": "Pause / resume a Google campaign",
        "tags": [
          "google"
        ],
        "description": "Enqueues a status flip on the GOOGLE_TOGGLE_ENTITY worker for the supplied campaign.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "account_id",
                  "is_active"
                ],
                "properties": {
                  "account_id": {
                    "minLength": 1,
                    "type": "string"
                  },
                  "is_active": {
                    "type": "boolean"
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "schema": {
              "minLength": 1,
              "type": "string"
            },
            "in": "path",
            "name": "campaignId",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Acknowledged enqueue (worker applies the change asynchronously).",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "description": "Acknowledged enqueue (worker applies the change asynchronously).",
                  "type": "object",
                  "required": [
                    "success",
                    "queued"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "queued": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/google/adgroups/{adgroupId}/toggle": {
      "post": {
        "operationId": "googleToggleAdGroup",
        "summary": "Pause / resume a Google ad group",
        "tags": [
          "google"
        ],
        "description": "Enqueues a status flip on the GOOGLE_TOGGLE_ENTITY worker for the supplied ad group.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "account_id",
                  "is_active"
                ],
                "properties": {
                  "account_id": {
                    "minLength": 1,
                    "type": "string"
                  },
                  "is_active": {
                    "type": "boolean"
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "schema": {
              "minLength": 1,
              "type": "string"
            },
            "in": "path",
            "name": "adgroupId",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Acknowledged enqueue (worker applies the change asynchronously).",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "description": "Acknowledged enqueue (worker applies the change asynchronously).",
                  "type": "object",
                  "required": [
                    "success",
                    "queued"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "queued": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/google/ads/{adId}/toggle": {
      "post": {
        "operationId": "googleToggleAd",
        "summary": "Pause / resume a Google ad",
        "tags": [
          "google"
        ],
        "description": "Enqueues a status flip on the GOOGLE_TOGGLE_ENTITY worker for the supplied ad.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "account_id",
                  "is_active"
                ],
                "properties": {
                  "account_id": {
                    "minLength": 1,
                    "type": "string"
                  },
                  "is_active": {
                    "type": "boolean"
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "schema": {
              "minLength": 1,
              "type": "string"
            },
            "in": "path",
            "name": "adId",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Acknowledged enqueue (worker applies the change asynchronously).",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "description": "Acknowledged enqueue (worker applies the change asynchronously).",
                  "type": "object",
                  "required": [
                    "success",
                    "queued"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "queued": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/google/campaigns/{campaignId}/budget": {
      "post": {
        "operationId": "googleEditCampaignBudget",
        "summary": "Edit a Google campaign daily budget",
        "tags": [
          "google"
        ],
        "description": "Enqueues a campaign budget update on the GOOGLE_EDIT_CAMPAIGN_BUDGET worker. The mutation runs asynchronously.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "account_id",
                  "budget"
                ],
                "properties": {
                  "account_id": {
                    "minLength": 1,
                    "type": "string"
                  },
                  "budget": {
                    "exclusiveMinimum": 0,
                    "description": "New daily budget in account currency.",
                    "type": "number"
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "schema": {
              "minLength": 1,
              "type": "string"
            },
            "in": "path",
            "name": "campaignId",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Acknowledged enqueue (worker applies the change asynchronously).",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "description": "Acknowledged enqueue (worker applies the change asynchronously).",
                  "type": "object",
                  "required": [
                    "success",
                    "queued"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "queued": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/google/adgroups/{adGroupId}/budget": {
      "post": {
        "operationId": "googleEditAdGroupCpcBid",
        "summary": "Edit a Google ad group CPC bid",
        "tags": [
          "google"
        ],
        "description": "Enqueues an ad-group CPC bid update on the GOOGLE_EDIT_ADGROUP_CPC_BID worker.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "account_id",
                  "cpc_bid"
                ],
                "properties": {
                  "account_id": {
                    "minLength": 1,
                    "type": "string"
                  },
                  "cpc_bid": {
                    "exclusiveMinimum": 0,
                    "description": "New CPC bid in account currency micros (Google API).",
                    "type": "number"
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "schema": {
              "minLength": 1,
              "type": "string"
            },
            "in": "path",
            "name": "adGroupId",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Acknowledged enqueue (worker applies the change asynchronously).",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "description": "Acknowledged enqueue (worker applies the change asynchronously).",
                  "type": "object",
                  "required": [
                    "success",
                    "queued"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "queued": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/google/conversion-actions/sync": {
      "post": {
        "operationId": "googleSyncConversions",
        "summary": "Sync Google conversion actions",
        "tags": [
          "google"
        ],
        "description": "Pulls every conversion action from Google Ads for connected non-MCC accounts and upserts them into `google_conversion_action`. Stale rows (no longer present in Google) are deleted.",
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "success",
                    "synced"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "synced": {
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/google/conversion-actions": {
      "get": {
        "operationId": "listGoogleConversions",
        "summary": "List Google conversion actions",
        "tags": [
          "google"
        ],
        "description": "Returns the conversion actions persisted for the caller session. Optional filters: `google_account_id`, free-text `search` (matches name).",
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "google_account_id",
            "required": false
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "limit",
            "required": false,
            "description": "Numeric string, default 50."
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "offset",
            "required": false,
            "description": "Numeric string, default 0."
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "search",
            "required": false,
            "description": "Case-insensitive substring match against name."
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "items",
                    "total"
                  ],
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "additionalProperties": true,
                        "type": "object",
                        "required": [
                          "id",
                          "google_account_id",
                          "conversion_action_id",
                          "name",
                          "category",
                          "type",
                          "status",
                          "origin",
                          "connected",
                          "created_at",
                          "synced_at"
                        ],
                        "properties": {
                          "id": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "google_account_id": {
                            "type": "string"
                          },
                          "conversion_action_id": {
                            "type": "string"
                          },
                          "name": {
                            "type": "string"
                          },
                          "category": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "type": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "status": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "origin": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "connected": {
                            "type": "boolean"
                          },
                          "created_at": {
                            "format": "date-time",
                            "type": "string"
                          },
                          "synced_at": {
                            "anyOf": [
                              {
                                "format": "date-time",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          }
                        }
                      }
                    },
                    "total": {
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/health": {
      "get": {
        "operationId": "getHealth",
        "summary": "Full health check with DB latency",
        "tags": [
          "health"
        ],
        "description": "Returns overall service status plus a live DB round-trip latency sample. `status` is `healthy` when the DB responds in <5s, `degraded` when slower, `unhealthy` when unreachable. Used by monitoring dashboards and alerting - NOT the K8s readiness probe (see `/ready`).",
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "status",
                    "timestamp",
                    "uptimeMs",
                    "db"
                  ],
                  "properties": {
                    "status": {
                      "anyOf": [
                        {
                          "type": "string",
                          "enum": [
                            "healthy"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "degraded"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "unhealthy"
                          ]
                        }
                      ]
                    },
                    "timestamp": {
                      "format": "date-time",
                      "type": "string"
                    },
                    "uptimeMs": {
                      "minimum": 0,
                      "type": "integer"
                    },
                    "db": {
                      "type": "object",
                      "required": [
                        "connected",
                        "latencyMs"
                      ],
                      "properties": {
                        "connected": {
                          "type": "boolean"
                        },
                        "latencyMs": {
                          "anyOf": [
                            {
                              "minimum": 0,
                              "type": "integer"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        }
                      }
                    },
                    "services": {
                      "type": "object",
                      "required": [
                        "competitive_intelligence"
                      ],
                      "properties": {
                        "competitive_intelligence": {
                          "anyOf": [
                            {
                              "type": "string",
                              "enum": [
                                "ok"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "degraded"
                              ]
                            }
                          ]
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "Service unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "status",
                    "timestamp",
                    "uptimeMs",
                    "db"
                  ],
                  "properties": {
                    "status": {
                      "anyOf": [
                        {
                          "type": "string",
                          "enum": [
                            "healthy"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "degraded"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "unhealthy"
                          ]
                        }
                      ]
                    },
                    "timestamp": {
                      "format": "date-time",
                      "type": "string"
                    },
                    "uptimeMs": {
                      "minimum": 0,
                      "type": "integer"
                    },
                    "db": {
                      "type": "object",
                      "required": [
                        "connected",
                        "latencyMs"
                      ],
                      "properties": {
                        "connected": {
                          "type": "boolean"
                        },
                        "latencyMs": {
                          "anyOf": [
                            {
                              "minimum": 0,
                              "type": "integer"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        }
                      }
                    },
                    "services": {
                      "type": "object",
                      "required": [
                        "competitive_intelligence"
                      ],
                      "properties": {
                        "competitive_intelligence": {
                          "anyOf": [
                            {
                              "type": "string",
                              "enum": [
                                "ok"
                              ]
                            },
                            {
                              "type": "string",
                              "enum": [
                                "degraded"
                              ]
                            }
                          ]
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/ready": {
      "get": {
        "operationId": "getReady",
        "summary": "K8s readiness probe",
        "tags": [
          "health"
        ],
        "description": "Lightweight readiness probe used by the Kubernetes readiness gate. Returns 200 only when the app can serve traffic (DB is reachable), 503 otherwise. Prefer `/health` for full status.",
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "ready"
                  ],
                  "properties": {
                    "ready": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "Service unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "ready"
                  ],
                  "properties": {
                    "ready": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/job-runs/{runId}/events": {
      "get": {
        "operationId": "listJobEventsUnderRun",
        "summary": "List all events for a specific job run",
        "tags": [
          "jobs"
        ],
        "description": "Retrieve all events associated with a specific job run, with cursor pagination.",
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "query",
            "name": "job_run_id",
            "required": false
          },
          {
            "schema": {
              "format": "date-time",
              "type": "string"
            },
            "in": "query",
            "name": "after",
            "required": false
          },
          {
            "schema": {
              "minimum": 1,
              "maximum": 200,
              "type": "number"
            },
            "in": "query",
            "name": "limit",
            "required": false
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "cursor",
            "required": false
          },
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "runId",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "items",
                    "next_cursor"
                  ],
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "additionalProperties": false,
                        "type": "object",
                        "required": [
                          "id",
                          "job_run_id",
                          "status",
                          "created_at"
                        ],
                        "properties": {
                          "id": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "job_run_id": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "status": {
                            "anyOf": [
                              {
                                "type": "string",
                                "enum": [
                                  "SUCCEEDED"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "FAILED"
                                ]
                              }
                            ]
                          },
                          "metadata": {
                            "$comment": "json-value",
                            "description": "Arbitrary JSON value with nested arrays and objects."
                          },
                          "created_at": {
                            "format": "date-time",
                            "type": "string"
                          },
                          "error_message": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          }
                        }
                      }
                    },
                    "next_cursor": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "createJobEventUnderRun",
        "summary": "Create a new job event under a specific job run",
        "tags": [
          "jobs"
        ],
        "description": "Create a new job event (status SUCCEEDED|FAILED) under a specific job run, with optional metadata and error_message.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "status"
                ],
                "properties": {
                  "status": {
                    "anyOf": [
                      {
                        "type": "string",
                        "enum": [
                          "SUCCEEDED"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "FAILED"
                        ]
                      }
                    ]
                  },
                  "metadata": {
                    "$comment": "json-value",
                    "description": "Arbitrary JSON value with nested arrays and objects."
                  },
                  "error_message": {
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "runId",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "201": {
            "description": "Resource created",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "id",
                    "job_run_id",
                    "status",
                    "created_at"
                  ],
                  "properties": {
                    "id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "job_run_id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "status": {
                      "anyOf": [
                        {
                          "type": "string",
                          "enum": [
                            "SUCCEEDED"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "FAILED"
                          ]
                        }
                      ]
                    },
                    "metadata": {
                      "$comment": "json-value",
                      "description": "Arbitrary JSON value with nested arrays and objects."
                    },
                    "created_at": {
                      "format": "date-time",
                      "type": "string"
                    },
                    "error_message": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/job-runs/{runId}/events/{eventId}": {
      "get": {
        "operationId": "getJobEventUnderRun",
        "summary": "Get a specific job event under a specific job run",
        "tags": [
          "jobs"
        ],
        "description": "Retrieve a specific job event scoped under a specific job run; returns 404 if ownership mismatch.",
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "runId",
            "required": true
          },
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "eventId",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "id",
                    "job_run_id",
                    "status",
                    "created_at"
                  ],
                  "properties": {
                    "id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "job_run_id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "status": {
                      "anyOf": [
                        {
                          "type": "string",
                          "enum": [
                            "SUCCEEDED"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "FAILED"
                          ]
                        }
                      ]
                    },
                    "metadata": {
                      "$comment": "json-value",
                      "description": "Arbitrary JSON value with nested arrays and objects."
                    },
                    "created_at": {
                      "format": "date-time",
                      "type": "string"
                    },
                    "error_message": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "message"
                  ],
                  "properties": {
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      },
      "patch": {
        "operationId": "updateJobEventUnderRun",
        "summary": "Update a specific job event under a specific job run",
        "tags": [
          "jobs"
        ],
        "description": "Update status (SUCCEEDED|FAILED) and/or metadata of a job event scoped under a specific job run; returns 404 if ownership mismatch.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "status": {
                    "anyOf": [
                      {
                        "type": "string",
                        "enum": [
                          "SUCCEEDED"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "FAILED"
                        ]
                      }
                    ]
                  },
                  "metadata": {
                    "$comment": "json-value",
                    "description": "Arbitrary JSON value with nested arrays and objects."
                  }
                },
                "additionalProperties": false
              }
            }
          }
        },
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "runId",
            "required": true
          },
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "eventId",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "id",
                    "job_run_id",
                    "status",
                    "created_at"
                  ],
                  "properties": {
                    "id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "job_run_id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "status": {
                      "anyOf": [
                        {
                          "type": "string",
                          "enum": [
                            "SUCCEEDED"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "FAILED"
                          ]
                        }
                      ]
                    },
                    "metadata": {
                      "$comment": "json-value",
                      "description": "Arbitrary JSON value with nested arrays and objects."
                    },
                    "created_at": {
                      "format": "date-time",
                      "type": "string"
                    },
                    "error_message": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "message"
                  ],
                  "properties": {
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      },
      "delete": {
        "operationId": "deleteJobEventUnderRun",
        "summary": "Delete a specific job event under a specific job run",
        "tags": [
          "jobs"
        ],
        "description": "Delete a specific job event scoped under a specific job run; returns 404 if ownership mismatch.",
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "runId",
            "required": true
          },
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "eventId",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "204": {
            "description": "No content"
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "message"
                  ],
                  "properties": {
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/job-events": {
      "get": {
        "operationId": "listJobEventsGlobal",
        "summary": "List all job events (global)",
        "tags": [
          "jobs"
        ],
        "description": "Retrieve all job events, optionally filtered by job_run_id, with cursor pagination.",
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "query",
            "name": "job_run_id",
            "required": false
          },
          {
            "schema": {
              "format": "date-time",
              "type": "string"
            },
            "in": "query",
            "name": "after",
            "required": false
          },
          {
            "schema": {
              "minimum": 1,
              "maximum": 200,
              "type": "number"
            },
            "in": "query",
            "name": "limit",
            "required": false
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "cursor",
            "required": false
          }
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "items",
                    "next_cursor"
                  ],
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "additionalProperties": false,
                        "type": "object",
                        "required": [
                          "id",
                          "job_run_id",
                          "status",
                          "created_at"
                        ],
                        "properties": {
                          "id": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "job_run_id": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "status": {
                            "anyOf": [
                              {
                                "type": "string",
                                "enum": [
                                  "SUCCEEDED"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "FAILED"
                                ]
                              }
                            ]
                          },
                          "metadata": {
                            "$comment": "json-value",
                            "description": "Arbitrary JSON value with nested arrays and objects."
                          },
                          "created_at": {
                            "format": "date-time",
                            "type": "string"
                          },
                          "error_message": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          }
                        }
                      }
                    },
                    "next_cursor": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/job-runs": {
      "get": {
        "operationId": "listJobRuns",
        "summary": "Retrieve all job runs",
        "tags": [
          "jobs"
        ],
        "description": "Returns a paginated list of job runs, with optional filters by status (RUNNING|SUCCEEDED|FAILED), job_type (EXPORT_CAMPAIGNS|BULK_LAUNCH) and date range.",
        "parameters": [
          {
            "schema": {
              "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
              "type": "string"
            },
            "in": "query",
            "name": "from_date",
            "required": false,
            "description": "Date in YYYY-MM-DD (UTC)"
          },
          {
            "schema": {
              "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
              "type": "string"
            },
            "in": "query",
            "name": "to_date",
            "required": false,
            "description": "Date in YYYY-MM-DD (UTC)"
          },
          {
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "enum": [
                    "RUNNING"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "SUCCEEDED"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "FAILED"
                  ]
                }
              ]
            },
            "in": "query",
            "name": "status",
            "required": false
          },
          {
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "enum": [
                    "EXPORT_CAMPAIGNS"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "BULK_LAUNCH"
                  ]
                }
              ]
            },
            "in": "query",
            "name": "job_type",
            "required": false
          },
          {
            "schema": {
              "minimum": 1,
              "maximum": 200,
              "type": "number"
            },
            "in": "query",
            "name": "limit",
            "required": false
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "cursor",
            "required": false
          }
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "items",
                    "next_cursor"
                  ],
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "additionalProperties": false,
                        "type": "object",
                        "required": [
                          "id",
                          "job_type",
                          "source",
                          "execution_id",
                          "initiator",
                          "params",
                          "status",
                          "error_message",
                          "started_at",
                          "finished_at"
                        ],
                        "properties": {
                          "id": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "job_type": {
                            "anyOf": [
                              {
                                "type": "string",
                                "enum": [
                                  "EXPORT_CAMPAIGNS"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "BULK_LAUNCH"
                                ]
                              }
                            ]
                          },
                          "source": {
                            "anyOf": [
                              {
                                "type": "string",
                                "enum": [
                                  "SHEETS"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "LAMBDA"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "API"
                                ]
                              }
                            ]
                          },
                          "execution_id": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "initiator": {
                            "type": "string"
                          },
                          "params": {
                            "anyOf": [
                              {
                                "$comment": "json-value",
                                "description": "Arbitrary JSON value with nested arrays and objects."
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "status": {
                            "anyOf": [
                              {
                                "type": "string",
                                "enum": [
                                  "RUNNING"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "SUCCEEDED"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "FAILED"
                                ]
                              }
                            ]
                          },
                          "error_message": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "started_at": {
                            "format": "date-time",
                            "type": "string"
                          },
                          "finished_at": {
                            "anyOf": [
                              {
                                "format": "date-time",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          }
                        }
                      }
                    },
                    "next_cursor": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "message"
                  ],
                  "properties": {
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "message"
                  ],
                  "properties": {
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "createJobRun",
        "summary": "Create a new job run",
        "tags": [
          "jobs"
        ],
        "description": "Create a new job run in RUNNING state. Returns the new job run ID.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "job_type",
                  "source"
                ],
                "properties": {
                  "job_type": {
                    "anyOf": [
                      {
                        "type": "string",
                        "enum": [
                          "EXPORT_CAMPAIGNS"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "BULK_LAUNCH"
                        ]
                      }
                    ]
                  },
                  "source": {
                    "anyOf": [
                      {
                        "type": "string",
                        "enum": [
                          "SHEETS"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "LAMBDA"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "API"
                        ]
                      }
                    ]
                  },
                  "initiator": {
                    "type": "string"
                  },
                  "params": {
                    "description": "JSON object with nested arrays and objects.",
                    "type": "object",
                    "additionalProperties": {
                      "$comment": "json-value",
                      "description": "Arbitrary JSON value with nested arrays and objects."
                    }
                  },
                  "execution_id": {
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "201": {
            "description": "Resource created",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "id"
                  ],
                  "properties": {
                    "id": {
                      "format": "uuid",
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "message"
                  ],
                  "properties": {
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "message"
                  ],
                  "properties": {
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/job-runs/{id}": {
      "get": {
        "operationId": "getJobRunById",
        "summary": "Get an existing job run by ID",
        "tags": [
          "jobs"
        ],
        "description": "Retrieve an existing job run by its ID.",
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "id",
                    "job_type",
                    "source",
                    "execution_id",
                    "initiator",
                    "params",
                    "status",
                    "error_message",
                    "started_at",
                    "finished_at"
                  ],
                  "properties": {
                    "id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "job_type": {
                      "anyOf": [
                        {
                          "type": "string",
                          "enum": [
                            "EXPORT_CAMPAIGNS"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "BULK_LAUNCH"
                          ]
                        }
                      ]
                    },
                    "source": {
                      "anyOf": [
                        {
                          "type": "string",
                          "enum": [
                            "SHEETS"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "LAMBDA"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "API"
                          ]
                        }
                      ]
                    },
                    "execution_id": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "initiator": {
                      "type": "string"
                    },
                    "params": {
                      "anyOf": [
                        {
                          "$comment": "json-value",
                          "description": "Arbitrary JSON value with nested arrays and objects."
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "status": {
                      "anyOf": [
                        {
                          "type": "string",
                          "enum": [
                            "RUNNING"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "SUCCEEDED"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "FAILED"
                          ]
                        }
                      ]
                    },
                    "error_message": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "started_at": {
                      "format": "date-time",
                      "type": "string"
                    },
                    "finished_at": {
                      "anyOf": [
                        {
                          "format": "date-time",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "message"
                  ],
                  "properties": {
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "message"
                  ],
                  "properties": {
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "message"
                  ],
                  "properties": {
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      },
      "patch": {
        "operationId": "updateJobRun",
        "summary": "Update an existing job run",
        "tags": [
          "jobs"
        ],
        "description": "Update an existing job run; allows changing status (RUNNING|SUCCEEDED|FAILED) and setting error_message. Returns the updated job run.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "status"
                ],
                "properties": {
                  "status": {
                    "anyOf": [
                      {
                        "type": "string",
                        "enum": [
                          "RUNNING"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "SUCCEEDED"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "FAILED"
                        ]
                      }
                    ]
                  },
                  "error_message": {
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "id",
                    "job_type",
                    "source",
                    "execution_id",
                    "initiator",
                    "params",
                    "status",
                    "error_message",
                    "started_at",
                    "finished_at"
                  ],
                  "properties": {
                    "id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "job_type": {
                      "anyOf": [
                        {
                          "type": "string",
                          "enum": [
                            "EXPORT_CAMPAIGNS"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "BULK_LAUNCH"
                          ]
                        }
                      ]
                    },
                    "source": {
                      "anyOf": [
                        {
                          "type": "string",
                          "enum": [
                            "SHEETS"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "LAMBDA"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "API"
                          ]
                        }
                      ]
                    },
                    "execution_id": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "initiator": {
                      "type": "string"
                    },
                    "params": {
                      "anyOf": [
                        {
                          "$comment": "json-value",
                          "description": "Arbitrary JSON value with nested arrays and objects."
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "status": {
                      "anyOf": [
                        {
                          "type": "string",
                          "enum": [
                            "RUNNING"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "SUCCEEDED"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "FAILED"
                          ]
                        }
                      ]
                    },
                    "error_message": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "started_at": {
                      "format": "date-time",
                      "type": "string"
                    },
                    "finished_at": {
                      "anyOf": [
                        {
                          "format": "date-time",
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "message"
                  ],
                  "properties": {
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "message"
                  ],
                  "properties": {
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "message"
                  ],
                  "properties": {
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/job-runs-events": {
      "get": {
        "operationId": "listJobRunsWithEvents",
        "summary": "Retrieve all job runs with their events",
        "tags": [
          "jobs"
        ],
        "description": "Returns a paginated list of job runs joined with their associated events; supports filters by job_run_status (RUNNING|SUCCEEDED|FAILED), job_run_type (EXPORT_CAMPAIGNS|BULK_LAUNCH) and date range.",
        "parameters": [
          {
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "enum": [
                    "RUNNING"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "SUCCEEDED"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "FAILED"
                  ]
                }
              ]
            },
            "in": "query",
            "name": "job_run_status",
            "required": false
          },
          {
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "enum": [
                    "EXPORT_CAMPAIGNS"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "BULK_LAUNCH"
                  ]
                }
              ]
            },
            "in": "query",
            "name": "job_run_type",
            "required": false
          },
          {
            "schema": {
              "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
              "type": "string"
            },
            "in": "query",
            "name": "from_date",
            "required": false,
            "description": "Date in YYYY-MM-DD (UTC)"
          },
          {
            "schema": {
              "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
              "type": "string"
            },
            "in": "query",
            "name": "to_date",
            "required": false,
            "description": "Date in YYYY-MM-DD (UTC)"
          },
          {
            "schema": {
              "minimum": 1,
              "maximum": 200,
              "type": "number"
            },
            "in": "query",
            "name": "limit",
            "required": false
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "cursor",
            "required": false
          }
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "items",
                    "next_cursor"
                  ],
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "additionalProperties": false,
                        "type": "object",
                        "required": [
                          "job_run_id",
                          "job_run_type",
                          "job_run_status",
                          "job_run_error_message",
                          "job_run_started_at",
                          "job_run_finished_at",
                          "event_id",
                          "event_status",
                          "event_metadata",
                          "event_created_at",
                          "event_error_message"
                        ],
                        "properties": {
                          "job_run_id": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "job_run_type": {
                            "anyOf": [
                              {
                                "type": "string",
                                "enum": [
                                  "EXPORT_CAMPAIGNS"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "BULK_LAUNCH"
                                ]
                              }
                            ]
                          },
                          "job_run_status": {
                            "anyOf": [
                              {
                                "type": "string",
                                "enum": [
                                  "RUNNING"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "SUCCEEDED"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "FAILED"
                                ]
                              }
                            ]
                          },
                          "job_run_error_message": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "job_run_started_at": {
                            "format": "date-time",
                            "type": "string"
                          },
                          "job_run_finished_at": {
                            "anyOf": [
                              {
                                "format": "date-time",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "event_id": {
                            "anyOf": [
                              {
                                "format": "uuid",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "event_status": {
                            "anyOf": [
                              {
                                "type": "string",
                                "enum": [
                                  "SUCCEEDED"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "FAILED"
                                ]
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "event_metadata": {
                            "anyOf": [
                              {
                                "$comment": "json-value",
                                "description": "Arbitrary JSON value with nested arrays and objects."
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "event_created_at": {
                            "anyOf": [
                              {
                                "format": "date-time",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "event_error_message": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          }
                        }
                      }
                    },
                    "next_cursor": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "message"
                  ],
                  "properties": {
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "message"
                  ],
                  "properties": {
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/campaigns/manual-conversions": {
      "post": {
        "operationId": "postCampaignsManualConversions",
        "summary": "Manually log a conversion and send it to Meta Conversions API",
        "tags": [
          "campaigns"
        ],
        "description": "Creates an audit row and forwards the event to Meta's Conversions API using the target ad account's own pixel and access token. Meta attributes the event by its own signal-matching, not by the campaign/adset/ad IDs passed here — those are stored for audit only.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "ad_account_id",
                  "campaign_id",
                  "event_name",
                  "event_time"
                ],
                "properties": {
                  "ad_account_id": {
                    "maxLength": 50,
                    "description": "Meta Ad Account ID owning the pixel used to send the event.",
                    "type": "string"
                  },
                  "campaign_id": {
                    "maxLength": 50,
                    "description": "Meta Campaign ID, stored for audit only — Meta does not attribute by this field.",
                    "type": "string"
                  },
                  "adset_id": {
                    "maxLength": 50,
                    "description": "Meta Adset ID, stored for audit only.",
                    "type": "string"
                  },
                  "ad_id": {
                    "maxLength": 50,
                    "description": "Meta Ad ID, stored for audit only.",
                    "type": "string"
                  },
                  "event_name": {
                    "anyOf": [
                      {
                        "type": "string",
                        "enum": [
                          "Purchase"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "Lead"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "CompleteRegistration"
                        ]
                      }
                    ]
                  },
                  "event_time": {
                    "format": "date-time",
                    "description": "ISO 8601 timestamp of when the conversion happened. Must not be in the future.",
                    "type": "string"
                  },
                  "value": {
                    "minimum": 0,
                    "maximum": 1000000,
                    "description": "Monetary value of the conversion.",
                    "type": "number"
                  },
                  "currency": {
                    "minLength": 3,
                    "maxLength": 3,
                    "description": "ISO 4217 currency code, e.g. EUR.",
                    "type": "string"
                  },
                  "customer_email": {
                    "format": "email",
                    "maxLength": 255,
                    "description": "Customer email. Hashed server-side before use; never persisted in plaintext.",
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "201": {
            "description": "Resource created",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "id",
                    "status",
                    "meta_event_id"
                  ],
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "status": {
                      "anyOf": [
                        {
                          "type": "string",
                          "enum": [
                            "sent"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "failed"
                          ]
                        }
                      ]
                    },
                    "meta_event_id": {
                      "type": "string"
                    },
                    "error_message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "422": {
            "description": "Unprocessable entity - semantic validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/meta-account-verification-blocks": {
      "get": {
        "operationId": "getApiV1MetaAccountVerificationBlocks",
        "summary": "List Meta account verification blocks for the team",
        "tags": [
          "meta-account-verification"
        ],
        "description": "Returns the team-shared Meta verification-block cases visible to the authenticated user, scoped to the teams they belong to. Defaults to open cases; pass status=resolved for history.",
        "parameters": [
          {
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "enum": [
                    "open"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "resolved"
                  ]
                }
              ]
            },
            "in": "query",
            "name": "status",
            "required": false,
            "description": "Filter by case status. Omit to return all statuses."
          }
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "blocks"
                  ],
                  "properties": {
                    "blocks": {
                      "type": "array",
                      "items": {
                        "additionalProperties": false,
                        "type": "object",
                        "required": [
                          "id",
                          "account_id",
                          "account_name",
                          "business_id",
                          "profile_name",
                          "profile_user_id",
                          "status",
                          "operation_type",
                          "error_message",
                          "occurrences",
                          "first_seen_at",
                          "last_seen_at"
                        ],
                        "properties": {
                          "id": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "account_id": {
                            "type": "string"
                          },
                          "account_name": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "business_id": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "profile_name": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "profile_user_id": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "status": {
                            "type": "string"
                          },
                          "operation_type": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "error_message": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "occurrences": {
                            "type": "integer"
                          },
                          "first_seen_at": {
                            "format": "date-time",
                            "type": "string"
                          },
                          "last_seen_at": {
                            "format": "date-time",
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/meta-account-verification-blocks/{id}/resolve": {
      "post": {
        "operationId": "postApiV1MetaAccountVerificationBlocksByIdResolve",
        "summary": "Resolve a single Meta account verification block",
        "tags": [
          "meta-account-verification"
        ],
        "description": "Marks the verification-block case resolved for the whole team (trust-based, no Meta probe). The case's team is authorized against the caller's full membership set; an unknown or cross-team id returns 404. The next real Meta error on the account reopens the case and re-notifies.",
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "path",
            "name": "id",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "id",
                    "outcome"
                  ],
                  "properties": {
                    "id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "outcome": {
                      "anyOf": [
                        {
                          "type": "string",
                          "enum": [
                            "resolved"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "not_found"
                          ]
                        },
                        {
                          "type": "string",
                          "enum": [
                            "already_resolved"
                          ]
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/meta-account-verification-blocks/resolve": {
      "post": {
        "operationId": "postApiV1MetaAccountVerificationBlocksResolve",
        "summary": "Resolve multiple Meta account verification blocks",
        "tags": [
          "meta-account-verification"
        ],
        "description": "Resolves several verification-block cases in one call (trust-based, no Meta probe). Each id is authorized against the caller membership set; the response reports a per-id outcome (resolved | already_resolved | not_found) without leaking cross-team existence.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "ids"
                ],
                "properties": {
                  "ids": {
                    "minItems": 1,
                    "maxItems": 200,
                    "type": "array",
                    "items": {
                      "format": "uuid",
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "results"
                  ],
                  "properties": {
                    "results": {
                      "type": "array",
                      "items": {
                        "additionalProperties": false,
                        "type": "object",
                        "required": [
                          "id",
                          "outcome"
                        ],
                        "properties": {
                          "id": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "outcome": {
                            "anyOf": [
                              {
                                "type": "string",
                                "enum": [
                                  "resolved"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "not_found"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "already_resolved"
                                ]
                              }
                            ]
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/meta/sync/ad-accounts": {
      "get": {
        "operationId": "getMetaSyncAdAccounts",
        "summary": "Refresh ad account from a sheet id",
        "tags": [
          "meta"
        ],
        "description": "Refreshes Meta Ad Account data associated with the provided sheet ID.",
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "sheet_id",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "status"
                  ],
                  "properties": {
                    "status": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/meta/ad-accounts": {
      "post": {
        "operationId": "postMetaAdAccounts",
        "summary": "Assign Meta Ad Accounts to Users",
        "tags": [
          "meta"
        ],
        "description": "Assigns Meta Ad Accounts to users based on the provided data. Uses the authenticated user's session ID.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "sheet_id",
                  "ad_accounts"
                ],
                "properties": {
                  "sheet_id": {
                    "description": "The ID of the sheet containing user data.",
                    "type": "string"
                  },
                  "ad_accounts": {
                    "description": "An array of Meta Ad Accounts to be assigned to users.",
                    "type": "array",
                    "items": {
                      "additionalProperties": false,
                      "type": "object",
                      "required": [
                        "id",
                        "business_id"
                      ],
                      "properties": {
                        "id": {
                          "description": "The ID of the Meta Ad Account.",
                          "type": "string"
                        },
                        "business_id": {
                          "description": "The business ID associated with the Ad Account.",
                          "type": "string"
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "status"
                  ],
                  "properties": {
                    "status": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/meta/ad-accounts/unassign": {
      "post": {
        "operationId": "postMetaAdAccountsUnassign",
        "summary": "Unassign (disconnect) specific Meta Ad Accounts",
        "tags": [
          "meta"
        ],
        "description": "Disconnects specific Meta Ad Accounts based on the provided list. Uses the authenticated user's session ID.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "sheet_id",
                  "ad_accounts"
                ],
                "properties": {
                  "sheet_id": {
                    "description": "The ID of the sheet containing user data.",
                    "type": "string"
                  },
                  "ad_accounts": {
                    "description": "An array of Meta Ad Accounts to be assigned to users.",
                    "type": "array",
                    "items": {
                      "additionalProperties": false,
                      "type": "object",
                      "required": [
                        "id",
                        "business_id"
                      ],
                      "properties": {
                        "id": {
                          "description": "The ID of the Meta Ad Account.",
                          "type": "string"
                        },
                        "business_id": {
                          "description": "The business ID associated with the Ad Account.",
                          "type": "string"
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "status"
                  ],
                  "properties": {
                    "status": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/meta/ad-account/relaunch": {
      "post": {
        "operationId": "postMetaAdAccountRelaunch",
        "summary": "Relaunch Meta Ad Accounts",
        "tags": [
          "meta"
        ],
        "description": "Retries the creation of Meta ads for the specified ad accounts. Useful when previous ad creation attempts have failed.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "sheet_id",
                  "ad_accounts"
                ],
                "properties": {
                  "sheet_id": {
                    "description": "The ID of the sheet containing user data.",
                    "type": "string"
                  },
                  "ad_accounts": {
                    "description": "Meta Ad Accounts with index.",
                    "type": "array",
                    "items": {
                      "additionalProperties": false,
                      "type": "object",
                      "required": [
                        "ad_account_id",
                        "index"
                      ],
                      "properties": {
                        "ad_account_id": {
                          "type": "string"
                        },
                        "index": {
                          "description": "Índex in sheet for ad account.",
                          "type": "string"
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "status"
                  ],
                  "properties": {
                    "status": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/meta/sync/catalogs": {
      "get": {
        "operationId": "getMetaSyncCatalogs",
        "summary": "Sync catalog data from a sheet id",
        "tags": [
          "meta"
        ],
        "description": "Triggers synchronization of Meta Product Catalogs for the provided sheet ID.",
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "sheet_id",
            "required": true
          },
          {
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "enum": [
                    "meta"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "google"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "tiktok"
                  ]
                }
              ]
            },
            "in": "query",
            "name": "platform",
            "required": false
          }
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "status"
                  ],
                  "properties": {
                    "status": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/meta/sync/fan-pages": {
      "get": {
        "operationId": "getMetaSyncFanPages",
        "summary": "Sync fan page data from a sheet id",
        "tags": [
          "meta"
        ],
        "description": "Triggers synchronization of Meta Fan Pages for the provided sheet ID from the Meta API.",
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "sheet_id",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "status"
                  ],
                  "properties": {
                    "status": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/meta/fan-pages": {
      "post": {
        "operationId": "postMetaFanPages",
        "summary": "Assign Meta Fan Pages to Users",
        "tags": [
          "meta"
        ],
        "description": "Assigns Meta Fan Pages to users based on the provided data. Uses the authenticated user's session ID.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "sheet_id",
                  "fan_pages"
                ],
                "properties": {
                  "sheet_id": {
                    "description": "The ID of the sheet containing user data.",
                    "type": "string"
                  },
                  "fan_pages": {
                    "description": "An array of Meta Fan Pages to be assigned to users.",
                    "type": "array",
                    "items": {
                      "additionalProperties": false,
                      "type": "object",
                      "required": [
                        "id",
                        "business_id"
                      ],
                      "properties": {
                        "id": {
                          "description": "The ID of the Meta Fan Page.",
                          "type": "string"
                        },
                        "name": {
                          "description": "The name of the Meta Fan Page.",
                          "type": "string"
                        },
                        "business_id": {
                          "description": "The business ID associated with the Fan Page.",
                          "type": "string"
                        },
                        "business_name": {
                          "description": "The business name associated with the Ad Account.",
                          "type": "string"
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "properties": {}
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/meta/fan-pages/unassign": {
      "post": {
        "operationId": "postMetaFanPagesUnassign",
        "summary": "Unassign Fan Pages",
        "tags": [
          "meta"
        ],
        "description": "Disconnects specific Meta Fan Pages from the user session based on the provided list.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "sheet_id",
                  "fan_pages"
                ],
                "properties": {
                  "sheet_id": {
                    "description": "The ID of the sheet containing user data.",
                    "type": "string"
                  },
                  "fan_pages": {
                    "description": "An array of Meta Fan Pages to be assigned to users.",
                    "type": "array",
                    "items": {
                      "additionalProperties": false,
                      "type": "object",
                      "required": [
                        "id",
                        "business_id"
                      ],
                      "properties": {
                        "id": {
                          "description": "The ID of the Meta Fan Page.",
                          "type": "string"
                        },
                        "name": {
                          "description": "The name of the Meta Fan Page.",
                          "type": "string"
                        },
                        "business_id": {
                          "description": "The business ID associated with the Fan Page.",
                          "type": "string"
                        },
                        "business_name": {
                          "description": "The business name associated with the Ad Account.",
                          "type": "string"
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "status"
                  ],
                  "properties": {
                    "status": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/meta/login": {
      "get": {
        "operationId": "getMetaLogin",
        "summary": "Redirect to Meta login",
        "tags": [
          "meta"
        ],
        "description": "Redirects the user to the Meta login page for authentication. Uses the authenticated user session. The destination workspace team is signed into the OAuth state (active team scope, else primary team).",
        "parameters": [
          {
            "schema": {
              "type": "boolean"
            },
            "in": "query",
            "name": "confirm_move",
            "required": false,
            "description": "Confirm moving Meta ad accounts already assigned to another workspace of the organization into the active workspace. Without confirmation, the OAuth callback redirects with code=ACCOUNT_ALREADY_ASSIGNED."
          },
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "header",
            "name": "x-team-id",
            "required": false,
            "description": "Destination workspace team id."
          }
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "302": {
            "description": "Redirect"
          },
          "400": {
            "description": "Explicit destination workspace required: send the x-team-id header or activate a team scope for this operation.",
            "content": {
              "application/json": {
                "schema": {
                  "description": "Explicit destination workspace required: send the x-team-id header or activate a team scope for this operation.",
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "SCOPE_TEAM_REQUIRED"
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/meta/login-url": {
      "get": {
        "operationId": "getMetaLoginUrl",
        "summary": "Get Meta login URL",
        "tags": [
          "meta"
        ],
        "description": "Returns the Meta OAuth login URL for the current user session. The destination workspace team (x-team-id header or active team scope) is signed into the OAuth state; requests without an explicit team get 400 SCOPE_TEAM_REQUIRED.",
        "parameters": [
          {
            "schema": {
              "type": "boolean"
            },
            "in": "query",
            "name": "confirm_move",
            "required": false,
            "description": "Confirm moving Meta ad accounts already assigned to another workspace of the organization into the active workspace. Without confirmation, the OAuth callback redirects with code=ACCOUNT_ALREADY_ASSIGNED."
          },
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "header",
            "name": "x-team-id",
            "required": false,
            "description": "Destination workspace team id."
          }
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "url"
                  ],
                  "properties": {
                    "url": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Explicit destination workspace required: send the x-team-id header or activate a team scope for this operation.",
            "content": {
              "application/json": {
                "schema": {
                  "description": "Explicit destination workspace required: send the x-team-id header or activate a team scope for this operation.",
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "SCOPE_TEAM_REQUIRED"
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/meta/extension.zip": {
      "get": {
        "operationId": "getMetaExtensionZip",
        "summary": "Download the auto-connect Chrome extension",
        "tags": [
          "meta"
        ],
        "description": "Returns a .zip of the \"Wevion Connect\" Chrome extension, pre-configured with this workspace OAuth link. Install it in Chrome or on any Chromium antidetect browser (AdsPower, Multilogin, GoLogin, Dolphin, ...) and open the profiles: the Facebook accounts connect to this workspace automatically.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "ZIP archive of the pre-configured \"Wevion Connect\" Chrome extension (application/zip).",
            "content": {
              "application/json": {
                "schema": {
                  "format": "binary",
                  "description": "ZIP archive of the pre-configured \"Wevion Connect\" Chrome extension (application/zip).",
                  "type": "string"
                }
              }
            }
          },
          "400": {
            "description": "Explicit destination workspace required: send the x-team-id header or activate a team scope for this operation.",
            "content": {
              "application/json": {
                "schema": {
                  "description": "Explicit destination workspace required: send the x-team-id header or activate a team scope for this operation.",
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "SCOPE_TEAM_REQUIRED"
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized — a valid session is required.",
            "content": {
              "application/json": {
                "schema": {
                  "description": "Unauthorized — a valid session is required.",
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/meta/login-callback": {
      "get": {
        "operationId": "getMetaLoginCallback",
        "summary": "Handle Meta login callback",
        "tags": [
          "meta"
        ],
        "description": "Handles the OAuth callback from Meta. Exchanges code for a long-lived token, stores it, checks discovered ad accounts for cross-workspace assignment conflicts, and starts post-login sync. If an account is already assigned to another workspace of the organization, the browser is redirected with code=ACCOUNT_ALREADY_ASSIGNED unless the signed OAuth state carried confirm_move=true.",
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "code",
            "required": false
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "state",
            "required": false
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "error",
            "required": false
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "error_description",
            "required": false
          }
        ],
        "responses": {
          "302": {
            "description": "Redirect"
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/meta/sync/pixels": {
      "get": {
        "operationId": "getMetaSyncPixels",
        "summary": "Sync pixel data from a sheet id",
        "tags": [
          "meta"
        ],
        "description": "Triggers synchronization of Meta Pixels for the provided sheet ID from the Meta API.",
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "sheet_id",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "status"
                  ],
                  "properties": {
                    "status": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/meta/pixels": {
      "post": {
        "operationId": "postMetaPixels",
        "summary": "Assign Meta Pixels to Ad Accounts",
        "tags": [
          "meta"
        ],
        "description": "Assigns Meta Pixels to Ad Accounts based on the provided data. Uses the authenticated user's session ID.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "sheet_id",
                  "pixels"
                ],
                "properties": {
                  "sheet_id": {
                    "type": "string"
                  },
                  "pixels": {
                    "description": "An array of Meta Pixels to be assigned to Ad Accounts.",
                    "type": "array",
                    "items": {
                      "additionalProperties": false,
                      "type": "object",
                      "required": [
                        "pixel_id",
                        "business_id"
                      ],
                      "properties": {
                        "pixel_id": {
                          "description": "The ID of the Meta Pixel.",
                          "type": "string"
                        },
                        "business_id": {
                          "description": "The business ID associated with the Pixel.",
                          "type": "string"
                        },
                        "name": {
                          "description": "The name of the Meta Pixel.",
                          "type": "string"
                        },
                        "ad_account_ids": {
                          "type": "array",
                          "items": {
                            "description": "The Ad Account IDs to which the Pixel will be assigned.",
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "properties": {}
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/meta/postback/conversion": {
      "get": {
        "operationId": "getMetaPostbackConversion",
        "summary": "Save meta postback conversion",
        "tags": [
          "meta"
        ],
        "description": "Public endpoint called by external affiliate networks to report conversions.",
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "transaction_id",
            "required": true,
            "description": "The unique identifier for the transaction."
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "payout",
            "required": true,
            "description": "The payout amount for the conversion, as a decimal string. Values outside 0 to 1,000,000 are rejected; a value that is not a number (e.g. an unsubstituted tracker macro) is accepted and stored without an amount."
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "currency",
            "required": false,
            "description": "ISO currency code for the payout."
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "campaign_id",
            "required": false,
            "description": "The Meta campaign ID associated with the conversion."
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "adset_id",
            "required": false,
            "description": "The Meta ad set ID associated with the conversion."
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "ad_id",
            "required": false,
            "description": "The Meta ad ID associated with the conversion."
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "sheet_id",
            "required": true,
            "description": "The ID of the sheet where conversion data is recorded."
          },
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "query",
            "name": "team_id",
            "required": false,
            "description": "The workspace team that owns this postback URL."
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "status"
                  ],
                  "properties": {
                    "status": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/meta/sync/users": {
      "get": {
        "operationId": "getMetaSyncUsers",
        "summary": "Refresh user from a sheet id",
        "tags": [
          "meta"
        ],
        "description": "Refreshes Meta Business token status and user names and business ids, all associated with the provided sheet ID.",
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "sheet_id",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "status",
                    "worker_run_ids"
                  ],
                  "properties": {
                    "status": {
                      "type": "string"
                    },
                    "worker_run_ids": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/meta/users": {
      "delete": {
        "operationId": "deleteMetaUsers",
        "summary": "Remove users from a sheet id",
        "tags": [
          "meta"
        ],
        "description": "Remove users connection from the database and refreshes Meta Business token status",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "sheet_id",
                  "users"
                ],
                "properties": {
                  "sheet_id": {
                    "type": "string"
                  },
                  "users": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "status"
                  ],
                  "properties": {
                    "status": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/meta/tokens": {
      "get": {
        "operationId": "getMetaTokens",
        "summary": "Get validated tokens from ad account fan page and sheet id",
        "tags": [
          "meta"
        ],
        "description": "Get validated list of tokens from ad account fan page and sheet id.",
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "sheet_id",
            "required": true
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "ad_account_id",
            "required": true
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "fan_page_id",
            "required": false
          }
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "required": [
                      "name",
                      "access_token"
                    ],
                    "properties": {
                      "name": {
                        "type": "string"
                      },
                      "access_token": {
                        "type": "string"
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/outbrain/connect-token": {
      "post": {
        "operationId": "outbrainConnectToken",
        "summary": "Connect Outbrain via pasted API token (no OAuth)",
        "tags": [
          "outbrain"
        ],
        "description": "Validates a manually-pasted Outbrain Amplify API token by calling /marketers, then persists it for the current session, stamping the destination workspace team (x-team-id header or active team scope — 400 SCOPE_TEAM_REQUIRED without it). Marketers already assigned to another workspace of the organization answer 409 ACCOUNT_ALREADY_ASSIGNED unless confirm_move=true. The token is valid 30 days; the buyer must regenerate and re-paste before expiry.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "token"
                ],
                "properties": {
                  "token": {
                    "minLength": 16,
                    "description": "Outbrain Amplify API token (OB-TOKEN-V1).",
                    "type": "string"
                  },
                  "confirm_move": {
                    "description": "Confirm moving marketers already assigned to another workspace of the organization into the active one (409 ACCOUNT_ALREADY_ASSIGNED otherwise). The move reassigns every row of each marketer and re-stamps its historical analytics.",
                    "type": "boolean"
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "header",
            "name": "x-team-id",
            "required": false,
            "description": "Destination workspace team id."
          }
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "success",
                    "token_expires_at",
                    "marketers"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "token_expires_at": {
                      "format": "date-time",
                      "type": "string"
                    },
                    "marketers": {
                      "type": "array",
                      "items": {
                        "additionalProperties": false,
                        "type": "object",
                        "required": [
                          "id",
                          "name",
                          "currency",
                          "timezone"
                        ],
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "name": {
                            "type": "string"
                          },
                          "currency": {
                            "type": "string"
                          },
                          "timezone": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Explicit destination workspace required: send the x-team-id header or activate a team scope for this operation.",
            "content": {
              "application/json": {
                "schema": {
                  "description": "Explicit destination workspace required: send the x-team-id header or activate a team scope for this operation.",
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "SCOPE_TEAM_REQUIRED"
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "The external ad account is already assigned to another workspace of your organization. Retry with confirm_move=true to move it (and its historical analytics) into the active workspace.",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "description": "The external ad account is already assigned to another workspace of your organization. Retry with confirm_move=true to move it (and its historical analytics) into the active workspace.",
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message",
                    "code",
                    "current_team_id",
                    "current_workspace_name",
                    "external_account_id",
                    "platform"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "ACCOUNT_ALREADY_ASSIGNED"
                      ]
                    },
                    "current_team_id": {
                      "format": "uuid",
                      "type": "string"
                    },
                    "current_workspace_name": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "external_account_id": {
                      "type": "string"
                    },
                    "platform": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/outbrain/ad-accounts/sync": {
      "post": {
        "operationId": "outbrainSyncAdAccounts",
        "summary": "Re-sync Outbrain marketer list for current session",
        "tags": [
          "outbrain"
        ],
        "description": "Queues a refresh of Outbrain marketers, conversion events, and campaigns for the authenticated session after verifying an active token exists. The resolved team (x-team-id header, active team scope, or primary team) is used to fill missing workspace assignments; already-assigned marketers are never moved by a re-sync.",
        "parameters": [
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "header",
            "name": "x-team-id",
            "required": false,
            "description": "Destination workspace team id."
          }
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "success",
                    "queued"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "queued": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/outbrain/conversion-goals": {
      "get": {
        "operationId": "outbrainListConversionGoals",
        "summary": "List Outbrain conversion goals for a marketer",
        "tags": [
          "outbrain"
        ],
        "description": "Returns cached conversion goals for an Outbrain marketer, falling back to a live Outbrain API fetch when the local cache is empty.",
        "parameters": [
          {
            "schema": {
              "minLength": 1,
              "type": "string"
            },
            "in": "query",
            "name": "account_id",
            "required": true,
            "description": "Outbrain marketer id."
          }
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "conversions"
                  ],
                  "properties": {
                    "conversions": {
                      "type": "array",
                      "items": {
                        "additionalProperties": true,
                        "type": "object",
                        "required": [
                          "id",
                          "name"
                        ],
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "name": {
                            "type": "string"
                          },
                          "type": {
                            "type": "string"
                          },
                          "category": {
                            "type": "string"
                          },
                          "status": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/outbrain/campaigns/{campaignId}/toggle": {
      "post": {
        "operationId": "outbrainToggleCampaign",
        "summary": "Pause / resume an Outbrain campaign",
        "tags": [
          "outbrain"
        ],
        "description": "Queues an Outbrain campaign enable or pause action for the given campaign id and marketer account.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "account_id",
                  "enabled"
                ],
                "properties": {
                  "account_id": {
                    "minLength": 1,
                    "type": "string"
                  },
                  "enabled": {
                    "type": "boolean"
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "schema": {
              "minLength": 1,
              "type": "string"
            },
            "in": "path",
            "name": "campaignId",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "success",
                    "queued"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "queued": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/outbrain/campaigns/{campaignId}/budget": {
      "post": {
        "operationId": "outbrainEditCampaignBudget",
        "summary": "Update budget amount for an Outbrain campaign",
        "tags": [
          "outbrain"
        ],
        "description": "Queues a budget update for an Outbrain campaign after resolving the cached budget entity id from the local campaign cache.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "account_id",
                  "amount"
                ],
                "properties": {
                  "account_id": {
                    "minLength": 1,
                    "type": "string"
                  },
                  "amount": {
                    "exclusiveMinimum": 0,
                    "type": "number"
                  },
                  "pacing": {
                    "anyOf": [
                      {
                        "type": "string",
                        "enum": [
                          "DAILY"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "MONTHLY"
                        ]
                      },
                      {
                        "type": "string",
                        "enum": [
                          "ENTIRE"
                        ]
                      }
                    ]
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "schema": {
              "minLength": 1,
              "type": "string"
            },
            "in": "path",
            "name": "campaignId",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "success",
                    "queued"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "queued": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/outbrain/disconnect": {
      "post": {
        "operationId": "outbrainDisconnect",
        "summary": "Disconnect Outbrain — revoke stored token and soft-delete marketers",
        "tags": [
          "outbrain"
        ],
        "description": "Disconnects the current session from Outbrain by revoking the stored token state and soft-deleting cached marketers.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object",
                  "required": [
                    "success"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/snapchat/login-url": {
      "get": {
        "operationId": "getSnapchatLoginUrl",
        "summary": "Get Snapchat OAuth login URL",
        "tags": [
          "snapchat"
        ],
        "description": "Generates a signed Snapchat OAuth authorization URL for the authenticated user. The destination workspace team (x-team-id header or active team scope) is signed into the OAuth state; requests without an explicit team get 400 SCOPE_TEAM_REQUIRED.",
        "parameters": [
          {
            "schema": {
              "type": "boolean"
            },
            "in": "query",
            "name": "confirm_move",
            "required": false,
            "description": "Confirm moving Snapchat ad accounts already assigned to another workspace of the organization into the active workspace. Without confirmation, the OAuth callback reports ACCOUNT_ALREADY_ASSIGNED."
          },
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "header",
            "name": "x-team-id",
            "required": false,
            "description": "Destination workspace team id."
          }
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "url"
                  ],
                  "properties": {
                    "url": {
                      "format": "uri",
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Explicit destination workspace required: send the x-team-id header or activate a team scope for this operation.",
            "content": {
              "application/json": {
                "schema": {
                  "description": "Explicit destination workspace required: send the x-team-id header or activate a team scope for this operation.",
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "SCOPE_TEAM_REQUIRED"
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "integer"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/snapchat/auth/url": {
      "get": {
        "operationId": "getSnapchatAuthUrl",
        "summary": "Get Snapchat OAuth authorization URL",
        "tags": [
          "snapchat"
        ],
        "description": "Compatibility endpoint that returns the same signed Snapchat OAuth authorization URL. Requires an explicit destination team (x-team-id header or active team scope); 400 SCOPE_TEAM_REQUIRED otherwise.",
        "parameters": [
          {
            "schema": {
              "type": "boolean"
            },
            "in": "query",
            "name": "confirm_move",
            "required": false,
            "description": "Confirm moving Snapchat ad accounts already assigned to another workspace of the organization into the active workspace. Without confirmation, the OAuth callback reports ACCOUNT_ALREADY_ASSIGNED."
          },
          {
            "schema": {
              "format": "uuid",
              "type": "string"
            },
            "in": "header",
            "name": "x-team-id",
            "required": false,
            "description": "Destination workspace team id."
          }
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "url"
                  ],
                  "properties": {
                    "url": {
                      "format": "uri",
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Explicit destination workspace required: send the x-team-id header or activate a team scope for this operation.",
            "content": {
              "application/json": {
                "schema": {
                  "description": "Explicit destination workspace required: send the x-team-id header or activate a team scope for this operation.",
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string",
                      "enum": [
                        "SCOPE_TEAM_REQUIRED"
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "integer"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/snapchat/login-callback": {
      "get": {
        "operationId": "handleSnapchatLoginCallback",
        "summary": "Handle Snapchat OAuth callback",
        "tags": [
          "snapchat"
        ],
        "description": "Consumes the Snapchat OAuth callback, stores refreshed tokens, dispatches account sync, and returns the popup-closing HTML response. If discovered ad accounts belong to another workspace of the organization, the callback reports ACCOUNT_ALREADY_ASSIGNED unless the signed OAuth state carried confirm_move=true.",
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "code",
            "required": false
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "state",
            "required": false
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "error",
            "required": false
          }
        ],
        "responses": {
          "200": {
            "description": "Small HTML page that closes the OAuth popup after success or provider callback failure.",
            "content": {
              "application/json": {
                "schema": {
                  "description": "Small HTML page that closes the OAuth popup after success or provider callback failure.",
                  "type": "string"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error",
                    "message",
                    "statusCode"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "integer"
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ]
      }
    },
    "/api/v1/taboola/insights/backfill": {
      "post": {
        "operationId": "taboolaSyncInsights",
        "summary": "Backfill historical Taboola Ads insights",
        "tags": [
          "taboola"
        ],
        "description": "Triggers an insights backfill for the last N days (default 30, max 365). Splits the date range into 30-day chunks distributed via SQS workers. Mirrors `/api/v1/insights/backfill` (Meta).",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "properties": {
                  "days": {
                    "minimum": 1,
                    "maximum": 365,
                    "default": 30,
                    "description": "Lookback window in days (default 30, max 365).",
                    "type": "number"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Insights backfill dispatch result. Mirrors `/api/v1/insights/backfill`.",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "description": "Insights backfill dispatch result. Mirrors `/api/v1/insights/backfill`.",
                  "type": "object",
                  "required": [
                    "status"
                  ],
                  "properties": {
                    "status": {
                      "type": "string"
                    },
                    "worker_run_id": {
                      "type": "string"
                    },
                    "days": {
                      "type": "number"
                    },
                    "chunks": {
                      "type": "number"
                    },
                    "from_date": {
                      "type": "string"
                    },
                    "to_date": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/taboola/campaigns/bulk-delete": {
      "post": {
        "operationId": "taboolaBulkDeleteCampaigns",
        "summary": "Bulk-delete every Taboola campaign for an account",
        "tags": [
          "taboola"
        ],
        "description": "Asynchronously removes every campaign on the supplied Taboola account via the DELETE_CAMPAIGNS_BY_TABOOLA_ACCOUNT worker. Returns 202 with the worker_run_id; track progress via `/api/v1/sync/status`.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "account_id"
                ],
                "properties": {
                  "account_id": {
                    "minLength": 1,
                    "description": "Taboola account id.",
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "202": {
            "description": "Accepted - processing asynchronously",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "success",
                    "queued",
                    "worker_run_id"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "queued": {
                      "type": "boolean"
                    },
                    "worker_run_id": {
                      "format": "uuid",
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/taboola/campaigns/{campaignId}": {
      "delete": {
        "operationId": "taboolaDeleteCampaign",
        "summary": "Delete a single Taboola campaign",
        "tags": [
          "taboola"
        ],
        "description": "Synchronously removes a single Taboola campaign.",
        "parameters": [
          {
            "schema": {
              "minLength": 1,
              "type": "string"
            },
            "in": "query",
            "name": "account_id",
            "required": true,
            "description": "Taboola account id."
          },
          {
            "schema": {
              "minLength": 1,
              "type": "string"
            },
            "in": "path",
            "name": "campaignId",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Synchronous success ack - additional fields may be present.",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "description": "Synchronous success ack - additional fields may be present.",
                  "type": "object",
                  "required": [
                    "success"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/taboola/campaigns/{campaignId}/items/{itemId}": {
      "delete": {
        "operationId": "taboolaDeleteCampaignItem",
        "summary": "Delete a Taboola campaign item (Wevion ad level)",
        "tags": [
          "taboola"
        ],
        "description": "Synchronously removes a single Taboola campaign_item (Wevion `ad` level for Taboola). The parent campaign id is required by Taboola.",
        "parameters": [
          {
            "schema": {
              "minLength": 1,
              "type": "string"
            },
            "in": "query",
            "name": "account_id",
            "required": true,
            "description": "Taboola account id."
          },
          {
            "schema": {
              "minLength": 1,
              "type": "string"
            },
            "in": "path",
            "name": "campaignId",
            "required": true
          },
          {
            "schema": {
              "minLength": 1,
              "type": "string"
            },
            "in": "path",
            "name": "itemId",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Synchronous success ack - additional fields may be present.",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "description": "Synchronous success ack - additional fields may be present.",
                  "type": "object",
                  "required": [
                    "success"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/taboola/campaigns/{campaignId}/duplicate": {
      "post": {
        "operationId": "taboolaDuplicateCampaign",
        "summary": "Duplicate a Taboola campaign",
        "tags": [
          "taboola"
        ],
        "description": "Calls Taboola native /campaigns/:cid/duplicate/ to clone a campaign. Returns the new campaign id.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "account_id"
                ],
                "properties": {
                  "account_id": {
                    "minLength": 1,
                    "description": "Taboola account id.",
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "schema": {
              "minLength": 1,
              "type": "string"
            },
            "in": "path",
            "name": "campaignId",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "success",
                    "campaign_id"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "campaign_id": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/taboola/campaigns/{campaignId}/items/{itemId}/duplicate": {
      "post": {
        "operationId": "taboolaDuplicateCampaignItem",
        "summary": "Duplicate a Taboola campaign item (Wevion ad level)",
        "tags": [
          "taboola"
        ],
        "description": "Reads the source Taboola campaign_item and recreates it under the same campaign. Returns the new item id.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "account_id"
                ],
                "properties": {
                  "account_id": {
                    "minLength": 1,
                    "description": "Taboola account id.",
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "schema": {
              "minLength": 1,
              "type": "string"
            },
            "in": "path",
            "name": "campaignId",
            "required": true
          },
          {
            "schema": {
              "minLength": 1,
              "type": "string"
            },
            "in": "path",
            "name": "itemId",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "success",
                    "item_id"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "item_id": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/taboola/campaign-groups/{campaignGroupId}/toggle": {
      "post": {
        "operationId": "taboolaToggleCampaignGroup",
        "summary": "Pause / resume a Taboola campaign group",
        "tags": [
          "taboola"
        ],
        "description": "Enqueues a status flip on the TABOOLA_TOGGLE_ENTITY worker for the supplied campaign group.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "account_id",
                  "is_active"
                ],
                "properties": {
                  "account_id": {
                    "minLength": 1,
                    "type": "string"
                  },
                  "is_active": {
                    "type": "boolean"
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "schema": {
              "minLength": 1,
              "type": "string"
            },
            "in": "path",
            "name": "campaignGroupId",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Acknowledged enqueue (worker applies the change asynchronously).",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "description": "Acknowledged enqueue (worker applies the change asynchronously).",
                  "type": "object",
                  "required": [
                    "success",
                    "queued"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "queued": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/taboola/campaigns/{campaignId}/toggle": {
      "post": {
        "operationId": "taboolaToggleCampaign",
        "summary": "Pause / resume a Taboola campaign",
        "tags": [
          "taboola"
        ],
        "description": "Enqueues a status flip on the TABOOLA_TOGGLE_ENTITY worker for the supplied campaign.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "account_id",
                  "is_active"
                ],
                "properties": {
                  "account_id": {
                    "minLength": 1,
                    "type": "string"
                  },
                  "is_active": {
                    "type": "boolean"
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "schema": {
              "minLength": 1,
              "type": "string"
            },
            "in": "path",
            "name": "campaignId",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Acknowledged enqueue (worker applies the change asynchronously).",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "description": "Acknowledged enqueue (worker applies the change asynchronously).",
                  "type": "object",
                  "required": [
                    "success",
                    "queued"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "queued": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/taboola/campaigns/{campaignId}/items/{itemId}/toggle": {
      "post": {
        "operationId": "taboolaToggleCampaignItem",
        "summary": "Pause / resume a Taboola campaign item (Wevion ad level)",
        "tags": [
          "taboola"
        ],
        "description": "Enqueues a status flip on the TABOOLA_TOGGLE_ENTITY worker for the supplied campaign item.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "account_id",
                  "is_active"
                ],
                "properties": {
                  "account_id": {
                    "minLength": 1,
                    "type": "string"
                  },
                  "is_active": {
                    "type": "boolean"
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "schema": {
              "minLength": 1,
              "type": "string"
            },
            "in": "path",
            "name": "campaignId",
            "required": true
          },
          {
            "schema": {
              "minLength": 1,
              "type": "string"
            },
            "in": "path",
            "name": "itemId",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Acknowledged enqueue (worker applies the change asynchronously).",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "description": "Acknowledged enqueue (worker applies the change asynchronously).",
                  "type": "object",
                  "required": [
                    "success",
                    "queued"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "queued": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/tiktok/insights/backfill": {
      "post": {
        "operationId": "tiktokSyncInsights",
        "summary": "Backfill historical TikTok Ads insights",
        "tags": [
          "tiktok"
        ],
        "description": "Triggers an insights backfill either for the last N days (`days`, default 30, max 365) or for an explicit `from_date`/`to_date` window (max 365 days back, not in the future). The two forms are mutually exclusive and anything that cannot be honored is rejected with 400 instead of being clamped. The range is split into 7-day chunks distributed via SQS workers. An explicit window is honored exactly. A window reaching back before an incident is deliberately allowed - that is how the data is rebuilt - and the dispatched window plus chunk count are logged. Mirrors `/api/v1/insights/backfill` (Meta). 5-minute per-session debounce (`status: \"skipped\"`).",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "properties": {
                  "days": {
                    "minimum": 1,
                    "maximum": 365,
                    "description": "Lookback window in days, ending today (default 30, max 365). Mutually exclusive with from_date/to_date.",
                    "type": "number"
                  },
                  "from_date": {
                    "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
                    "description": "First day of the requested window (YYYY-MM-DD, UTC). Must be sent together with to_date, cannot be more than 365 days in the past, and is mutually exclusive with days.",
                    "type": "string"
                  },
                  "to_date": {
                    "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
                    "description": "Last day of the requested window (YYYY-MM-DD, UTC). Must be sent together with from_date and cannot be in the future.",
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Insights backfill dispatch result. Mirrors `/api/v1/insights/backfill`.",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "description": "Insights backfill dispatch result. Mirrors `/api/v1/insights/backfill`.",
                  "type": "object",
                  "required": [
                    "status"
                  ],
                  "properties": {
                    "status": {
                      "description": "`processing` when chunks were dispatched, `skipped` when debounced.",
                      "type": "string"
                    },
                    "worker_run_id": {
                      "type": "string"
                    },
                    "days": {
                      "description": "Effective lookback in days actually dispatched.",
                      "type": "number"
                    },
                    "chunks": {
                      "type": "number"
                    },
                    "from_date": {
                      "description": "First day of the EFFECTIVE dispatched window.",
                      "type": "string"
                    },
                    "to_date": {
                      "description": "Last day of the EFFECTIVE dispatched window.",
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Rejected request: the window could not be honored as asked.",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "description": "Rejected request: the window could not be honored as asked.",
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "statusCode": {
                      "type": "number"
                    },
                    "code": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/tiktok/campaigns/bulk-delete": {
      "post": {
        "operationId": "tiktokBulkDeleteCampaigns",
        "summary": "Bulk-delete every TikTok campaign for an advertiser",
        "tags": [
          "tiktok"
        ],
        "description": "Asynchronously removes every campaign on the supplied TikTok advertiser via the DELETE_CAMPAIGNS_BY_TIKTOK_ACCOUNT worker. Returns 202 with the worker_run_id; track progress via `/api/v1/sync/status`.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "advertiser_id"
                ],
                "properties": {
                  "advertiser_id": {
                    "minLength": 1,
                    "description": "TikTok advertiser id.",
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "202": {
            "description": "Accepted - processing asynchronously",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "success",
                    "queued",
                    "worker_run_id"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "queued": {
                      "type": "boolean"
                    },
                    "worker_run_id": {
                      "format": "uuid",
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/tiktok/campaigns/{campaignId}": {
      "delete": {
        "operationId": "tiktokDeleteCampaign",
        "summary": "Delete a single TikTok campaign",
        "tags": [
          "tiktok"
        ],
        "description": "Synchronously removes a single TikTok campaign via /campaign/status/update/.",
        "parameters": [
          {
            "schema": {
              "minLength": 1,
              "type": "string"
            },
            "in": "query",
            "name": "advertiser_id",
            "required": true,
            "description": "TikTok advertiser id."
          },
          {
            "schema": {
              "minLength": 1,
              "type": "string"
            },
            "in": "path",
            "name": "campaignId",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Synchronous success ack - additional fields may be present.",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "description": "Synchronous success ack - additional fields may be present.",
                  "type": "object",
                  "required": [
                    "success"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/tiktok/adgroups/{adgroupId}": {
      "delete": {
        "operationId": "tiktokDeleteAdGroup",
        "summary": "Delete a single TikTok ad group",
        "tags": [
          "tiktok"
        ],
        "description": "Synchronously removes a single TikTok ad group (Wevion adset level).",
        "parameters": [
          {
            "schema": {
              "minLength": 1,
              "type": "string"
            },
            "in": "query",
            "name": "advertiser_id",
            "required": true,
            "description": "TikTok advertiser id."
          },
          {
            "schema": {
              "minLength": 1,
              "type": "string"
            },
            "in": "path",
            "name": "adgroupId",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Synchronous success ack - additional fields may be present.",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "description": "Synchronous success ack - additional fields may be present.",
                  "type": "object",
                  "required": [
                    "success"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/tiktok/ads/{adId}": {
      "delete": {
        "operationId": "tiktokDeleteAd",
        "summary": "Delete a single TikTok ad",
        "tags": [
          "tiktok"
        ],
        "description": "Synchronously removes a single TikTok ad.",
        "parameters": [
          {
            "schema": {
              "minLength": 1,
              "type": "string"
            },
            "in": "query",
            "name": "advertiser_id",
            "required": true,
            "description": "TikTok advertiser id."
          },
          {
            "schema": {
              "minLength": 1,
              "type": "string"
            },
            "in": "path",
            "name": "adId",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Synchronous success ack - additional fields may be present.",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "description": "Synchronous success ack - additional fields may be present.",
                  "type": "object",
                  "required": [
                    "success"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/tiktok/campaigns/{campaignId}/duplicate": {
      "post": {
        "operationId": "tiktokDuplicateCampaign",
        "summary": "Duplicate a TikTok campaign (not supported)",
        "tags": [
          "tiktok"
        ],
        "description": "TikTok exposes no campaign copy endpoint in its Marketing API (duplication is only available in TikTok Ads Manager), so this route returns 400. Retained on the API surface until a manual deep-copy is implemented.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "advertiser_id"
                ],
                "properties": {
                  "advertiser_id": {
                    "minLength": 1,
                    "description": "TikTok advertiser id.",
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "schema": {
              "minLength": 1,
              "type": "string"
            },
            "in": "path",
            "name": "campaignId",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "success",
                    "campaign_id"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "campaign_id": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/tiktok/adgroups/{adgroupId}/duplicate": {
      "post": {
        "operationId": "tiktokDuplicateAdGroup",
        "summary": "Duplicate a TikTok ad group (not supported)",
        "tags": [
          "tiktok"
        ],
        "description": "TikTok exposes no ad group copy endpoint in its Marketing API (duplication is only available in TikTok Ads Manager), so this route returns 400.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "advertiser_id"
                ],
                "properties": {
                  "advertiser_id": {
                    "minLength": 1,
                    "description": "TikTok advertiser id.",
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "schema": {
              "minLength": 1,
              "type": "string"
            },
            "in": "path",
            "name": "adgroupId",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "success",
                    "adgroup_id"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "adgroup_id": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/tiktok/ads/{adId}/duplicate": {
      "post": {
        "operationId": "tiktokDuplicateAd",
        "summary": "Duplicate a TikTok ad (not supported)",
        "tags": [
          "tiktok"
        ],
        "description": "TikTok exposes no ad copy endpoint in its Marketing API (duplication is only available in TikTok Ads Manager), so this route returns 400.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "advertiser_id"
                ],
                "properties": {
                  "advertiser_id": {
                    "minLength": 1,
                    "description": "TikTok advertiser id.",
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "schema": {
              "minLength": 1,
              "type": "string"
            },
            "in": "path",
            "name": "adId",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "success",
                    "ad_id"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "ad_id": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/tiktok/campaigns/{campaignId}/toggle": {
      "post": {
        "operationId": "tiktokToggleCampaign",
        "summary": "Pause / resume a TikTok campaign",
        "tags": [
          "tiktok"
        ],
        "description": "Enqueues a status flip on the TIKTOK_TOGGLE_ENTITY worker for the supplied campaign.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "advertiser_id",
                  "is_active"
                ],
                "properties": {
                  "advertiser_id": {
                    "minLength": 1,
                    "type": "string"
                  },
                  "is_active": {
                    "type": "boolean"
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "schema": {
              "minLength": 1,
              "type": "string"
            },
            "in": "path",
            "name": "campaignId",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Acknowledged enqueue (worker applies the change asynchronously).",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "description": "Acknowledged enqueue (worker applies the change asynchronously).",
                  "type": "object",
                  "required": [
                    "success",
                    "queued"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "queued": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/tiktok/adgroups/{adgroupId}/toggle": {
      "post": {
        "operationId": "tiktokToggleAdGroup",
        "summary": "Pause / resume a TikTok ad group",
        "tags": [
          "tiktok"
        ],
        "description": "Enqueues a status flip on the TIKTOK_TOGGLE_ENTITY worker for the supplied ad group.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "advertiser_id",
                  "is_active"
                ],
                "properties": {
                  "advertiser_id": {
                    "minLength": 1,
                    "type": "string"
                  },
                  "is_active": {
                    "type": "boolean"
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "schema": {
              "minLength": 1,
              "type": "string"
            },
            "in": "path",
            "name": "adgroupId",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Acknowledged enqueue (worker applies the change asynchronously).",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "description": "Acknowledged enqueue (worker applies the change asynchronously).",
                  "type": "object",
                  "required": [
                    "success",
                    "queued"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "queued": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/tiktok/ads/{adId}/toggle": {
      "post": {
        "operationId": "tiktokToggleAd",
        "summary": "Pause / resume a TikTok ad",
        "tags": [
          "tiktok"
        ],
        "description": "Enqueues a status flip on the TIKTOK_TOGGLE_ENTITY worker for the supplied ad.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "advertiser_id",
                  "is_active"
                ],
                "properties": {
                  "advertiser_id": {
                    "minLength": 1,
                    "type": "string"
                  },
                  "is_active": {
                    "type": "boolean"
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "schema": {
              "minLength": 1,
              "type": "string"
            },
            "in": "path",
            "name": "adId",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Acknowledged enqueue (worker applies the change asynchronously).",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "description": "Acknowledged enqueue (worker applies the change asynchronously).",
                  "type": "object",
                  "required": [
                    "success",
                    "queued"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "queued": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/tiktok/campaigns/{campaignId}/budget": {
      "post": {
        "operationId": "tiktokEditCampaignBudget",
        "summary": "Edit a TikTok campaign budget",
        "tags": [
          "tiktok"
        ],
        "description": "Enqueues a campaign budget update on the TIKTOK_EDIT_BUDGET worker (`level=campaign`).",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "advertiser_id",
                  "budget"
                ],
                "properties": {
                  "advertiser_id": {
                    "minLength": 1,
                    "type": "string"
                  },
                  "budget": {
                    "exclusiveMinimum": 0,
                    "description": "New budget amount in advertiser currency.",
                    "type": "number"
                  },
                  "budget_mode": {
                    "description": "TikTok budget_mode (BUDGET_MODE_DAY, BUDGET_MODE_TOTAL, BUDGET_MODE_INFINITE).",
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "schema": {
              "minLength": 1,
              "type": "string"
            },
            "in": "path",
            "name": "campaignId",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Acknowledged enqueue (worker applies the change asynchronously).",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "description": "Acknowledged enqueue (worker applies the change asynchronously).",
                  "type": "object",
                  "required": [
                    "success",
                    "queued"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "queued": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/tiktok/adgroups/{adGroupId}/budget": {
      "post": {
        "operationId": "tiktokEditAdGroupBudget",
        "summary": "Edit a TikTok ad group budget",
        "tags": [
          "tiktok"
        ],
        "description": "Enqueues an ad-group budget update on the TIKTOK_EDIT_BUDGET worker (`level=adgroup`).",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "type": "object",
                "required": [
                  "advertiser_id",
                  "budget"
                ],
                "properties": {
                  "advertiser_id": {
                    "minLength": 1,
                    "type": "string"
                  },
                  "budget": {
                    "exclusiveMinimum": 0,
                    "description": "New budget amount in advertiser currency.",
                    "type": "number"
                  },
                  "budget_mode": {
                    "description": "TikTok budget_mode (BUDGET_MODE_DAY, BUDGET_MODE_TOTAL, BUDGET_MODE_INFINITE).",
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "schema": {
              "minLength": 1,
              "type": "string"
            },
            "in": "path",
            "name": "adGroupId",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Acknowledged enqueue (worker applies the change asynchronously).",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "description": "Acknowledged enqueue (worker applies the change asynchronously).",
                  "type": "object",
                  "required": [
                    "success",
                    "queued"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "queued": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/tiktok/pixels/sync": {
      "post": {
        "operationId": "syncAllTikTokPixels",
        "summary": "Sync TikTok pixels across all active tokens",
        "tags": [
          "tiktok"
        ],
        "description": "Enqueues a SYNC_TIKTOK_PIXELS job per (advertiser × active token) pair for the caller session. Returns the number of jobs queued.",
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "success",
                    "queued"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "queued": {
                      "description": "Number of (advertiser × token) sync jobs enqueued.",
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/tiktok/pixels": {
      "get": {
        "operationId": "listSyncedTikTokPixels",
        "summary": "List synced TikTok pixels for an advertiser",
        "tags": [
          "tiktok"
        ],
        "description": "Returns the persisted TikTok pixel rows previously synced via /api/v1/tiktok/pixels/sync.",
        "parameters": [
          {
            "schema": {
              "minLength": 1,
              "type": "string"
            },
            "in": "query",
            "name": "advertiser_id",
            "required": true
          }
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "pixels"
                  ],
                  "properties": {
                    "pixels": {
                      "type": "array",
                      "items": {
                        "additionalProperties": true,
                        "type": "object",
                        "required": [
                          "pixel_id",
                          "pixel_name",
                          "status"
                        ],
                        "properties": {
                          "pixel_id": {
                            "type": "string"
                          },
                          "pixel_name": {
                            "type": "string"
                          },
                          "status": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/worker-run-events": {
      "get": {
        "operationId": "listWorkerRunEvents",
        "summary": "List all worker run events",
        "tags": [
          "jobs"
        ],
        "description": "Returns a paginated list of worker run events for a given sheet_id, with optional filters by worker_run status (RUNNING|SUCCEEDED|FAILED), worker_type and date range.",
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "sheet_id",
            "required": true
          },
          {
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "enum": [
                    "RUNNING"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "SUCCEEDED"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "FAILED"
                  ]
                }
              ]
            },
            "in": "query",
            "name": "status",
            "required": false
          },
          {
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "enum": [
                    "SYNC_AD_ACCOUNTS"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "ASSIGN_AD_ACCOUNTS"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "SYNC_FAN_PAGES"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "ASSIGN_FAN_PAGES"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "SYNC_PIXELS"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "ASSIGN_PIXELS"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "SYNC_USERS"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "CAMPAIGN_REPORT"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "AD_REPORT"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "ADSET_REPORT"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "EDIT_CAMPAIGN_BUDGET"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "PAUSE_CAMPAIGN"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "EDIT_ADSET_BID"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "PAUSE_ADSET"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "TURN_OFF_ADS"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "DELETE_CAMPAIGNS_BY_ACCOUNT"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "SYNC_ADS_CHECKER"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "RELAUNCH_ADS"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "BULK_LAUNCH"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "TOGGLE_CAMPAIGN"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "TOGGLE_ADSET"
                  ]
                },
                {
                  "type": "string",
                  "enum": [
                    "TOGGLE_ADS"
                  ]
                }
              ]
            },
            "in": "query",
            "name": "type",
            "required": false
          },
          {
            "schema": {
              "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
              "type": "string"
            },
            "in": "query",
            "name": "from_date",
            "required": false,
            "description": "Date in YYYY-MM-DD (UTC)"
          },
          {
            "schema": {
              "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
              "type": "string"
            },
            "in": "query",
            "name": "to_date",
            "required": false,
            "description": "Date in YYYY-MM-DD (UTC)"
          },
          {
            "schema": {
              "minimum": 1,
              "maximum": 200,
              "type": "number"
            },
            "in": "query",
            "name": "limit",
            "required": false
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "cursor",
            "required": false
          }
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "type": "object",
                  "required": [
                    "items",
                    "next_cursor"
                  ],
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "additionalProperties": false,
                        "type": "object",
                        "required": [
                          "worker_run_id",
                          "worker_run_type",
                          "worker_run_status",
                          "worker_run_error_message",
                          "worker_run_started_at",
                          "worker_run_finished_at",
                          "worker_run_event_id",
                          "worker_run_event_status",
                          "worker_run_event_metadata",
                          "worker_run_event_created_at",
                          "worker_run_event_error_message"
                        ],
                        "properties": {
                          "worker_run_id": {
                            "format": "uuid",
                            "type": "string"
                          },
                          "worker_run_type": {
                            "type": "string"
                          },
                          "worker_run_status": {
                            "anyOf": [
                              {
                                "type": "string",
                                "enum": [
                                  "RUNNING"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "SUCCEEDED"
                                ]
                              },
                              {
                                "type": "string",
                                "enum": [
                                  "FAILED"
                                ]
                              }
                            ]
                          },
                          "worker_run_error_message": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "worker_run_started_at": {
                            "format": "date-time",
                            "type": "string"
                          },
                          "worker_run_finished_at": {
                            "anyOf": [
                              {
                                "format": "date-time",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "worker_run_event_id": {
                            "anyOf": [
                              {
                                "format": "uuid",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "worker_run_event_status": {
                            "anyOf": [
                              {
                                "anyOf": [
                                  {
                                    "type": "string",
                                    "enum": [
                                      "SUCCEEDED"
                                    ]
                                  },
                                  {
                                    "type": "string",
                                    "enum": [
                                      "FAILED"
                                    ]
                                  }
                                ]
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "worker_run_event_metadata": {
                            "anyOf": [
                              {
                                "$comment": "json-value",
                                "description": "Arbitrary JSON value with nested arrays and objects."
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "worker_run_event_created_at": {
                            "anyOf": [
                              {
                                "format": "date-time",
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "worker_run_event_error_message": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          }
                        }
                      }
                    },
                    "next_cursor": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request - schema validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - missing or invalid bearer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden - caller lacks the required role/permission",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "statusCode",
                    "error",
                    "message"
                  ],
                  "properties": {
                    "statusCode": {
                      "type": "number"
                    },
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  },
  "servers": [
    {
      "url": "https://api.wevion.ai",
      "description": "Production"
    },
    {
      "url": "https://api-stage.wevion.ai",
      "description": "Staging"
    },
    {
      "url": "http://localhost:3000",
      "description": "Local"
    }
  ],
  "tags": [
    {
      "name": "auth",
      "description": "Authentication, sessions, 2FA, account lifecycle."
    },
    {
      "name": "api-keys",
      "description": "Programmatic API key management."
    },
    {
      "name": "teams",
      "description": "Team membership, invites, roles, ownership."
    },
    {
      "name": "permissions",
      "description": "Business-user level permission sharing on Meta assets."
    },
    {
      "name": "onboarding",
      "description": "First-time setup wizard."
    },
    {
      "name": "workspace",
      "description": "Workspace preferences (per-user override + team preset)."
    },
    {
      "name": "meta",
      "description": "Meta OAuth, asset assignment, token sync."
    },
    {
      "name": "ad-accounts",
      "description": "Ad accounts (list, conversion settings, businesses, currencies, custom audiences)."
    },
    {
      "name": "fan-pages",
      "description": "Meta fan pages (list, posts, businesses)."
    },
    {
      "name": "pixels",
      "description": "Meta pixels (list, ad-account links, businesses)."
    },
    {
      "name": "catalogs",
      "description": "Meta product catalogs."
    },
    {
      "name": "catalog-products",
      "description": "Products inside a catalog."
    },
    {
      "name": "catalog-feeds",
      "description": "Product feed scheduling and uploads."
    },
    {
      "name": "product-audiences",
      "description": "Dynamic product audiences."
    },
    {
      "name": "google",
      "description": "Google Ads: row-level + bulk campaign/adgroup/ad delete, duplicate, toggle, budget edit, Performance Max asset groups, conversion actions and insights backfill."
    },
    {
      "name": "tiktok",
      "description": "TikTok Ads: row-level + bulk campaign/adgroup/ad delete, duplicate, toggle, budget edit, identities, pixels, apps, catalogs, lead forms and insights backfill."
    },
    {
      "name": "taboola",
      "description": "Taboola Ads: campaign + campaign-item delete and duplicate, toggle, budget edit, pixels and insights backfill."
    },
    {
      "name": "platforms",
      "description": "Cross-platform aggregator endpoints under `/api/v1/platforms/*` - connections stats and non-Meta user lifecycle (deactivate / delete Google / TikTok / Taboola tokens)."
    },
    {
      "name": "campaigns",
      "description": "Campaign drafts, templates, duplication, publish."
    },
    {
      "name": "ads",
      "description": "Ads / adsets actions (toggle, edit bid)."
    },
    {
      "name": "launch",
      "description": "Launch templates and resources."
    },
    {
      "name": "bulk-launch",
      "description": "Bulk and nested campaign launchers."
    },
    {
      "name": "ad-creatives",
      "description": "Ad creative assets, video, thumbnails."
    },
    {
      "name": "insights",
      "description": "Insights queries (campaign/adset/ad level + lookups)."
    },
    {
      "name": "analytics",
      "description": "High-level KPI/spend analytics."
    },
    {
      "name": "analytics-cross-channel",
      "description": "Unified cross-channel analytics across connected advertising platforms."
    },
    {
      "name": "dashboard",
      "description": "Dashboard summary stats."
    },
    {
      "name": "dashboard-layouts",
      "description": "Saved dashboard layouts."
    },
    {
      "name": "reports",
      "description": "PDF reports, schedules, templates, branding."
    },
    {
      "name": "trackers",
      "description": "Tracker configuration & sync."
    },
    {
      "name": "tracker-mappings",
      "description": "Tracker → Meta mappings (rules, manual, auto-detect)."
    },
    {
      "name": "tracker-breakdowns",
      "description": "Tracker stats grouped by sub-id, landing, offer, geo."
    },
    {
      "name": "access",
      "description": "Per-member Keitaro user access mappings (tracker access)."
    },
    {
      "name": "postback",
      "description": "Postback configuration and conversions log."
    },
    {
      "name": "utm",
      "description": "UTM templates and link history."
    },
    {
      "name": "ai-chat",
      "description": "AI chat sessions, projects, messages, credits, preferences."
    },
    {
      "name": "creative-hub",
      "description": "Creative Hub Drive: files, folders, sharing, thumbnails."
    },
    {
      "name": "creative-generation",
      "description": "AI generation (video, avatar, TTS, composite)."
    },
    {
      "name": "kb",
      "description": "Knowledge Base articles ingestion & retrieval."
    },
    {
      "name": "kb-admin",
      "description": "Knowledge Base admin endpoints (health, status, replay)."
    },
    {
      "name": "platform-knowledge",
      "description": "Free-form platform knowledge entries."
    },
    {
      "name": "notifications",
      "description": "In-app notifications and preferences (legacy)."
    },
    {
      "name": "telegram",
      "description": "Telegram channel link and preferences."
    },
    {
      "name": "slack-notifications",
      "description": "Slack channel install, callback, destinations."
    },
    {
      "name": "billing",
      "description": "Stripe checkout, subscriptions, plans, payments."
    },
    {
      "name": "jobs",
      "description": "Job runs and events."
    },
    {
      "name": "cron",
      "description": "Cron triggers and status."
    },
    {
      "name": "sync",
      "description": "Manual sync triggers."
    },
    {
      "name": "metrics",
      "description": "Internal observability metrics (Meta, SQS, trackers)."
    },
    {
      "name": "audit",
      "description": "Audit log query and export."
    },
    {
      "name": "rules",
      "description": "Automation rules engine."
    },
    {
      "name": "release-candidates",
      "description": "Release candidates."
    },
    {
      "name": "asset-events",
      "description": "SSE asset event stream."
    },
    {
      "name": "webhooks",
      "description": "Inbound webhooks (Featurebase, GitHub)."
    },
    {
      "name": "featurebase",
      "description": "Featurebase changelog/roadmap integration."
    },
    {
      "name": "beta-feedback",
      "description": "Beta feedback bug tracking."
    },
    {
      "name": "health",
      "description": "Liveness and readiness probes."
    },
    {
      "name": "web-push",
      "description": "Web Push subscription management for the current user."
    },
    {
      "name": "search",
      "description": "Universal search."
    },
    {
      "name": "targeting",
      "description": "Meta targeting lookups (geo, etc)."
    }
  ],
  "x-tagGroups": [
    {
      "name": "Identity",
      "tags": [
        "auth",
        "api-keys",
        "teams",
        "permissions",
        "onboarding",
        "workspace"
      ]
    },
    {
      "name": "Meta",
      "tags": [
        "meta",
        "ad-accounts",
        "fan-pages",
        "pixels",
        "catalogs",
        "catalog-products",
        "catalog-feeds",
        "product-audiences",
        "campaigns",
        "ads",
        "bulk-launch",
        "ad-creatives",
        "launch"
      ]
    },
    {
      "name": "Google",
      "tags": [
        "google"
      ]
    },
    {
      "name": "TikTok",
      "tags": [
        "tiktok"
      ]
    },
    {
      "name": "Taboola",
      "tags": [
        "taboola"
      ]
    },
    {
      "name": "Platforms",
      "tags": [
        "platforms"
      ]
    },
    {
      "name": "Insights",
      "tags": [
        "insights",
        "analytics",
        "analytics-cross-channel",
        "dashboard",
        "dashboard-layouts",
        "reports"
      ]
    },
    {
      "name": "Trackers",
      "tags": [
        "trackers",
        "tracker-mappings",
        "tracker-breakdowns",
        "access",
        "postback",
        "utm"
      ]
    },
    {
      "name": "AI & Knowledge",
      "tags": [
        "ai-chat",
        "creative-hub",
        "creative-generation",
        "kb",
        "kb-admin",
        "platform-knowledge"
      ]
    },
    {
      "name": "Notifications",
      "tags": [
        "notifications",
        "telegram",
        "slack-notifications"
      ]
    },
    {
      "name": "Billing",
      "tags": [
        "billing"
      ]
    },
    {
      "name": "Operations",
      "tags": [
        "jobs",
        "cron",
        "sync",
        "metrics",
        "audit",
        "rules",
        "release-candidates",
        "asset-events",
        "webhooks",
        "featurebase",
        "beta-feedback"
      ]
    },
    {
      "name": "Internal",
      "tags": [
        "health",
        "web-push",
        "search",
        "targeting"
      ]
    }
  ]
}
